OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include "base/values.h" |
9 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 10 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
10 #include "net/base/x509_certificate.h" | 11 #include "net/base/x509_certificate.h" |
11 #include "ui/gfx/native_widget_types.h" | 12 #include "ui/gfx/native_widget_types.h" |
12 | 13 |
13 // Displays the WebUI certificate viewer dialog for the passed in certificate. | 14 // Displays the WebUI certificate viewer dialog for the passed in certificate. |
14 void ShowCertificateViewer(gfx::NativeWindow parent, | 15 void ShowCertificateViewer(gfx::NativeWindow parent, |
15 net::X509Certificate*); | 16 net::X509Certificate*); |
16 | 17 |
17 // Dialog for displaying detailed certificate information. This is used in linux | 18 // Dialog for displaying detailed certificate information. This is used in linux |
18 // and chromeos builds to display detailed information in a floating dialog when | 19 // and chromeos builds to display detailed information in a floating dialog when |
19 // the user clicks on "Certificate Information" from the lock icon of a web site | 20 // the user clicks on "Certificate Information" from the lock icon of a web site |
20 // or "View" from the Certificate Manager. | 21 // or "View" from the Certificate Manager. |
21 class CertificateViewerDialog : private HtmlDialogUIDelegate { | 22 class CertificateViewerDialog : private HtmlDialogUIDelegate { |
22 public: | 23 public: |
23 // Shows the certificate viewer dialog for the passed in certificate. | 24 // Shows the certificate viewer dialog for the passed in certificate. |
24 static void ShowDialog(gfx::NativeWindow owning_window, | 25 static void ShowDialog(gfx::NativeWindow parent, |
25 net::X509Certificate* cert); | 26 net::X509Certificate* cert); |
26 | 27 |
27 private: | 28 private: |
28 // Construct a certificate viewer for the passed in certificate. A reference | 29 // Construct a certificate viewer for the passed in certificate. A reference |
29 // to the certificate pointer is added for the lifetime of the certificate | 30 // to the certificate pointer is added for the lifetime of the certificate |
30 // viewer. | 31 // viewer. |
31 explicit CertificateViewerDialog(net::X509Certificate* cert); | 32 explicit CertificateViewerDialog(gfx::NativeWindow parent, |
| 33 net::X509Certificate* cert); |
32 | 34 |
33 // Overridden from HtmlDialogUI::Delegate: | 35 // Overridden from HtmlDialogUI::Delegate: |
34 virtual bool IsDialogModal() const OVERRIDE; | 36 virtual bool IsDialogModal() const OVERRIDE; |
35 virtual string16 GetDialogTitle() const OVERRIDE; | 37 virtual string16 GetDialogTitle() const OVERRIDE; |
36 virtual GURL GetDialogContentURL() const OVERRIDE; | 38 virtual GURL GetDialogContentURL() const OVERRIDE; |
37 virtual void GetWebUIMessageHandlers( | 39 virtual void GetWebUIMessageHandlers( |
38 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE; | 40 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE; |
39 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; | 41 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; |
40 virtual std::string GetDialogArgs() const OVERRIDE; | 42 virtual std::string GetDialogArgs() const OVERRIDE; |
41 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; | 43 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; |
42 virtual void OnCloseContents( | 44 virtual void OnCloseContents( |
43 TabContents* source, bool* out_close_dialog) OVERRIDE; | 45 TabContents* source, bool* out_close_dialog) OVERRIDE; |
44 virtual bool ShouldShowDialogTitle() const OVERRIDE; | 46 virtual bool ShouldShowDialogTitle() const OVERRIDE; |
45 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; | 47 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; |
46 | 48 |
47 // The certificate being viewed. | 49 // The certificate being viewed. |
48 scoped_refptr<net::X509Certificate> cert_; | 50 scoped_refptr<net::X509Certificate> cert_; |
49 | 51 |
50 // The argument string for the dialog which passes the certificate pointer. | 52 // The owning window. |
51 std::string json_args_; | 53 gfx::NativeWindow parent_; |
52 | 54 |
53 // The title of the certificate viewer dialog, Certificate Viewer: CN. | 55 // The title of the certificate viewer dialog, Certificate Viewer: CN. |
54 string16 title_; | 56 string16 title_; |
55 | 57 |
56 DISALLOW_COPY_AND_ASSIGN(CertificateViewerDialog); | 58 DISALLOW_COPY_AND_ASSIGN(CertificateViewerDialog); |
57 }; | 59 }; |
58 | 60 |
| 61 // Dialog handler which handles calls from the JS WebUI code to view certificate |
| 62 // details and export the certificate. |
| 63 class CertificateViewerDialogHandler : public WebUIMessageHandler { |
| 64 public: |
| 65 CertificateViewerDialogHandler(gfx::NativeWindow parent, |
| 66 net::X509Certificate* cert); |
| 67 |
| 68 // Overridden from WebUIMessageHandler |
| 69 virtual void RegisterMessages(); |
| 70 |
| 71 private: |
| 72 // Brings up the export certificate dialog for the chosen certificate in the |
| 73 // chain. |
| 74 // |
| 75 // The input is an integer index to the certificate in the chain to export. |
| 76 void ExportCertificate(const base::ListValue* args); |
| 77 |
| 78 // Gets the details for a specific certificate in the certificate chain. Calls |
| 79 // the javascript function cert_viewer.getCertificateFields with a tree |
| 80 // structure containing the fields and values for certain nodes. |
| 81 // |
| 82 // The input is an integer index to the certificate in the chain to view. |
| 83 void RequestCertificateFields(const base::ListValue* args); |
| 84 |
| 85 // Extracts the certificate details and returns them to the javascript |
| 86 // function cert_viewer.getCertificateInfo in a dictionary structure. |
| 87 void RequestCertificateInfo(const base::ListValue* args); |
| 88 |
| 89 // The certificate being viewed. |
| 90 scoped_refptr<net::X509Certificate> cert_; |
| 91 |
| 92 // The parent window. |
| 93 gfx::NativeWindow parent_; |
| 94 |
| 95 // The certificate chain. |
| 96 net::X509Certificate::OSCertHandles cert_chain_; |
| 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(CertificateViewerDialogHandler); |
| 99 }; |
| 100 |
59 #endif // CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_H_ | 101 #endif // CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_H_ |
OLD | NEW |