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.
4
5#include "chrome/browser/ui/webui/certificate_viewer_ui.h"
6
7#include "chrome/browser/profiles/profile.h"
8#include "chrome/common/url_constants.h"
9#include "content/public/browser/web_contents.h"
10#include "content/public/browser/web_ui.h"
11#include "content/public/browser/web_ui_data_source.h"
12#include "grit/browser_resources.h"
13#include "grit/generated_resources.h"
14
15CertificateViewerUI::CertificateViewerUI(content::WebUI* web_ui)
16    : ConstrainedWebDialogUI(web_ui) {
17  // Set up the chrome://view-cert source.
18  content::WebUIDataSource* html_source =
19      content::WebUIDataSource::Create(chrome::kChromeUICertificateViewerHost);
20
21  // Localized strings.
22  html_source->SetUseJsonJSFormatV2();
23  html_source->AddLocalizedString("general", IDS_CERT_INFO_GENERAL_TAB_LABEL);
24  html_source->AddLocalizedString("details", IDS_CERT_INFO_DETAILS_TAB_LABEL);
25  html_source->AddLocalizedString("close", IDS_CLOSE);
26  html_source->AddLocalizedString("export",
27      IDS_CERT_DETAILS_EXPORT_CERTIFICATE);
28  html_source->AddLocalizedString("usages",
29      IDS_CERT_INFO_VERIFIED_USAGES_GROUP);
30  html_source->AddLocalizedString("issuedTo", IDS_CERT_INFO_SUBJECT_GROUP);
31  html_source->AddLocalizedString("issuedBy", IDS_CERT_INFO_ISSUER_GROUP);
32  html_source->AddLocalizedString("cn", IDS_CERT_INFO_COMMON_NAME_LABEL);
33  html_source->AddLocalizedString("o", IDS_CERT_INFO_ORGANIZATION_LABEL);
34  html_source->AddLocalizedString("ou",
35      IDS_CERT_INFO_ORGANIZATIONAL_UNIT_LABEL);
36  html_source->AddLocalizedString("sn", IDS_CERT_INFO_SERIAL_NUMBER_LABEL);
37  html_source->AddLocalizedString("validity", IDS_CERT_INFO_VALIDITY_GROUP);
38  html_source->AddLocalizedString("issuedOn", IDS_CERT_INFO_ISSUED_ON_LABEL);
39  html_source->AddLocalizedString("expiresOn", IDS_CERT_INFO_EXPIRES_ON_LABEL);
40  html_source->AddLocalizedString("fingerprints",
41      IDS_CERT_INFO_FINGERPRINTS_GROUP);
42  html_source->AddLocalizedString("sha256",
43      IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL);
44  html_source->AddLocalizedString("sha1", IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL);
45  html_source->AddLocalizedString("hierarchy",
46      IDS_CERT_DETAILS_CERTIFICATE_HIERARCHY_LABEL);
47  html_source->AddLocalizedString("certFields",
48      IDS_CERT_DETAILS_CERTIFICATE_FIELDS_LABEL);
49  html_source->AddLocalizedString("certFieldVal",
50      IDS_CERT_DETAILS_CERTIFICATE_FIELD_VALUE_LABEL);
51  html_source->SetJsonPath("strings.js");
52
53  // Add required resources.
54  html_source->AddResourcePath("certificate_viewer.js",
55      IDR_CERTIFICATE_VIEWER_JS);
56  html_source->AddResourcePath("certificate_viewer.css",
57      IDR_CERTIFICATE_VIEWER_CSS);
58  html_source->SetDefaultResource(IDR_CERTIFICATE_VIEWER_HTML);
59
60  Profile* profile = Profile::FromWebUI(web_ui);
61  content::WebUIDataSource::Add(profile, html_source);
62}
63
64CertificateViewerUI::~CertificateViewerUI() {
65}
66