Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: chrome/browser/page_info_model.cc

Issue 3171031: Add mixed content warning to the Page Info bubble.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/page_info_model.h ('k') | chrome/browser/views/page_info_bubble_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 10 matching lines...) Expand all
21 #include "net/base/ssl_connection_status_flags.h" 21 #include "net/base/ssl_connection_status_flags.h"
22 #include "net/base/ssl_cipher_suite_names.h" 22 #include "net/base/ssl_cipher_suite_names.h"
23 #include "net/base/x509_certificate.h" 23 #include "net/base/x509_certificate.h"
24 24
25 PageInfoModel::PageInfoModel(Profile* profile, 25 PageInfoModel::PageInfoModel(Profile* profile,
26 const GURL& url, 26 const GURL& url,
27 const NavigationEntry::SSLStatus& ssl, 27 const NavigationEntry::SSLStatus& ssl,
28 bool show_history, 28 bool show_history,
29 PageInfoModelObserver* observer) 29 PageInfoModelObserver* observer)
30 : observer_(observer) { 30 : observer_(observer) {
31 bool state = true; 31 SectionInfoState state = SECTION_STATE_OK;
32 string16 head_line; 32 string16 headline;
33 string16 description; 33 string16 description;
34 scoped_refptr<net::X509Certificate> cert; 34 scoped_refptr<net::X509Certificate> cert;
35 35
36 // Identity section. 36 // Identity section.
37 string16 subject_name(UTF8ToUTF16(url.host())); 37 string16 subject_name(UTF8ToUTF16(url.host()));
38 bool empty_subject_name = false; 38 bool empty_subject_name = false;
39 if (subject_name.empty()) { 39 if (subject_name.empty()) {
40 subject_name.assign( 40 subject_name.assign(
41 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); 41 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
42 empty_subject_name = true; 42 empty_subject_name = true;
43 } 43 }
44 if (ssl.cert_id() && 44 if (ssl.cert_id() &&
45 CertStore::GetSharedInstance()->RetrieveCert(ssl.cert_id(), &cert) && 45 CertStore::GetSharedInstance()->RetrieveCert(ssl.cert_id(), &cert) &&
46 !net::IsCertStatusError(ssl.cert_status())) { 46 !net::IsCertStatusError(ssl.cert_status())) {
47 // OK HTTPS page. 47 // OK HTTPS page.
48 if ((ssl.cert_status() & net::CERT_STATUS_IS_EV) != 0) { 48 if ((ssl.cert_status() & net::CERT_STATUS_IS_EV) != 0) {
49 DCHECK(!cert->subject().organization_names.empty()); 49 DCHECK(!cert->subject().organization_names.empty());
50 head_line = 50 headline =
51 l10n_util::GetStringFUTF16(IDS_PAGE_INFO_EV_IDENTITY_TITLE, 51 l10n_util::GetStringFUTF16(IDS_PAGE_INFO_EV_IDENTITY_TITLE,
52 UTF8ToUTF16(cert->subject().organization_names[0]), 52 UTF8ToUTF16(cert->subject().organization_names[0]),
53 UTF8ToUTF16(url.host())); 53 UTF8ToUTF16(url.host()));
54 // An EV Cert is required to have a city (localityName) and country but 54 // An EV Cert is required to have a city (localityName) and country but
55 // state is "if any". 55 // state is "if any".
56 DCHECK(!cert->subject().locality_name.empty()); 56 DCHECK(!cert->subject().locality_name.empty());
57 DCHECK(!cert->subject().country_name.empty()); 57 DCHECK(!cert->subject().country_name.empty());
58 string16 locality; 58 string16 locality;
59 if (!cert->subject().state_or_province_name.empty()) { 59 if (!cert->subject().state_or_province_name.empty()) {
60 locality = l10n_util::GetStringFUTF16( 60 locality = l10n_util::GetStringFUTF16(
61 IDS_PAGEINFO_ADDRESS, 61 IDS_PAGEINFO_ADDRESS,
62 UTF8ToUTF16(cert->subject().locality_name), 62 UTF8ToUTF16(cert->subject().locality_name),
63 UTF8ToUTF16(cert->subject().state_or_province_name), 63 UTF8ToUTF16(cert->subject().state_or_province_name),
64 UTF8ToUTF16(cert->subject().country_name)); 64 UTF8ToUTF16(cert->subject().country_name));
65 } else { 65 } else {
66 locality = l10n_util::GetStringFUTF16( 66 locality = l10n_util::GetStringFUTF16(
67 IDS_PAGEINFO_PARTIAL_ADDRESS, 67 IDS_PAGEINFO_PARTIAL_ADDRESS,
68 UTF8ToUTF16(cert->subject().locality_name), 68 UTF8ToUTF16(cert->subject().locality_name),
69 UTF8ToUTF16(cert->subject().country_name)); 69 UTF8ToUTF16(cert->subject().country_name));
70 } 70 }
71 DCHECK(!cert->subject().organization_names.empty()); 71 DCHECK(!cert->subject().organization_names.empty());
72 description.assign(l10n_util::GetStringFUTF16( 72 description.assign(l10n_util::GetStringFUTF16(
73 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV, 73 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV,
74 UTF8ToUTF16(cert->subject().organization_names[0]), 74 UTF8ToUTF16(cert->subject().organization_names[0]),
75 locality, 75 locality,
76 UTF8ToUTF16(cert->issuer().GetDisplayName()))); 76 UTF8ToUTF16(cert->issuer().GetDisplayName())));
77 } else { 77 } else {
78 // Non EV OK HTTPS. 78 // Non EV OK HTTPS.
79 if (empty_subject_name) 79 if (empty_subject_name)
80 head_line.clear(); // Don't display any title. 80 headline.clear(); // Don't display any title.
81 else 81 else
82 head_line.assign(subject_name); 82 headline.assign(subject_name);
83 string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName())); 83 string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName()));
84 if (issuer_name.empty()) { 84 if (issuer_name.empty()) {
85 issuer_name.assign(l10n_util::GetStringUTF16( 85 issuer_name.assign(l10n_util::GetStringUTF16(
86 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); 86 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
87 } else { 87 } else {
88 description.assign(l10n_util::GetStringFUTF16( 88 description.assign(l10n_util::GetStringFUTF16(
89 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name)); 89 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name));
90 } 90 }
91 } 91 }
92 } else { 92 } else {
93 // HTTP or bad HTTPS. 93 // HTTP or bad HTTPS.
94 description.assign(l10n_util::GetStringUTF16( 94 description.assign(l10n_util::GetStringUTF16(
95 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY)); 95 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
96 state = false; 96 state = SECTION_STATE_ERROR;
97 } 97 }
98 sections_.push_back(SectionInfo( 98 sections_.push_back(SectionInfo(
99 state, 99 state,
100 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE), 100 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE),
101 head_line, 101 headline,
102 description, 102 description,
103 SECTION_INFO_IDENTITY)); 103 SECTION_INFO_IDENTITY));
104 104
105 // Connection section. 105 // Connection section.
106 // We consider anything less than 80 bits encryption to be weak encryption. 106 // We consider anything less than 80 bits encryption to be weak encryption.
107 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and 107 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
108 // weakly encrypted connections. 108 // weakly encrypted connections.
109 state = true; 109 state = SECTION_STATE_OK;
110 head_line.clear(); 110 headline.clear();
111 description.clear(); 111 description.clear();
112 if (ssl.security_bits() <= 0) { 112 if (ssl.security_bits() <= 0) {
113 state = false; 113 state = SECTION_STATE_ERROR;
114 description.assign(l10n_util::GetStringFUTF16( 114 description.assign(l10n_util::GetStringFUTF16(
115 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, 115 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
116 subject_name)); 116 subject_name));
117 } else if (ssl.security_bits() < 80) { 117 } else if (ssl.security_bits() < 80) {
118 state = false; 118 state = SECTION_STATE_ERROR;
119 description.assign(l10n_util::GetStringFUTF16( 119 description.assign(l10n_util::GetStringFUTF16(
120 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT, 120 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
121 subject_name)); 121 subject_name));
122 } else { 122 } else {
123 description.assign(l10n_util::GetStringFUTF16( 123 description.assign(l10n_util::GetStringFUTF16(
124 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, 124 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
125 subject_name, 125 subject_name,
126 base::IntToString16(ssl.security_bits()))); 126 base::IntToString16(ssl.security_bits())));
127 if (ssl.displayed_insecure_content() || ssl.ran_insecure_content()) { 127 if (ssl.displayed_insecure_content() || ssl.ran_insecure_content()) {
128 state = false; 128 state = SECTION_STATE_ERROR;
129 description.assign(l10n_util::GetStringFUTF16( 129 description.assign(l10n_util::GetStringFUTF16(
130 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, 130 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
131 description, 131 description,
132 l10n_util::GetStringUTF16(ssl.ran_insecure_content() ? 132 l10n_util::GetStringUTF16(ssl.ran_insecure_content() ?
133 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR : 133 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR :
134 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING))); 134 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
135 } 135 }
136 } 136 }
137 137
138 if (state == SECTION_STATE_OK && ssl.displayed_insecure_content()) {
139 state = SECTION_STATE_WARNING; // Mixed content warrants a warning.
140 headline.clear();
141 description.assign(l10n_util::GetStringUTF16(
142 IDS_PAGE_INFO_SECURITY_MIXED_CONTENT));
143 }
144
138 uint16 cipher_suite = 145 uint16 cipher_suite =
139 net::SSLConnectionStatusToCipherSuite(ssl.connection_status()); 146 net::SSLConnectionStatusToCipherSuite(ssl.connection_status());
140 if (ssl.security_bits() > 0 && cipher_suite) { 147 if (ssl.security_bits() > 0 && cipher_suite) {
141 bool did_fallback = (ssl.connection_status() & 148 bool did_fallback = (ssl.connection_status() &
142 net::SSL_CONNECTION_SSL3_FALLBACK) != 0; 149 net::SSL_CONNECTION_SSL3_FALLBACK) != 0;
143 bool no_renegotiation = 150 bool no_renegotiation =
144 (ssl.connection_status() & 151 (ssl.connection_status() &
145 net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0; 152 net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0;
146 const char *key_exchange, *cipher, *mac; 153 const char *key_exchange, *cipher, *mac;
147 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, cipher_suite); 154 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, cipher_suite);
(...skipping 12 matching lines...) Expand all
160 description += l10n_util::GetStringFUTF16( 167 description += l10n_util::GetStringFUTF16(
161 IDS_PAGE_INFO_SECURITY_TAB_COMPRESSION_DETAILS, 168 IDS_PAGE_INFO_SECURITY_TAB_COMPRESSION_DETAILS,
162 ASCIIToUTF16(compression)); 169 ASCIIToUTF16(compression));
163 } else { 170 } else {
164 description += l10n_util::GetStringUTF16( 171 description += l10n_util::GetStringUTF16(
165 IDS_PAGE_INFO_SECURITY_TAB_NO_COMPRESSION); 172 IDS_PAGE_INFO_SECURITY_TAB_NO_COMPRESSION);
166 } 173 }
167 174
168 if (did_fallback) { 175 if (did_fallback) {
169 // For now, only SSLv3 fallback will trigger a warning icon. 176 // For now, only SSLv3 fallback will trigger a warning icon.
170 state = false; 177 state = SECTION_STATE_ERROR;
171 description += ASCIIToUTF16("\n\n"); 178 description += ASCIIToUTF16("\n\n");
172 description += l10n_util::GetStringUTF16( 179 description += l10n_util::GetStringUTF16(
173 IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE); 180 IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE);
174 } 181 }
175 if (no_renegotiation) { 182 if (no_renegotiation) {
176 description += ASCIIToUTF16("\n\n"); 183 description += ASCIIToUTF16("\n\n");
177 description += l10n_util::GetStringUTF16( 184 description += l10n_util::GetStringUTF16(
178 IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE); 185 IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE);
179 } 186 }
180 } 187 }
181 188
182 sections_.push_back(SectionInfo( 189 sections_.push_back(SectionInfo(
183 state, 190 state,
184 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_CONNECTION_TITLE), 191 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_CONNECTION_TITLE),
185 head_line, 192 headline,
186 description, 193 description,
187 SECTION_INFO_CONNECTION)); 194 SECTION_INFO_CONNECTION));
188 195
189 // Request the number of visits. 196 // Request the number of visits.
190 HistoryService* history = profile->GetHistoryService( 197 HistoryService* history = profile->GetHistoryService(
191 Profile::EXPLICIT_ACCESS); 198 Profile::EXPLICIT_ACCESS);
192 if (show_history && history) { 199 if (show_history && history) {
193 history->GetVisitCountToHost( 200 history->GetVisitCountToHost(
194 url, 201 url,
195 &request_consumer_, 202 &request_consumer_,
(...skipping 21 matching lines...) Expand all
217 224
218 bool visited_before_today = false; 225 bool visited_before_today = false;
219 if (count) { 226 if (count) {
220 base::Time today = base::Time::Now().LocalMidnight(); 227 base::Time today = base::Time::Now().LocalMidnight();
221 base::Time first_visit_midnight = first_visit.LocalMidnight(); 228 base::Time first_visit_midnight = first_visit.LocalMidnight();
222 visited_before_today = (first_visit_midnight < today); 229 visited_before_today = (first_visit_midnight < today);
223 } 230 }
224 231
225 if (!visited_before_today) { 232 if (!visited_before_today) {
226 sections_.push_back(SectionInfo( 233 sections_.push_back(SectionInfo(
227 false, 234 SECTION_STATE_ERROR,
228 l10n_util::GetStringUTF16( 235 l10n_util::GetStringUTF16(
229 IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE), 236 IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE),
230 string16(), 237 string16(),
231 l10n_util::GetStringUTF16( 238 l10n_util::GetStringUTF16(
232 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY), 239 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY),
233 SECTION_INFO_FIRST_VISIT)); 240 SECTION_INFO_FIRST_VISIT));
234 } else { 241 } else {
235 sections_.push_back(SectionInfo( 242 sections_.push_back(SectionInfo(
236 true, 243 SECTION_STATE_OK,
237 l10n_util::GetStringUTF16( 244 l10n_util::GetStringUTF16(
238 IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE), 245 IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE),
239 string16(), 246 string16(),
240 l10n_util::GetStringFUTF16( 247 l10n_util::GetStringFUTF16(
241 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY, 248 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY,
242 WideToUTF16(base::TimeFormatShortDate(first_visit))), 249 WideToUTF16(base::TimeFormatShortDate(first_visit))),
243 SECTION_INFO_FIRST_VISIT)); 250 SECTION_INFO_FIRST_VISIT));
244 } 251 }
245 observer_->ModelChanged(); 252 observer_->ModelChanged();
246 } 253 }
247 254
248 // static 255 // static
249 void PageInfoModel::RegisterPrefs(PrefService* prefs) { 256 void PageInfoModel::RegisterPrefs(PrefService* prefs) {
250 prefs->RegisterDictionaryPref(prefs::kPageInfoWindowPlacement); 257 prefs->RegisterDictionaryPref(prefs::kPageInfoWindowPlacement);
251 } 258 }
OLDNEW
« no previous file with comments | « chrome/browser/page_info_model.h ('k') | chrome/browser/views/page_info_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698