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 #include "chrome/browser/page_info_model.h" | 5 #include "chrome/browser/page_info_model.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // warnings instead. | 61 // warnings instead. |
62 static const int cert_warnings = | 62 static const int cert_warnings = |
63 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION | | 63 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION | |
64 net::CERT_STATUS_NO_REVOCATION_MECHANISM; | 64 net::CERT_STATUS_NO_REVOCATION_MECHANISM; |
65 int status_with_warnings_removed = ssl.cert_status() & ~cert_warnings; | 65 int status_with_warnings_removed = ssl.cert_status() & ~cert_warnings; |
66 | 66 |
67 if (ssl.cert_id() && | 67 if (ssl.cert_id() && |
68 CertStore::GetInstance()->RetrieveCert(ssl.cert_id(), &cert) && | 68 CertStore::GetInstance()->RetrieveCert(ssl.cert_id(), &cert) && |
69 !net::IsCertStatusError(status_with_warnings_removed)) { | 69 !net::IsCertStatusError(status_with_warnings_removed)) { |
70 // No error found so far, check cert_status warnings. | 70 // No error found so far, check cert_status warnings. |
71 int cert_status = ssl.cert_status(); | 71 net::CertStatus cert_status = ssl.cert_status(); |
72 if (cert_status & cert_warnings) { | 72 if (cert_status & cert_warnings) { |
73 string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName())); | 73 string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName())); |
74 if (issuer_name.empty()) { | 74 if (issuer_name.empty()) { |
75 issuer_name.assign(l10n_util::GetStringUTF16( | 75 issuer_name.assign(l10n_util::GetStringUTF16( |
76 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); | 76 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
77 } | 77 } |
78 description.assign(l10n_util::GetStringFUTF16( | 78 description.assign(l10n_util::GetStringFUTF16( |
79 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name)); | 79 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name)); |
80 | 80 |
81 description += ASCIIToUTF16("\n\n"); | 81 description += ASCIIToUTF16("\n\n"); |
82 if (cert_status & net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) { | 82 if (cert_status & net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) { |
83 description += l10n_util::GetStringUTF16( | 83 description += l10n_util::GetStringUTF16( |
84 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION); | 84 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION); |
85 } else if (cert_status & net::CERT_STATUS_NO_REVOCATION_MECHANISM) { | 85 } else if (cert_status & net::CERT_STATUS_NO_REVOCATION_MECHANISM) { |
86 description += l10n_util::GetStringUTF16( | 86 description += l10n_util::GetStringUTF16( |
87 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM); | 87 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM); |
88 } else { | 88 } else { |
89 NOTREACHED() << "Need to specify string for this warning"; | 89 NOTREACHED() << "Need to specify string for this warning"; |
90 } | 90 } |
91 icon_id = ICON_STATE_WARNING_MINOR; | 91 icon_id = ICON_STATE_WARNING_MINOR; |
92 } else if ((ssl.cert_status() & net::CERT_STATUS_IS_EV) != 0) { | 92 } else if (ssl.cert_status() & net::CERT_STATUS_IS_EV) { |
93 // EV HTTPS page. | 93 // EV HTTPS page. |
94 DCHECK(!cert->subject().organization_names.empty()); | 94 DCHECK(!cert->subject().organization_names.empty()); |
95 headline = | 95 headline = |
96 l10n_util::GetStringFUTF16(IDS_PAGE_INFO_EV_IDENTITY_TITLE, | 96 l10n_util::GetStringFUTF16(IDS_PAGE_INFO_EV_IDENTITY_TITLE, |
97 UTF8ToUTF16(cert->subject().organization_names[0]), | 97 UTF8ToUTF16(cert->subject().organization_names[0]), |
98 UTF8ToUTF16(url.host())); | 98 UTF8ToUTF16(url.host())); |
99 // An EV Cert is required to have a city (localityName) and country but | 99 // An EV Cert is required to have a city (localityName) and country but |
100 // state is "if any". | 100 // state is "if any". |
101 DCHECK(!cert->subject().locality_name.empty()); | 101 DCHECK(!cert->subject().locality_name.empty()); |
102 DCHECK(!cert->subject().country_name.empty()); | 102 DCHECK(!cert->subject().country_name.empty()); |
103 string16 locality; | 103 string16 locality; |
104 if (!cert->subject().state_or_province_name.empty()) { | 104 if (!cert->subject().state_or_province_name.empty()) { |
105 locality = l10n_util::GetStringFUTF16( | 105 locality = l10n_util::GetStringFUTF16( |
106 IDS_PAGEINFO_ADDRESS, | 106 IDS_PAGEINFO_ADDRESS, |
107 UTF8ToUTF16(cert->subject().locality_name), | 107 UTF8ToUTF16(cert->subject().locality_name), |
108 UTF8ToUTF16(cert->subject().state_or_province_name), | 108 UTF8ToUTF16(cert->subject().state_or_province_name), |
109 UTF8ToUTF16(cert->subject().country_name)); | 109 UTF8ToUTF16(cert->subject().country_name)); |
110 } else { | 110 } else { |
111 locality = l10n_util::GetStringFUTF16( | 111 locality = l10n_util::GetStringFUTF16( |
112 IDS_PAGEINFO_PARTIAL_ADDRESS, | 112 IDS_PAGEINFO_PARTIAL_ADDRESS, |
113 UTF8ToUTF16(cert->subject().locality_name), | 113 UTF8ToUTF16(cert->subject().locality_name), |
114 UTF8ToUTF16(cert->subject().country_name)); | 114 UTF8ToUTF16(cert->subject().country_name)); |
115 } | 115 } |
116 DCHECK(!cert->subject().organization_names.empty()); | 116 DCHECK(!cert->subject().organization_names.empty()); |
117 description.assign(l10n_util::GetStringFUTF16( | 117 description.assign(l10n_util::GetStringFUTF16( |
118 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV, | 118 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV, |
119 UTF8ToUTF16(cert->subject().organization_names[0]), | 119 UTF8ToUTF16(cert->subject().organization_names[0]), |
120 locality, | 120 locality, |
121 UTF8ToUTF16(cert->issuer().GetDisplayName()))); | 121 UTF8ToUTF16(cert->issuer().GetDisplayName()))); |
122 } else if ((ssl.cert_status() & net::CERT_STATUS_IS_DNSSEC) != 0) { | 122 } else if (ssl.cert_status() & net::CERT_STATUS_IS_DNSSEC) { |
123 // DNSSEC authenticated page. | 123 // DNSSEC authenticated page. |
124 if (empty_subject_name) | 124 if (empty_subject_name) |
125 headline.clear(); // Don't display any title. | 125 headline.clear(); // Don't display any title. |
126 else | 126 else |
127 headline.assign(subject_name); | 127 headline.assign(subject_name); |
128 description.assign(l10n_util::GetStringFUTF16( | 128 description.assign(l10n_util::GetStringFUTF16( |
129 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, UTF8ToUTF16("DNSSEC"))); | 129 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, UTF8ToUTF16("DNSSEC"))); |
130 } else { | 130 } else { |
131 // Non-EV OK HTTPS page. | 131 // Non-EV OK HTTPS page. |
132 if (empty_subject_name) | 132 if (empty_subject_name) |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 // Loads the icons into the vector. The order must match the SectionStateIcon | 351 // Loads the icons into the vector. The order must match the SectionStateIcon |
352 // enum. | 352 // enum. |
353 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 353 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
354 icons_.push_back(&rb.GetNativeImageNamed(IDR_PAGEINFO_GOOD)); | 354 icons_.push_back(&rb.GetNativeImageNamed(IDR_PAGEINFO_GOOD)); |
355 icons_.push_back(&rb.GetNativeImageNamed(IDR_PAGEINFO_WARNING_MINOR)); | 355 icons_.push_back(&rb.GetNativeImageNamed(IDR_PAGEINFO_WARNING_MINOR)); |
356 icons_.push_back(&rb.GetNativeImageNamed(IDR_PAGEINFO_WARNING_MAJOR)); | 356 icons_.push_back(&rb.GetNativeImageNamed(IDR_PAGEINFO_WARNING_MAJOR)); |
357 icons_.push_back(&rb.GetNativeImageNamed(IDR_PAGEINFO_BAD)); | 357 icons_.push_back(&rb.GetNativeImageNamed(IDR_PAGEINFO_BAD)); |
358 icons_.push_back(&rb.GetNativeImageNamed(IDR_PAGEINFO_INFO)); | 358 icons_.push_back(&rb.GetNativeImageNamed(IDR_PAGEINFO_INFO)); |
359 icons_.push_back(&rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_26)); | 359 icons_.push_back(&rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_26)); |
360 } | 360 } |
OLD | NEW |