Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / webui / certificate_viewer_ui.cc
blobae4fb3b9402a7e2cdedfdd13c89e07296327bac1
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/certificate_viewer_ui.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/webui/certificate_viewer_webui.h"
9 #include "chrome/common/url_constants.h"
10 #include "chrome/grit/generated_resources.h"
11 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/web_contents.h"
13 #include "content/public/browser/web_ui.h"
14 #include "content/public/browser/web_ui_data_source.h"
15 #include "grit/browser_resources.h"
16 #include "ui/web_dialogs/web_dialog_delegate.h"
18 namespace {
20 content::WebUIDataSource* GetWebUIDataSource(const std::string& host) {
21 content::WebUIDataSource* html_source =
22 content::WebUIDataSource::Create(host);
24 // Localized strings.
25 html_source->AddLocalizedString("general", IDS_CERT_INFO_GENERAL_TAB_LABEL);
26 html_source->AddLocalizedString("details", IDS_CERT_INFO_DETAILS_TAB_LABEL);
27 html_source->AddLocalizedString("close", IDS_CLOSE);
28 html_source->AddLocalizedString("export",
29 IDS_CERT_DETAILS_EXPORT_CERTIFICATE);
30 html_source->AddLocalizedString("usages",
31 IDS_CERT_INFO_VERIFIED_USAGES_GROUP);
32 html_source->AddLocalizedString("issuedTo", IDS_CERT_INFO_SUBJECT_GROUP);
33 html_source->AddLocalizedString("issuedBy", IDS_CERT_INFO_ISSUER_GROUP);
34 html_source->AddLocalizedString("cn", IDS_CERT_INFO_COMMON_NAME_LABEL);
35 html_source->AddLocalizedString("o", IDS_CERT_INFO_ORGANIZATION_LABEL);
36 html_source->AddLocalizedString("ou",
37 IDS_CERT_INFO_ORGANIZATIONAL_UNIT_LABEL);
38 html_source->AddLocalizedString("sn", IDS_CERT_INFO_SERIAL_NUMBER_LABEL);
39 html_source->AddLocalizedString("validity", IDS_CERT_INFO_VALIDITY_GROUP);
40 html_source->AddLocalizedString("issuedOn", IDS_CERT_INFO_ISSUED_ON_LABEL);
41 html_source->AddLocalizedString("expiresOn", IDS_CERT_INFO_EXPIRES_ON_LABEL);
42 html_source->AddLocalizedString("fingerprints",
43 IDS_CERT_INFO_FINGERPRINTS_GROUP);
44 html_source->AddLocalizedString("sha256",
45 IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL);
46 html_source->AddLocalizedString("sha1", IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL);
47 html_source->AddLocalizedString("hierarchy",
48 IDS_CERT_DETAILS_CERTIFICATE_HIERARCHY_LABEL);
49 html_source->AddLocalizedString("certFields",
50 IDS_CERT_DETAILS_CERTIFICATE_FIELDS_LABEL);
51 html_source->AddLocalizedString("certFieldVal",
52 IDS_CERT_DETAILS_CERTIFICATE_FIELD_VALUE_LABEL);
53 html_source->SetJsonPath("strings.js");
55 // Add required resources.
56 html_source->AddResourcePath("certificate_viewer.js",
57 IDR_CERTIFICATE_VIEWER_JS);
58 html_source->AddResourcePath("certificate_viewer.css",
59 IDR_CERTIFICATE_VIEWER_CSS);
60 html_source->SetDefaultResource(IDR_CERTIFICATE_VIEWER_HTML);
61 return html_source;
64 } // namespace
66 CertificateViewerModalDialogUI::CertificateViewerModalDialogUI(
67 content::WebUI* web_ui)
68 : ui::WebDialogUI(web_ui) {
69 // Set up the chrome://view-cert-dialog source.
70 Profile* profile = Profile::FromWebUI(web_ui);
71 content::WebUIDataSource::Add(
72 profile,
73 GetWebUIDataSource(chrome::kChromeUICertificateViewerDialogHost));
76 CertificateViewerModalDialogUI::~CertificateViewerModalDialogUI() {
79 CertificateViewerUI::CertificateViewerUI(content::WebUI* web_ui)
80 : ConstrainedWebDialogUI(web_ui) {
81 // Set up the chrome://view-cert source.
82 Profile* profile = Profile::FromWebUI(web_ui);
83 content::WebUIDataSource::Add(
84 profile,
85 GetWebUIDataSource(chrome::kChromeUICertificateViewerHost));
88 CertificateViewerUI::~CertificateViewerUI() {