| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/i18n/time_formatting.h" | 12 #include "base/i18n/time_formatting.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "chrome/browser/certificate_viewer.h" | 17 #include "chrome/browser/certificate_viewer.h" |
| 18 #include "chrome/browser/platform_util.h" | 18 #include "chrome/browser/platform_util.h" |
| 19 #include "chrome/browser/ui/browser_dialogs.h" | 19 #include "chrome/browser/ui/browser_dialogs.h" |
| 20 #include "chrome/browser/ui/certificate_dialogs.h" | 20 #include "chrome/browser/ui/certificate_dialogs.h" |
| 21 #include "chrome/browser/ui/webui/certificate_viewer_ui.h" | 21 #include "chrome/browser/ui/webui/certificate_viewer_ui.h" |
| 22 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | 22 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
| 23 #include "chrome/common/net/x509_certificate_model.h" | 23 #include "chrome/common/net/x509_certificate_model.h" |
| 24 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| 25 #include "chrome/grit/generated_resources.h" | 25 #include "chrome/grit/generated_resources.h" |
| 26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/gfx/geometry/size.h" | 28 #include "ui/gfx/geometry/size.h" |
| 29 #include "ui/gfx/view_util.h" |
| 29 | 30 |
| 30 using content::WebContents; | 31 using content::WebContents; |
| 31 using content::WebUIMessageHandler; | 32 using content::WebUIMessageHandler; |
| 32 | 33 |
| 33 // Shows a certificate using the WebUI certificate viewer. | 34 // Shows a certificate using the WebUI certificate viewer. |
| 34 void ShowCertificateViewer(WebContents* web_contents, | 35 void ShowCertificateViewer(WebContents* web_contents, |
| 35 gfx::NativeWindow parent, | 36 gfx::NativeWindow parent, |
| 36 net::X509Certificate* cert) { | 37 net::X509Certificate* cert) { |
| 37 CertificateViewerDialog* dialog = new CertificateViewerDialog(cert); | 38 CertificateViewerDialog* dialog = new CertificateViewerDialog(cert); |
| 38 dialog->Show(web_contents, parent); | 39 dialog->Show(web_contents, parent); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 base::Unretained(this))); | 270 base::Unretained(this))); |
| 270 } | 271 } |
| 271 | 272 |
| 272 void CertificateViewerDialogHandler::ExportCertificate( | 273 void CertificateViewerDialogHandler::ExportCertificate( |
| 273 const base::ListValue* args) { | 274 const base::ListValue* args) { |
| 274 int cert_index = GetCertificateIndex(args); | 275 int cert_index = GetCertificateIndex(args); |
| 275 if (cert_index < 0) | 276 if (cert_index < 0) |
| 276 return; | 277 return; |
| 277 | 278 |
| 278 gfx::NativeWindow window = | 279 gfx::NativeWindow window = |
| 279 platform_util::GetTopLevel(dialog_->GetNativeWebContentsModalDialog()); | 280 gfx::GetTopLevel(dialog_->GetNativeWebContentsModalDialog()); |
| 280 ShowCertExportDialog(web_ui()->GetWebContents(), | 281 ShowCertExportDialog(web_ui()->GetWebContents(), |
| 281 window, | 282 window, |
| 282 cert_chain_.begin() + cert_index, | 283 cert_chain_.begin() + cert_index, |
| 283 cert_chain_.end()); | 284 cert_chain_.end()); |
| 284 } | 285 } |
| 285 | 286 |
| 286 void CertificateViewerDialogHandler::RequestCertificateFields( | 287 void CertificateViewerDialogHandler::RequestCertificateFields( |
| 287 const base::ListValue* args) { | 288 const base::ListValue* args) { |
| 288 int cert_index = GetCertificateIndex(args); | 289 int cert_index = GetCertificateIndex(args); |
| 289 if (cert_index < 0) | 290 if (cert_index < 0) |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 const base::ListValue* args) const { | 461 const base::ListValue* args) const { |
| 461 int cert_index; | 462 int cert_index; |
| 462 double val; | 463 double val; |
| 463 if (!(args->GetDouble(0, &val))) | 464 if (!(args->GetDouble(0, &val))) |
| 464 return -1; | 465 return -1; |
| 465 cert_index = static_cast<int>(val); | 466 cert_index = static_cast<int>(val); |
| 466 if (cert_index < 0 || cert_index >= static_cast<int>(cert_chain_.size())) | 467 if (cert_index < 0 || cert_index >= static_cast<int>(cert_chain_.size())) |
| 467 return -1; | 468 return -1; |
| 468 return cert_index; | 469 return cert_index; |
| 469 } | 470 } |
| OLD | NEW |