| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/certificate_viewer_webui.h" | 5 #include "chrome/browser/ui/webui/certificate_viewer_webui.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/certificate_viewer.h" | 13 #include "chrome/browser/certificate_viewer.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_dialogs.h" | 15 #include "chrome/browser/ui/browser_dialogs.h" |
| 16 #include "chrome/browser/ui/browser_list.h" | 16 #include "chrome/browser/ui/browser_list.h" |
| 17 #include "chrome/browser/ui/certificate_dialogs.h" | 17 #include "chrome/browser/ui/certificate_dialogs.h" |
| 18 #include "chrome/browser/ui/constrained_window.h" | 18 #include "chrome/browser/ui/constrained_window.h" |
| 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 20 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | |
| 21 #include "chrome/browser/ui/webui/web_dialog_observer.h" | |
| 22 #include "chrome/common/net/x509_certificate_model.h" | 20 #include "chrome/common/net/x509_certificate_model.h" |
| 23 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 24 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 25 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/web_dialogs/constrained_web_dialog_ui.h" |
| 26 #include "ui/web_dialogs/web_dialog_observer.h" |
| 27 | 27 |
| 28 using content::WebContents; | 28 using content::WebContents; |
| 29 using content::WebUIMessageHandler; | 29 using content::WebUIMessageHandler; |
| 30 using ui::WebDialogObserver; |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 // Default width/height of the dialog. | 34 // Default width/height of the dialog. |
| 34 const int kDefaultWidth = 580; | 35 const int kDefaultWidth = 580; |
| 35 const int kDefaultHeight = 600; | 36 const int kDefaultHeight = 600; |
| 36 | 37 |
| 37 } // namespace | 38 } // namespace |
| 38 | 39 |
| 39 // Shows a certificate using the WebUI certificate viewer. | 40 // Shows a certificate using the WebUI certificate viewer. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 68 } | 69 } |
| 69 | 70 |
| 70 void CertificateViewerDialog::Show(gfx::NativeWindow parent) { | 71 void CertificateViewerDialog::Show(gfx::NativeWindow parent) { |
| 71 // TODO(oshima): Should get browser from parent. | 72 // TODO(oshima): Should get browser from parent. |
| 72 Browser* browser = BrowserList::GetLastActive(); | 73 Browser* browser = BrowserList::GetLastActive(); |
| 73 DCHECK(browser); | 74 DCHECK(browser); |
| 74 TabContentsWrapper* current_wrapper = | 75 TabContentsWrapper* current_wrapper = |
| 75 browser->GetSelectedTabContentsWrapper(); | 76 browser->GetSelectedTabContentsWrapper(); |
| 76 // TODO(bshe): UI tweaks needed for AURA html Dialog, such as add padding on | 77 // TODO(bshe): UI tweaks needed for AURA html Dialog, such as add padding on |
| 77 // title for AURA ConstrainedWebDialogUI. | 78 // title for AURA ConstrainedWebDialogUI. |
| 78 window_ = ConstrainedWebDialogUI::CreateConstrainedWebDialog( | 79 window_ = ui::CreateConstrainedWebDialog( |
| 79 current_wrapper->profile(), | 80 current_wrapper->profile(), |
| 80 this, | 81 this, |
| 81 NULL, | 82 NULL, |
| 82 current_wrapper)->window()->GetNativeWindow(); | 83 current_wrapper)->window()->GetNativeWindow(); |
| 83 } | 84 } |
| 84 | 85 |
| 85 ui::ModalType CertificateViewerDialog::GetDialogModalType() const { | 86 ui::ModalType CertificateViewerDialog::GetDialogModalType() const { |
| 86 return ui::MODAL_TYPE_NONE; | 87 return ui::MODAL_TYPE_NONE; |
| 87 } | 88 } |
| 88 | 89 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 const base::ListValue* args) const { | 412 const base::ListValue* args) const { |
| 412 int cert_index; | 413 int cert_index; |
| 413 double val; | 414 double val; |
| 414 if (!(args->GetDouble(0, &val))) | 415 if (!(args->GetDouble(0, &val))) |
| 415 return -1; | 416 return -1; |
| 416 cert_index = static_cast<int>(val); | 417 cert_index = static_cast<int>(val); |
| 417 if (cert_index < 0 || cert_index >= static_cast<int>(cert_chain_.size())) | 418 if (cert_index < 0 || cert_index >= static_cast<int>(cert_chain_.size())) |
| 418 return -1; | 419 return -1; |
| 419 return cert_index; | 420 return cert_index; |
| 420 } | 421 } |
| OLD | NEW |