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 |
(...skipping 21 matching lines...) Expand all Loading... |
40 virtual std::string GetDialogArgs() const OVERRIDE; | 41 virtual std::string GetDialogArgs() const OVERRIDE; |
41 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; | 42 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; |
42 virtual void OnCloseContents( | 43 virtual void OnCloseContents( |
43 TabContents* source, bool* out_close_dialog) OVERRIDE; | 44 TabContents* source, bool* out_close_dialog) OVERRIDE; |
44 virtual bool ShouldShowDialogTitle() const OVERRIDE; | 45 virtual bool ShouldShowDialogTitle() const OVERRIDE; |
45 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; | 46 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; |
46 | 47 |
47 // The certificate being viewed. | 48 // The certificate being viewed. |
48 scoped_refptr<net::X509Certificate> cert_; | 49 scoped_refptr<net::X509Certificate> cert_; |
49 | 50 |
50 // The argument string for the dialog which passes the certificate pointer. | |
51 std::string json_args_; | |
52 | |
53 // The title of the certificate viewer dialog, Certificate Viewer: CN. | 51 // The title of the certificate viewer dialog, Certificate Viewer: CN. |
54 string16 title_; | 52 string16 title_; |
55 | 53 |
56 DISALLOW_COPY_AND_ASSIGN(CertificateViewerDialog); | 54 DISALLOW_COPY_AND_ASSIGN(CertificateViewerDialog); |
57 }; | 55 }; |
58 | 56 |
| 57 // Dialog handler which handles calls from the JS WebUI code to view certificate |
| 58 // details and export the certificate. |
| 59 class CertificateViewerDialogHandler : public WebUIMessageHandler { |
| 60 public: |
| 61 explicit CertificateViewerDialogHandler(net::X509Certificate* cert); |
| 62 |
| 63 // Overridden from WebUIMessageHandler |
| 64 virtual void RegisterMessages(); |
| 65 |
| 66 private: |
| 67 // Brings up the export certificate dialog for the chosen certificate in the |
| 68 // chain. |
| 69 // |
| 70 // The input is an integer index to the certificate in the chain to export. |
| 71 void ExportCertificate(const base::ListValue* args); |
| 72 |
| 73 // Gets the details for a specific certificate in the certificate chain. Calls |
| 74 // the javascript function cert_viewer.getCertificateFields with a tree |
| 75 // structure containing the fields and values for certain nodes. |
| 76 // |
| 77 // The input is an integer index to the certificate in the chain to view. |
| 78 void RequestCertificateFields(const base::ListValue* args); |
| 79 |
| 80 // Extracts the certificate details and returns them to the javascript |
| 81 // function cert_viewer.getCertificateInfo in a dictionary structure. |
| 82 void RequestCertificateInfo(const base::ListValue* args); |
| 83 |
| 84 // The certificate being viewed. |
| 85 scoped_refptr<net::X509Certificate> cert_; |
| 86 |
| 87 // The certificate chain. |
| 88 net::X509Certificate::OSCertHandles cert_chain_; |
| 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(CertificateViewerDialogHandler); |
| 91 }; |
| 92 |
59 #endif // CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_H_ | 93 #endif // CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_H_ |
OLD | NEW |