diff options
author | flackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-14 15:22:18 +0000 |
---|---|---|
committer | flackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-14 15:22:18 +0000 |
commit | 8ebc9b4348260fb7b0c1f116af8d758156359320 (patch) | |
tree | 46a83cc28bdbb185b47f8d3aa4dac9af86468a63 /chrome | |
parent | a17df4d7a6e87c141d1add055516a8244a581a1b (diff) | |
download | chromium_src-8ebc9b4348260fb7b0c1f116af8d758156359320.zip chromium_src-8ebc9b4348260fb7b0c1f116af8d758156359320.tar.gz chromium_src-8ebc9b4348260fb7b0c1f116af8d758156359320.tar.bz2 |
Add WebUI certificate viewer to eventually replace GTK certificate viewer.
Hidden behind the gyp flag webui_certificate_viewer, this dialog will replace the GTK certificate viewer as part of the nogtk effort. This CL only adds the new certificate viewer but does not use it unless compiled with webui_certificate_viewer=1.
This is the first stage, which adds the viewer and only shows the "General" certificate details (As shown in the General tab in the GTK viewer). The next steps are to show the detailed information, resolve some minor display and functionality issues on desktop builds and then make this the standard certificate viewer.
BUG=None
TEST=Manually viewed certificate details for several secure sites.
Review URL: http://codereview.chromium.org/7331016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92541 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_resources.grd | 5 | ||||
-rw-r--r-- | chrome/browser/resources/certificate_viewer.css | 38 | ||||
-rw-r--r-- | chrome/browser/resources/certificate_viewer.html | 78 | ||||
-rw-r--r-- | chrome/browser/resources/certificate_viewer.js | 50 | ||||
-rw-r--r-- | chrome/browser/ui/webui/certificate_viewer.cc | 110 | ||||
-rw-r--r-- | chrome/browser/ui/webui/certificate_viewer.h | 60 | ||||
-rw-r--r-- | chrome/browser/ui/webui/certificate_viewer_ui.cc | 161 | ||||
-rw-r--r-- | chrome/browser/ui/webui/certificate_viewer_ui.h | 29 | ||||
-rw-r--r-- | chrome/browser/ui/webui/chrome_web_ui_factory.cc | 8 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 29 | ||||
-rw-r--r-- | chrome/common/url_constants.cc | 2 | ||||
-rw-r--r-- | chrome/common/url_constants.h | 2 |
12 files changed, 572 insertions, 0 deletions
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index 8822f4c..406c3ed 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -29,6 +29,11 @@ <include name="IDR_ABOUT_VERSION_HTML" file="resources\about_version.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_ABOUT_VERSION_JS" file="resources\about_version.js" type="BINDATA" /> <include name="IDR_BOOKMARKS_MANIFEST" file="resources\bookmark_manager\manifest.json" type="BINDATA" /> + <if expr="pp_if('webui_certificate_viewer')"> + <include name="IDR_CERTIFICATE_VIEWER_HTML" file="resources\certificate_viewer.html" type="BINDATA" /> + <include name="IDR_CERTIFICATE_VIEWER_JS" file="resources\certificate_viewer.js" type="BINDATA" /> + <include name="IDR_CERTIFICATE_VIEWER_CSS" file="resources\certificate_viewer.css" type="BINDATA" /> + </if> <include name="IDR_CRASHES_HTML" file="resources\crashes.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_CRASHES_JS" file="resources\crashes.js" type="BINDATA" /> <include name="IDR_CREDITS_HTML" file="resources\about_credits.html" flattenhtml="true" type="BINDATA" /> diff --git a/chrome/browser/resources/certificate_viewer.css b/chrome/browser/resources/certificate_viewer.css new file mode 100644 index 0000000..553e8e3 --- /dev/null +++ b/chrome/browser/resources/certificate_viewer.css @@ -0,0 +1,38 @@ +.title { + font-weight: bold; + padding-top: 5px; +} + +#usages { + -webkit-padding-start: 15px; + padding-top: 5px; + white-space: pre-wrap; +} + +.groups { + display: table; +} + +.group, +.detail { + display: table-row; +} + +.detail div { + -webkit-padding-start: 15px; + padding: 3px; +} + +.attribute { + display: table-cell; + white-space: nowrap; +} + +.value { + display: table-cell; + white-space: pre-wrap; +} + +.controls { + text-align: end; +} diff --git a/chrome/browser/resources/certificate_viewer.html b/chrome/browser/resources/certificate_viewer.html new file mode 100644 index 0000000..ef8e09b --- /dev/null +++ b/chrome/browser/resources/certificate_viewer.html @@ -0,0 +1,78 @@ +<html> + <head> + <title id="title"></title> + <link rel="stylesheet" type="text/css" href="certificate_viewer.css"> + <script src="strings.js"></script> + <script src="chrome://resources/js/cr.js"></script> + <script src="chrome://resources/js/i18n_template.js"></script> + <script src="chrome://resources/js/util.js"></script> + <script src="certificate_viewer.js"></script> + </head> + <body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize"> + <div class="title"> + <span i18n-content="usages"></span> + </div> + <div id="usages"></div> + <div class="groups"> + <div class="group"> + <span class="title" i18n-content="issuedto"></span> + </div> + <div class="detail"> + <div class="attribute" i18n-content="cn"></div> + <div id="issued-cn" class="value"></div> + </div> + <div class="detail"> + <div class="attribute" i18n-content="o"></div> + <div id="issued-o" class="value"></div> + </div> + <div class="detail"> + <div class="attribute" i18n-content="ou"></div> + <div id="issued-ou" class="value"></div> + </div> + <div class="detail"> + <div class="attribute" i18n-content="sn"></div> + <div id="issued-sn" class="value"></div> + </div> + <div class="group"> + <span class="title" i18n-content="issuedby"></span> + </div> + <div class="detail"> + <div class="attribute" i18n-content="cn"></div> + <div id="issuer-cn" class="value"></div> + </div> + <div class="detail"> + <div class="attribute" i18n-content="o"></div> + <div id="issuer-o" class="value"></div> + </div> + <div class="detail"> + <div class="attribute" i18n-content="ou"></div> + <div id="issuer-ou" class="value"></div> + </div> + <div class="group"> + <span class="title" i18n-content="validity"></span> + </div> + <div class="detail"> + <div class="attribute" i18n-content="issuedon"></div> + <div id="issuedate" class="value"></div> + </div> + <div class="detail"> + <div class="attribute" i18n-content="expireson"></div> + <div id="expirydate" class="value"></div> + </div> + <div class="group"> + <span class="title" i18n-content="fingerprints"></span> + </div> + <div class="detail"> + <div class="attribute" i18n-content="sha256"></div> + <div id="sha256" class="value"></div> + </div> + <div class="detail"> + <div class="attribute" i18n-content="sha1"></div> + <div id="sha1" class="value"></div> + </div> + </div> + <div class="controls"> + <button id="close" i18n-content="close"></button> + </div> + </body> +</html> diff --git a/chrome/browser/resources/certificate_viewer.js b/chrome/browser/resources/certificate_viewer.js new file mode 100644 index 0000000..c3a506f --- /dev/null +++ b/chrome/browser/resources/certificate_viewer.js @@ -0,0 +1,50 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +cr.define('cert_viewer', function() { + 'use strict'; + + /** + * Initialize the certificate viewer dialog by wiring up the close button, + * substituting in translated strings and requesting certificate details. + */ + function initialize() { + $('close').onclick = function() { + window.close(); + } + i18nTemplate.process(document, templateData); + requestCertificate(); + } + + /** + * Requests certificate information. The requested certificate is identified + * by a unique handle. + **/ + function requestCertificate() { + var params = parseQueryParams(location); + + // If a certificate identifier hasn't been specified, do nothing. + // @TODO(flackr) Display some sort of default / error page. + if (params['cert']) + chrome.send('requestCertificateInfo', [params['cert']]); + } + + /** + * This function is called from certificate_viewer_ui.cc with the certificate + * information. Display all returned information to the user. + * @param {Object} certInfo Certificate information in named fields. + */ + function getCertificateInfo(certInfo) { + for (var key in certInfo) { + $(key).textContent = certInfo[key]; + } + } + + return { + initialize: initialize, + getCertificateInfo: getCertificateInfo, + }; +}); + +document.addEventListener('DOMContentLoaded', cert_viewer.initialize); diff --git a/chrome/browser/ui/webui/certificate_viewer.cc b/chrome/browser/ui/webui/certificate_viewer.cc new file mode 100644 index 0000000..b610032 --- /dev/null +++ b/chrome/browser/ui/webui/certificate_viewer.cc @@ -0,0 +1,110 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/utf_string_conversions.h" +#include "base/string_number_conversions.h" +#include "chrome/browser/ui/webui/certificate_viewer.h" +#include "chrome/common/url_constants.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/views/html_dialog_view.h" +#include "chrome/browser/ui/browser_dialogs.h" +#include "chrome/common/net/x509_certificate_model.h" +#include "ui/base/l10n/l10n_util.h" +#include "grit/generated_resources.h" + +namespace { + +// Default width/height of the dialog. +const int kDefaultWidth = 450; +const int kDefaultHeight = 450; + +} // namespace + +// Shows a certificate using the WebUI certificate viewer. +void ShowCertificateViewer(gfx::NativeWindow parent, + net::X509Certificate* cert) { + CertificateViewerDialog::ShowDialog(parent, cert); +} + +void CertificateViewerDialog::ShowDialog(gfx::NativeWindow owning_window, + net::X509Certificate* cert) { + Browser* browser = BrowserList::GetLastActive(); + DCHECK(browser); + browser->BrowserShowHtmlDialog(new CertificateViewerDialog(cert), + owning_window); +} + +// TODO(flackr): This is duplicated from cookies_view_handler.cc +// Encodes a pointer value into a hex string. +std::string PointerToHexString(const void* pointer) { + return base::HexEncode(&pointer, sizeof(pointer)); +} + +CertificateViewerDialog::CertificateViewerDialog(net::X509Certificate* cert) + : cert_(cert) { + // Construct the certificate viewer URL to view the stored certificate. + // TODO(flackr): The certificate pointer could be passed through DialogArgs, + // however GetDialogArgs is currently not called in Linux builds. When + // GTK dialogs are fixed or replaced with Views move the certificate + // pointer to DialogArgs to remove the potential of entering a URL which + // may crash the browser. + GURL::Replacements replacements; + std::string query_string = "cert=" + PointerToHexString(cert_); + replacements.SetQuery(query_string.c_str(), url_parse::Component(0, + query_string.length())); + dialogURL_ = GURL(chrome::kChromeUICertificateViewerURL). + ReplaceComponents(replacements); + + // Construct the dialog title from the certificate. + net::X509Certificate::OSCertHandles cert_chain; + x509_certificate_model::GetCertChainFromCert(cert_->os_cert_handle(), + &cert_chain); + title_ = UTF16ToWide(l10n_util::GetStringFUTF16( + IDS_CERT_INFO_DIALOG_TITLE, UTF8ToUTF16(x509_certificate_model::GetTitle( + cert_chain.front())))); +} + +bool CertificateViewerDialog::IsDialogModal() const { + return false; +} + +std::wstring CertificateViewerDialog::GetDialogTitle() const { + return title_; +} + +GURL CertificateViewerDialog::GetDialogContentURL() const { + return dialogURL_; +} + +void CertificateViewerDialog::GetWebUIMessageHandlers( + std::vector<WebUIMessageHandler*>* handlers) const { +} + +void CertificateViewerDialog::GetDialogSize(gfx::Size* size) const { + size->SetSize(kDefaultWidth, kDefaultHeight); +} + +std::string CertificateViewerDialog::GetDialogArgs() const { + return std::string(); +} + +void CertificateViewerDialog::OnDialogClosed(const std::string& json_retval) { + delete this; +} + +void CertificateViewerDialog::OnCloseContents(TabContents* source, + bool* out_close_dialog) { + if (out_close_dialog) + *out_close_dialog = true; +} + +bool CertificateViewerDialog::ShouldShowDialogTitle() const { + return true; +} + +bool CertificateViewerDialog::HandleContextMenu( + const ContextMenuParams& params) { + return true; +} diff --git a/chrome/browser/ui/webui/certificate_viewer.h b/chrome/browser/ui/webui/certificate_viewer.h new file mode 100644 index 0000000..28aad1a --- /dev/null +++ b/chrome/browser/ui/webui/certificate_viewer.h @@ -0,0 +1,60 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_H_ +#define CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_H_ +#pragma once + +#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "net/base/x509_certificate.h" +#include "ui/gfx/native_widget_types.h" + +// Displays the WebUI certificate viewer dialog for the passed in certificate. +void ShowCertificateViewer(gfx::NativeWindow parent, + net::X509Certificate*); + +// Dialog for displaying detailed certificate information. This is used in linux +// and chromeos builds to display detailed information in a floating dialog when +// the user clicks on "Certificate Information" from the lock icon of a web site +// or "View" from the Certificate Manager. +class CertificateViewerDialog : private HtmlDialogUIDelegate { + public: + // Shows the certificate viewer dialog for the passed in certificate. + static void ShowDialog(gfx::NativeWindow owning_window, + net::X509Certificate* cert); + + private: + // Construct a certificate viewer for the passed in certificate. A reference + // to the certificate pointer is added for the lifetime of the certificate + // viewer. + explicit CertificateViewerDialog(net::X509Certificate* cert); + + // Overridden from HtmlDialogUI::Delegate: + virtual bool IsDialogModal() const OVERRIDE; + virtual std::wstring GetDialogTitle() const OVERRIDE; + virtual GURL GetDialogContentURL() const OVERRIDE; + virtual void GetWebUIMessageHandlers( + std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE; + virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; + virtual std::string GetDialogArgs() const OVERRIDE; + virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; + virtual void OnCloseContents( + TabContents* source, bool* out_close_dialog) OVERRIDE; + virtual bool ShouldShowDialogTitle() const OVERRIDE; + virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; + + // The certificate being viewed. + scoped_refptr<net::X509Certificate> cert_; + + // The URL of the dialog of the form chrome://view-cert/?cert=X where X is the + // hex encoded pointer to the certificate being displayed. + GURL dialogURL_; + + // The title of the certificate viewer dialog, Certificate Viewer: CN. + std::wstring title_; + + DISALLOW_COPY_AND_ASSIGN(CertificateViewerDialog); +}; + +#endif // CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_H_ diff --git a/chrome/browser/ui/webui/certificate_viewer_ui.cc b/chrome/browser/ui/webui/certificate_viewer_ui.cc new file mode 100644 index 0000000..c08c454 --- /dev/null +++ b/chrome/browser/ui/webui/certificate_viewer_ui.cc @@ -0,0 +1,161 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/webui/certificate_viewer_ui.h" + +#include "base/string_number_conversions.h" +#include "base/i18n/time_formatting.h" +#include "base/utf_string_conversions.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" +#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" +#include "chrome/common/url_constants.h" +#include "chrome/common/net/x509_certificate_model.h" +#include "content/browser/cert_store.h" +#include "grit/browser_resources.h" +#include "grit/generated_resources.h" +#include "net/base/x509_certificate.h" +#include "ui/base/l10n/l10n_util.h" + +CertificateViewerUI::CertificateViewerUI(TabContents* contents) + : ChromeWebUI(contents) { + + // Set up the chrome://view-cert source. + ChromeWebUIDataSource* html_source = + new ChromeWebUIDataSource(chrome::kChromeUICertificateViewerHost); + + // Register callback handler to retrieve certificate information. + RegisterMessageCallback("requestCertificateInfo", + NewCallback(this, &CertificateViewerUI::RequestCertificateInfo)); + + // Localized strings. + html_source->AddLocalizedString("close", IDS_CLOSE); + html_source->AddLocalizedString("usages", + IDS_CERT_INFO_VERIFIED_USAGES_GROUP); + html_source->AddLocalizedString("issuedto", IDS_CERT_INFO_SUBJECT_GROUP); + html_source->AddLocalizedString("issuedby", IDS_CERT_INFO_ISSUER_GROUP); + html_source->AddLocalizedString("cn", IDS_CERT_INFO_COMMON_NAME_LABEL); + html_source->AddLocalizedString("o", IDS_CERT_INFO_ORGANIZATION_LABEL); + html_source->AddLocalizedString("ou", + IDS_CERT_INFO_ORGANIZATIONAL_UNIT_LABEL); + html_source->AddLocalizedString("sn", IDS_CERT_INFO_SERIAL_NUMBER_LABEL); + html_source->AddLocalizedString("validity", IDS_CERT_INFO_VALIDITY_GROUP); + html_source->AddLocalizedString("issuedon", IDS_CERT_INFO_ISSUED_ON_LABEL); + html_source->AddLocalizedString("expireson", IDS_CERT_INFO_EXPIRES_ON_LABEL); + html_source->AddLocalizedString("fingerprints", + IDS_CERT_INFO_FINGERPRINTS_GROUP); + html_source->AddLocalizedString("sha256", + IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL); + html_source->AddLocalizedString("sha1", IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL); + html_source->set_json_path("strings.js"); + + // Add required resources. + html_source->add_resource_path("certificate_viewer.js", + IDR_CERTIFICATE_VIEWER_JS); + html_source->add_resource_path("certificate_viewer.css", + IDR_CERTIFICATE_VIEWER_CSS); + html_source->set_default_resource(IDR_CERTIFICATE_VIEWER_HTML); + + contents->profile()->GetChromeURLDataManager()->AddDataSource( + html_source); +} + +CertificateViewerUI::~CertificateViewerUI() { +} + +// TODO(flackr): This is duplicated from cookies_view_handler.cc +// Decodes a pointer from a hex string. +void* HexStringToPointer(const std::string& str) { + std::vector<uint8> buffer; + if (!base::HexStringToBytes(str, &buffer) || + buffer.size() != sizeof(void*)) { + return NULL; + } + + return *reinterpret_cast<void**>(&buffer[0]); +} + +// Returns the certificate information of the requested certificate id from +// the CertStore to the javascript handler. +void CertificateViewerUI::RequestCertificateInfo(const ListValue* args) { + // The certificate id should be in the first argument. + std::string val; + if (!(args->GetString(0, &val))) { + return; + } + net::X509Certificate* cert = static_cast<net::X509Certificate*>( + HexStringToPointer(val)); + + // Certificate information. The keys in this dictionary correspond to the IDs + // in the Html page. + DictionaryValue cert_info; + net::X509Certificate::OSCertHandle cert_hnd = cert->os_cert_handle(); + + // Get the certificate chain. + net::X509Certificate::OSCertHandles cert_chain; + x509_certificate_model::GetCertChainFromCert(cert_hnd, &cert_chain); + + // Certificate usage. + std::vector<std::string> usages; + x509_certificate_model::GetUsageStrings(cert_hnd, &usages); + std::string usagestr; + for (std::vector<std::string>::iterator it = usages.begin(); + it != usages.end(); ++it) { + if (usagestr.length() > 0) { + usagestr += "\n"; + } + usagestr += *it; + } + cert_info.SetString("usages", usagestr); + + // Standard certificate details. + const std::string alternative_text = + l10n_util::GetStringUTF8(IDS_CERT_INFO_FIELD_NOT_PRESENT); + cert_info.SetString("title", l10n_util::GetStringFUTF8( + IDS_CERT_INFO_DIALOG_TITLE, UTF8ToUTF16(x509_certificate_model::GetTitle( + cert_chain.front())))); + + // Issued to information. + cert_info.SetString("issued-cn", x509_certificate_model::GetSubjectCommonName( + cert_hnd, alternative_text)); + cert_info.SetString("issued-o", x509_certificate_model::GetSubjectOrgName( + cert_hnd, alternative_text)); + cert_info.SetString("issued-ou", x509_certificate_model::GetSubjectOrgUnitName + (cert_hnd, alternative_text)); + cert_info.SetString("issued-sn", + x509_certificate_model::GetSerialNumberHexified( + cert_hnd, alternative_text)); + + // Issuer information. + cert_info.SetString("issuer-cn", x509_certificate_model::GetIssuerCommonName( + cert_hnd, alternative_text)); + cert_info.SetString("issuer-o", x509_certificate_model::GetIssuerOrgName( + cert_hnd, alternative_text)); + cert_info.SetString("issuer-ou", x509_certificate_model::GetIssuerOrgUnitName + (cert_hnd, alternative_text)); + + // Validity period. + base::Time issued, expires; + std::string issued_str, expires_str; + if (x509_certificate_model::GetTimes(cert_hnd, &issued, &expires)) { + issued_str = UTF16ToUTF8( + base::TimeFormatShortDateNumeric(issued)); + expires_str = UTF16ToUTF8( + base::TimeFormatShortDateNumeric(expires)); + } else { + issued_str = alternative_text; + expires_str = alternative_text; + } + cert_info.SetString("issuedate", issued_str); + cert_info.SetString("expirydate", expires_str); + + cert_info.SetString("sha256", + x509_certificate_model::HashCertSHA256(cert_hnd)); + cert_info.SetString("sha1", + x509_certificate_model::HashCertSHA1(cert_hnd)); + + // Send certificate information to javascript. + CallJavascriptFunction("cert_viewer.getCertificateInfo", cert_info); +} + diff --git a/chrome/browser/ui/webui/certificate_viewer_ui.h b/chrome/browser/ui/webui/certificate_viewer_ui.h new file mode 100644 index 0000000..4169381 --- /dev/null +++ b/chrome/browser/ui/webui/certificate_viewer_ui.h @@ -0,0 +1,29 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_UI_H_ +#define CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_UI_H_ +#pragma once + +#include "base/values.h" +#include "chrome/browser/ui/webui/chrome_web_ui.h" + +// The WebUI for chrome://view-cert +class CertificateViewerUI : public ChromeWebUI { + public: + explicit CertificateViewerUI(TabContents* contents); + virtual ~CertificateViewerUI(); + + protected: + // Extracts the certificate details and returns them to the javascript + // function getCertificateInfo in a dictionary structure. + // + // The input is an X509Certificate pointer in hex encoded format in the first + // argument of the args list. + void RequestCertificateInfo(const ListValue* args); + + DISALLOW_COPY_AND_ASSIGN(CertificateViewerUI); +}; + +#endif // CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_UI_H_ diff --git a/chrome/browser/ui/webui/chrome_web_ui_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_factory.cc index 4539ef8..a8066b7 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_factory.cc @@ -69,6 +69,10 @@ #include "chrome/browser/ui/webui/conflicts_ui.h" #endif +#if defined(WEBUI_CERTIFICATE_VIEWER) +#include "chrome/browser/ui/webui/certificate_viewer_ui.h" +#endif + namespace { // A function for creating a new WebUI. The caller owns the return value, which @@ -142,6 +146,10 @@ static WebUIFactoryFunction GetWebUIFactoryFunction(Profile* profile, return &NewWebUI<BookmarksUI>; if (url.host() == chrome::kChromeUIBugReportHost) return &NewWebUI<BugReportUI>; +#if defined(WEBUI_CERTIFICATE_VIEWER) + if (url.host() == chrome::kChromeUICertificateViewerHost) + return &NewWebUI<CertificateViewerUI>; +#endif if (url.host() == chrome::kChromeUICrashesHost) return &NewWebUI<CrashesUI>; if (url.host() == chrome::kChromeUIDevToolsHost) diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 08ce0b5..76b99f0 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -3359,6 +3359,10 @@ 'browser/ui/webui/bookmarks_ui.h', 'browser/ui/webui/bug_report_ui.cc', 'browser/ui/webui/bug_report_ui.h', + 'browser/ui/webui/certificate_viewer.cc', + 'browser/ui/webui/certificate_viewer.h', + 'browser/ui/webui/certificate_viewer_ui.cc', + 'browser/ui/webui/certificate_viewer_ui.h', 'browser/ui/webui/chrome_url_data_manager_backend.cc', 'browser/ui/webui/chrome_url_data_manager_backend.h', 'browser/ui/webui/chrome_url_data_manager.cc', @@ -3827,6 +3831,23 @@ '../third_party/angle/include', ], }], + ['webui_certificate_viewer==0', { + 'sources/': [ + ['exclude', '^browser/ui/webui/certificate_viewer.cc'], + ['exclude', '^browser/ui/webui/certificate_viewer.h'], + ['exclude', '^browser/ui/webui/certificate_viewer_ui.cc'], + ['exclude', '^browser/ui/webui/certificate_viewer_ui.h'], + ], + }], + ['webui_certificate_viewer==1', { + 'sources/': [ + ['exclude', '^browser/ui/gtk/certificate_viewer.cc'], + ['exclude', '^browser/ui/gtk/certificate_viewer.h'], + ], + 'defines': [ + 'WEBUI_CERTIFICATE_VIEWER', + ], + }], ['toolkit_uses_gtk == 1', { 'dependencies': [ '../build/linux/system.gyp:dbus-glib', @@ -4466,6 +4487,14 @@ ['exclude', '^browser/ui/panels/panel_browser_window_gtk.h'], ], }], + # Exclude the GTK cert viewer again if webui_certificate_viewer is + # enabled. + ['webui_certificate_viewer==1', { + 'sources/': [ + ['exclude', '^browser/ui/gtk/certificate_viewer.cc'], + ['exclude', '^browser/ui/gtk/certificate_viewer.h'], + ], + }], # Exclude these toolkit_views specific files again. # (Required because of the '^browser/extensions/' include above) ['toolkit_views==0', { diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index 04e4aba..f25c541 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -29,6 +29,7 @@ const char kAboutVersionURL[] = "about:version"; const char kChromeUIAboutURL[] = "chrome://about/"; const char kChromeUIBookmarksURL[] = "chrome://bookmarks/"; const char kChromeUIBugReportURL[] = "chrome://bugreport/"; +const char kChromeUICertificateViewerURL[] = "chrome://view-cert/"; const char kChromeUIChromeURLsURL[] = "chrome://chrome-urls/"; const char kChromeUICloudPrintResourcesURL[] = "chrome://cloudprintresources/"; const char kChromeUIConflictsURL[] = "chrome://conflicts/"; @@ -98,6 +99,7 @@ const char kChromeUIBookmarksHost[] = "bookmarks"; const char kChromeUIBrowserCrashHost[] = "inducebrowsercrashforrealz"; const char kChromeUIBugReportHost[] = "bugreport"; const char kChromeUICacheHost[] = "cache"; +const char kChromeUICertificateViewerHost[] = "view-cert"; const char kChromeUIChromeURLsHost[] = "chrome-urls"; const char kChromeUICloudPrintResourcesHost[] = "cloudprintresources"; const char kChromeUICloudPrintSetupHost[] = "cloudprintsetup"; diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index b19edbc..c9bfc49 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -25,6 +25,7 @@ extern const char kAboutVersionURL[]; extern const char kChromeUIAboutURL[]; extern const char kChromeUIBookmarksURL[]; extern const char kChromeUIBugReportURL[]; +extern const char kChromeUICertificateViewerURL[]; extern const char kChromeUIChromeURLsURL[]; extern const char kChromeUICloudPrintResourcesURL[]; extern const char kChromeUIConflictsURL[]; @@ -92,6 +93,7 @@ extern const char kChromeUIBookmarksHost[]; extern const char kChromeUIBrowserCrashHost[]; extern const char kChromeUIBugReportHost[]; extern const char kChromeUICacheHost[]; +extern const char kChromeUICertificateViewerHost[]; extern const char kChromeUIChromeURLsHost[]; extern const char kChromeUICloudPrintResourcesHost[]; extern const char kChromeUICloudPrintSetupHost[]; |