blob: decf2948aeceecfc3ac684b0818effa592554d86 [file] [log] [blame]
[email protected]03ef4b2a2012-03-06 15:04:201// 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
[email protected]4237dd52012-06-05 00:00:325#include "chrome/browser/ui/website_settings/website_settings.h"
[email protected]03ef4b2a2012-03-06 15:04:206
7#include <string>
8#include <vector>
9
[email protected]15b092542012-05-16 13:08:1410#include "base/bind.h"
11#include "base/bind_helpers.h"
12#include "base/i18n/time_formatting.h"
[email protected]03ef4b2a2012-03-06 15:04:2013#include "base/string_number_conversions.h"
14#include "base/utf_string_conversions.h"
[email protected]0b9fdd72012-04-04 10:00:3315#include "base/values.h"
[email protected]b0cb5e82012-07-19 19:22:4716#include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
17#include "chrome/browser/browsing_data/browsing_data_database_helper.h"
18#include "chrome/browser/browsing_data/browsing_data_file_system_helper.h"
19#include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
20#include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
21#include "chrome/browser/browsing_data/browsing_data_server_bound_cert_helper.h"
[email protected]0b9fdd72012-04-04 10:00:3322#include "chrome/browser/content_settings/content_settings_utils.h"
23#include "chrome/browser/content_settings/host_content_settings_map.h"
[email protected]df818272012-04-20 13:10:5024#include "chrome/browser/content_settings/local_shared_objects_container.h"
[email protected]77a91c72012-08-13 16:19:3425#include "chrome/browser/history/history_service_factory.h"
[email protected]66f157312012-08-01 13:50:2626#include "chrome/browser/infobars/infobar_tab_helper.h"
[email protected]03ef4b2a2012-03-06 15:04:2027#include "chrome/browser/profiles/profile.h"
[email protected]03ef4b2a2012-03-06 15:04:2028#include "chrome/browser/ssl/ssl_error_info.h"
[email protected]66f157312012-08-01 13:50:2629#include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h"
[email protected]4237dd52012-06-05 00:00:3230#include "chrome/browser/ui/website_settings/website_settings_ui.h"
[email protected]0b9fdd72012-04-04 10:00:3331#include "chrome/common/content_settings_pattern.h"
32#include "content/public/browser/browser_thread.h"
[email protected]b59c6cf02012-03-12 20:51:4233#include "content/public/browser/cert_store.h"
[email protected]03ef4b2a2012-03-06 15:04:2034#include "content/public/common/ssl_status.h"
35#include "content/public/common/url_constants.h"
36#include "grit/chromium_strings.h"
37#include "grit/generated_resources.h"
38#include "net/base/cert_status_flags.h"
[email protected]be28b5f42012-07-20 11:31:2539#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
[email protected]03ef4b2a2012-03-06 15:04:2040#include "net/base/ssl_cipher_suite_names.h"
41#include "net/base/ssl_connection_status_flags.h"
42#include "net/base/x509_certificate.h"
43#include "ui/base/l10n/l10n_util.h"
44#include "ui/base/resource/resource_bundle.h"
45
[email protected]0b9fdd72012-04-04 10:00:3346using content::BrowserThread;
47
48namespace {
49
[email protected]b1d113d2012-06-27 21:27:3450// The list of content settings types to display on the Website Settings UI.
[email protected]0b9fdd72012-04-04 10:00:3351ContentSettingsType kPermissionType[] = {
[email protected]b1d113d2012-06-27 21:27:3452 CONTENT_SETTINGS_TYPE_IMAGES,
53 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
[email protected]0b9fdd72012-04-04 10:00:3354 CONTENT_SETTINGS_TYPE_PLUGINS,
[email protected]b1d113d2012-06-27 21:27:3455 CONTENT_SETTINGS_TYPE_POPUPS,
[email protected]0b9fdd72012-04-04 10:00:3356 CONTENT_SETTINGS_TYPE_GEOLOCATION,
[email protected]b1d113d2012-06-27 21:27:3457 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
58 CONTENT_SETTINGS_TYPE_FULLSCREEN,
59 CONTENT_SETTINGS_TYPE_MOUSELOCK,
60 CONTENT_SETTINGS_TYPE_MEDIASTREAM,
[email protected]0b9fdd72012-04-04 10:00:3361};
62
63} // namespace
64
65WebsiteSettings::WebsiteSettings(
66 WebsiteSettingsUI* ui,
67 Profile* profile,
[email protected]df818272012-04-20 13:10:5068 TabSpecificContentSettings* tab_specific_content_settings,
[email protected]66f157312012-08-01 13:50:2669 InfoBarTabHelper* infobar_tab_helper,
[email protected]0b9fdd72012-04-04 10:00:3370 const GURL& url,
71 const content::SSLStatus& ssl,
72 content::CertStore* cert_store)
[email protected]df818272012-04-20 13:10:5073 : TabSpecificContentSettings::SiteDataObserver(
74 tab_specific_content_settings),
75 ui_(ui),
[email protected]66f157312012-08-01 13:50:2676 infobar_helper_(infobar_tab_helper),
77 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:3378 site_url_(url),
79 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]f61c1ce2012-05-09 13:55:1180 cert_id_(0),
[email protected]03ef4b2a2012-03-06 15:04:2081 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
[email protected]0b9fdd72012-04-04 10:00:3382 cert_store_(cert_store),
83 content_settings_(profile->GetHostContentSettingsMap()) {
[email protected]03ef4b2a2012-03-06 15:04:2084 Init(profile, url, ssl);
[email protected]0b9fdd72012-04-04 10:00:3385
[email protected]78a1fd90a2012-07-19 08:11:2586 HistoryService* history_service = HistoryServiceFactory::GetForProfile(
87 profile, Profile::EXPLICIT_ACCESS);
[email protected]15b092542012-05-16 13:08:1488 if (history_service) {
89 history_service->GetVisibleVisitCountToHost(
90 site_url_,
91 &visit_count_request_consumer_,
92 base::Bind(&WebsiteSettings::OnGotVisitCountToHost,
93 base::Unretained(this)));
94 }
95
[email protected]0b9fdd72012-04-04 10:00:3396 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:5097 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:4198 PresentSiteIdentity();
[email protected]15b092542012-05-16 13:08:1499 PresentHistoryInfo(base::Time());
[email protected]03ef4b2a2012-03-06 15:04:20100}
101
[email protected]0b9fdd72012-04-04 10:00:33102WebsiteSettings::~WebsiteSettings() {
[email protected]03ef4b2a2012-03-06 15:04:20103}
104
[email protected]df818272012-04-20 13:10:50105void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type,
106 ContentSetting setting) {
107 ContentSettingsPattern primary_pattern;
108 ContentSettingsPattern secondary_pattern;
109 switch (type) {
110 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
111 // TODO(markusheintz): The rule we create here should also change the
112 // location permission for iframed content.
113 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_);
114 secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_);
115 break;
116 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
117 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_);
118 secondary_pattern = ContentSettingsPattern::Wildcard();
119 break;
[email protected]b1d113d2012-06-27 21:27:34120 case CONTENT_SETTINGS_TYPE_IMAGES:
121 case CONTENT_SETTINGS_TYPE_JAVASCRIPT:
[email protected]df818272012-04-20 13:10:50122 case CONTENT_SETTINGS_TYPE_PLUGINS:
123 case CONTENT_SETTINGS_TYPE_POPUPS:
[email protected]b1d113d2012-06-27 21:27:34124 case CONTENT_SETTINGS_TYPE_FULLSCREEN:
125 case CONTENT_SETTINGS_TYPE_MOUSELOCK:
126 case CONTENT_SETTINGS_TYPE_MEDIASTREAM:
[email protected]df818272012-04-20 13:10:50127 primary_pattern = ContentSettingsPattern::FromURL(site_url_);
128 secondary_pattern = ContentSettingsPattern::Wildcard();
129 break;
130 default:
131 NOTREACHED() << "ContentSettingsType " << type << "is not supported.";
132 break;
[email protected]0b9fdd72012-04-04 10:00:33133 }
134
[email protected]df818272012-04-20 13:10:50135 // Permission settings are specified via rules. There exists always at least
136 // one rule for the default setting. Get the rule that currently defines
137 // the permission for the given permission |type|. Then test whether the
138 // existing rule is more specific than the rule we are about to create. If
139 // the existing rule is more specific, than change the existing rule instead
140 // of creating a new rule that would be hidden behind the existing rule.
141 content_settings::SettingInfo info;
142 scoped_ptr<Value> v(content_settings_->GetWebsiteSetting(
143 site_url_, site_url_, type, "", &info));
144 DCHECK(info.source == content_settings::SETTING_SOURCE_USER);
145 ContentSettingsPattern::Relation r1 =
146 info.primary_pattern.Compare(primary_pattern);
147 DCHECK(r1 != ContentSettingsPattern::DISJOINT_ORDER_POST &&
148 r1 != ContentSettingsPattern::DISJOINT_ORDER_PRE);
149 if (r1 == ContentSettingsPattern::PREDECESSOR) {
150 primary_pattern = info.primary_pattern;
151 } else if (r1 == ContentSettingsPattern::IDENTITY) {
152 ContentSettingsPattern::Relation r2 =
153 info.secondary_pattern.Compare(secondary_pattern);
154 DCHECK(r2 != ContentSettingsPattern::DISJOINT_ORDER_POST &&
155 r2 != ContentSettingsPattern::DISJOINT_ORDER_PRE);
156 if (r2 == ContentSettingsPattern::PREDECESSOR)
157 secondary_pattern = info.secondary_pattern;
158 }
159
160 Value* value = NULL;
161 if (setting != CONTENT_SETTING_DEFAULT)
162 value = Value::CreateIntegerValue(setting);
163 content_settings_->SetWebsiteSetting(
164 primary_pattern, secondary_pattern, type, "", value);
[email protected]66f157312012-08-01 13:50:26165 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24166
167 // Refresh the UI to reflect the new setting.
168 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50169}
170
[email protected]15b092542012-05-16 13:08:14171void WebsiteSettings::OnGotVisitCountToHost(HistoryService::Handle handle,
172 bool found_visits,
173 int visit_count,
174 base::Time first_visit) {
175 if (!found_visits) {
176 // This indicates an error, such as the page's URL scheme wasn't
177 // http/https.
178 first_visit = base::Time();
179 } else if (visit_count == 0) {
180 first_visit = base::Time::Now();
181 }
182 PresentHistoryInfo(first_visit);
183}
184
[email protected]df818272012-04-20 13:10:50185void WebsiteSettings::OnSiteDataAccessed() {
186 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33187}
188
[email protected]66f157312012-08-01 13:50:26189void WebsiteSettings::OnUIClosing() {
190 if (show_info_bar_) {
191 infobar_helper_->AddInfoBar(
192 new WebsiteSettingsInfobarDelegate(infobar_helper_));
193 }
194}
195
[email protected]0b9fdd72012-04-04 10:00:33196void WebsiteSettings::Init(Profile* profile,
197 const GURL& url,
198 const content::SSLStatus& ssl) {
[email protected]03ef4b2a2012-03-06 15:04:20199 if (url.SchemeIs(chrome::kChromeUIScheme)) {
200 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
201 site_identity_details_ =
202 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
203 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
204 return;
205 }
206
207 scoped_refptr<net::X509Certificate> cert;
208
209 // Identity section.
210 string16 subject_name(UTF8ToUTF16(url.host()));
[email protected]03ef4b2a2012-03-06 15:04:20211 if (subject_name.empty()) {
212 subject_name.assign(
213 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
[email protected]03ef4b2a2012-03-06 15:04:20214 }
215
[email protected]f61c1ce2012-05-09 13:55:11216 cert_id_ = ssl.cert_id;
217
[email protected]03ef4b2a2012-03-06 15:04:20218 if (ssl.cert_id &&
219 cert_store_->RetrieveCert(ssl.cert_id, &cert) &&
220 (!net::IsCertStatusError(ssl.cert_status) ||
221 net::IsCertStatusMinorError(ssl.cert_status))) {
222 // There are no major errors. Check for minor errors.
223 if (net::IsCertStatusMinorError(ssl.cert_status)) {
224 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
225 string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName()));
226 if (issuer_name.empty()) {
227 issuer_name.assign(l10n_util::GetStringUTF16(
228 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
229 }
230 site_identity_details_.assign(l10n_util::GetStringFUTF16(
231 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name));
232
233 site_identity_details_ += ASCIIToUTF16("\n\n");
234 if (ssl.cert_status & net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
235 site_identity_details_ += l10n_util::GetStringUTF16(
236 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
237 } else if (ssl.cert_status & net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
238 site_identity_details_ += l10n_util::GetStringUTF16(
239 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
240 } else {
241 NOTREACHED() << "Need to specify string for this warning";
242 }
243 } else if (ssl.cert_status & net::CERT_STATUS_IS_EV) {
244 // EV HTTPS page.
245 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
246 DCHECK(!cert->subject().organization_names.empty());
247 organization_name_ = UTF8ToUTF16(cert->subject().organization_names[0]);
248 // An EV Cert is required to have a city (localityName) and country but
249 // state is "if any".
250 DCHECK(!cert->subject().locality_name.empty());
251 DCHECK(!cert->subject().country_name.empty());
252 string16 locality;
253 if (!cert->subject().state_or_province_name.empty()) {
254 locality = l10n_util::GetStringFUTF16(
255 IDS_PAGEINFO_ADDRESS,
256 UTF8ToUTF16(cert->subject().locality_name),
257 UTF8ToUTF16(cert->subject().state_or_province_name),
258 UTF8ToUTF16(cert->subject().country_name));
259 } else {
260 locality = l10n_util::GetStringFUTF16(
261 IDS_PAGEINFO_PARTIAL_ADDRESS,
262 UTF8ToUTF16(cert->subject().locality_name),
263 UTF8ToUTF16(cert->subject().country_name));
264 }
265 DCHECK(!cert->subject().organization_names.empty());
266 site_identity_details_.assign(l10n_util::GetStringFUTF16(
267 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV,
268 UTF8ToUTF16(cert->subject().organization_names[0]),
269 locality,
270 UTF8ToUTF16(cert->issuer().GetDisplayName())));
271 } else if (ssl.cert_status & net::CERT_STATUS_IS_DNSSEC) {
272 // DNSSEC authenticated page.
273 site_identity_status_ = SITE_IDENTITY_STATUS_DNSSEC_CERT;
274 site_identity_details_.assign(l10n_util::GetStringFUTF16(
275 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, UTF8ToUTF16("DNSSEC")));
276 } else {
277 // Non-EV OK HTTPS page.
278 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
279 string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName()));
280 if (issuer_name.empty()) {
281 issuer_name.assign(l10n_util::GetStringUTF16(
282 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
283 }
284 site_identity_details_.assign(l10n_util::GetStringFUTF16(
285 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name));
286 }
287 } else {
288 // HTTP or HTTPS with errors (not warnings).
289 site_identity_details_.assign(l10n_util::GetStringUTF16(
290 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
291 if (ssl.security_style == content::SECURITY_STYLE_UNAUTHENTICATED)
292 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
293 else
294 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
295
296 const string16 bullet = UTF8ToUTF16("\n • ");
297 std::vector<SSLErrorInfo> errors;
298 SSLErrorInfo::GetErrorsForCertStatus(ssl.cert_id, ssl.cert_status,
299 url, &errors);
300 for (size_t i = 0; i < errors.size(); ++i) {
301 site_identity_details_ += bullet;
302 site_identity_details_ += errors[i].short_description();
303 }
304
305 if (ssl.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
306 site_identity_details_ += ASCIIToUTF16("\n\n");
307 site_identity_details_ += l10n_util::GetStringUTF16(
308 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
309 }
310 }
311
312 // Site Connection
313 // We consider anything less than 80 bits encryption to be weak encryption.
314 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
315 // weakly encrypted connections.
316 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
317
318 if (!ssl.cert_id) {
319 // Not HTTPS.
320 DCHECK_EQ(ssl.security_style, content::SECURITY_STYLE_UNAUTHENTICATED);
321 if (ssl.security_style == content::SECURITY_STYLE_UNAUTHENTICATED)
322 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
323 else
324 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
325
326 site_connection_details_.assign(l10n_util::GetStringFUTF16(
327 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
328 subject_name));
329 } else if (ssl.security_bits < 0) {
330 // Security strength is unknown. Say nothing.
331 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
332 } else if (ssl.security_bits == 0) {
333 DCHECK_NE(ssl.security_style, content::SECURITY_STYLE_UNAUTHENTICATED);
334 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
335 site_connection_details_.assign(l10n_util::GetStringFUTF16(
336 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
337 subject_name));
338 } else if (ssl.security_bits < 80) {
339 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
340 site_connection_details_.assign(l10n_util::GetStringFUTF16(
341 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
342 subject_name));
343 } else {
344 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
345 site_connection_details_.assign(l10n_util::GetStringFUTF16(
346 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
347 subject_name,
348 base::IntToString16(ssl.security_bits)));
349 if (ssl.content_status) {
350 bool ran_insecure_content =
351 !!(ssl.content_status & content::SSLStatus::RAN_INSECURE_CONTENT);
352 site_connection_status_ = ran_insecure_content ?
353 SITE_CONNECTION_STATUS_ENCRYPTED_ERROR
354 : SITE_CONNECTION_STATUS_MIXED_CONTENT;
355 site_connection_details_.assign(l10n_util::GetStringFUTF16(
356 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
357 site_connection_details_,
358 l10n_util::GetStringUTF16(ran_insecure_content ?
359 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR :
360 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
361 }
362 }
363
364 uint16 cipher_suite =
365 net::SSLConnectionStatusToCipherSuite(ssl.connection_status);
366 if (ssl.security_bits > 0 && cipher_suite) {
367 int ssl_version =
368 net::SSLConnectionStatusToVersion(ssl.connection_status);
369 const char* ssl_version_str;
370 net::SSLVersionToString(&ssl_version_str, ssl_version);
371 site_connection_details_ += ASCIIToUTF16("\n\n");
372 site_connection_details_ += l10n_util::GetStringFUTF16(
373 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION,
374 ASCIIToUTF16(ssl_version_str));
375
376 bool did_fallback = (ssl.connection_status &
[email protected]80c75f682012-05-26 16:22:17377 net::SSL_CONNECTION_VERSION_FALLBACK) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20378 bool no_renegotiation =
379 (ssl.connection_status &
380 net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0;
381 const char *key_exchange, *cipher, *mac;
382 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, cipher_suite);
383
384 site_connection_details_ += ASCIIToUTF16("\n\n");
385 site_connection_details_ += l10n_util::GetStringFUTF16(
386 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS,
387 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
388
389 site_connection_details_ += ASCIIToUTF16("\n\n");
390 uint8 compression_id =
391 net::SSLConnectionStatusToCompression(ssl.connection_status);
392 if (compression_id) {
393 const char* compression;
394 net::SSLCompressionToString(&compression, compression_id);
395 site_connection_details_ += l10n_util::GetStringFUTF16(
396 IDS_PAGE_INFO_SECURITY_TAB_COMPRESSION_DETAILS,
397 ASCIIToUTF16(compression));
398 } else {
399 site_connection_details_ += l10n_util::GetStringUTF16(
400 IDS_PAGE_INFO_SECURITY_TAB_NO_COMPRESSION);
401 }
402
403 if (did_fallback) {
404 // For now, only SSLv3 fallback will trigger a warning icon.
405 if (site_connection_status_ < SITE_CONNECTION_STATUS_MIXED_CONTENT)
406 site_connection_status_ = SITE_CONNECTION_STATUS_MIXED_CONTENT;
407 site_connection_details_ += ASCIIToUTF16("\n\n");
408 site_connection_details_ += l10n_util::GetStringUTF16(
409 IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE);
410 }
411 if (no_renegotiation) {
412 site_connection_details_ += ASCIIToUTF16("\n\n");
413 site_connection_details_ += l10n_util::GetStringUTF16(
414 IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE);
415 }
416 }
417}
[email protected]0b9fdd72012-04-04 10:00:33418
[email protected]df818272012-04-20 13:10:50419void WebsiteSettings::PresentSitePermissions() {
420 PermissionInfoList permission_info_list;
421
422 WebsiteSettingsUI::PermissionInfo permission_info;
423 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
424 permission_info.type = kPermissionType[i];
425
426 content_settings::SettingInfo info;
427 scoped_ptr<Value> value(content_settings_->GetWebsiteSetting(
428 site_url_, site_url_, permission_info.type, "", &info));
429 DCHECK(value.get());
430 permission_info.setting =
431 content_settings::ValueToContentSetting(value.get());
[email protected]8bdf45c32012-08-04 00:12:55432 permission_info.source = info.source;
[email protected]df818272012-04-20 13:10:50433
[email protected]b1d113d2012-06-27 21:27:34434 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
435 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
436 permission_info.default_setting = permission_info.setting;
437 permission_info.setting = CONTENT_SETTING_DEFAULT;
438 } else {
439 permission_info.default_setting =
440 content_settings_->GetDefaultContentSetting(permission_info.type,
441 NULL);
[email protected]df818272012-04-20 13:10:50442 }
[email protected]b1d113d2012-06-27 21:27:34443 permission_info_list.push_back(permission_info);
[email protected]df818272012-04-20 13:10:50444 }
445
446 ui_->SetPermissionInfo(permission_info_list);
[email protected]0b9fdd72012-04-04 10:00:33447}
448
[email protected]df818272012-04-20 13:10:50449void WebsiteSettings::PresentSiteData() {
450 CookieInfoList cookie_info_list;
[email protected]e0ac35892012-05-15 12:53:34451 const LocalSharedObjectsContainer& allowed_objects =
452 tab_specific_content_settings()->allowed_local_shared_objects();
453 const LocalSharedObjectsContainer& blocked_objects =
454 tab_specific_content_settings()->blocked_local_shared_objects();
455
456 // Add first party cookie and site data counts.
[email protected]df818272012-04-20 13:10:50457 WebsiteSettingsUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34458 std::string cookie_source =
459 net::RegistryControlledDomainService::GetDomainAndRegistry(site_url_);
460 if (cookie_source.empty())
461 cookie_source = site_url_.host();
462 cookie_info.cookie_source = cookie_source;
463 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
464 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
465 cookie_info_list.push_back(cookie_info);
466
467 // Add third party cookie counts.
468 cookie_info.cookie_source = l10n_util::GetStringUTF8(
469 IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA);
470 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
471 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
[email protected]df818272012-04-20 13:10:50472 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33473
[email protected]df818272012-04-20 13:10:50474 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33475}
[email protected]16de6de2012-04-04 12:24:14476
[email protected]24c8818c2012-04-25 09:57:41477void WebsiteSettings::PresentSiteIdentity() {
478 // After initialization the status about the site's connection
479 // and it's identity must be available.
480 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
481 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
482 WebsiteSettingsUI::IdentityInfo info;
483 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
484 info.site_identity = UTF16ToUTF8(organization_name());
485 else
486 info.site_identity = site_url_.host();
487
488 info.connection_status = site_connection_status_;
489 info.connection_status_description =
490 UTF16ToUTF8(site_connection_details_);
491 info.identity_status = site_identity_status_;
492 info.identity_status_description =
493 UTF16ToUTF8(site_identity_details_);
[email protected]f61c1ce2012-05-09 13:55:11494 info.cert_id = cert_id_;
[email protected]24c8818c2012-04-25 09:57:41495 ui_->SetIdentityInfo(info);
496}
497
[email protected]15b092542012-05-16 13:08:14498void WebsiteSettings::PresentHistoryInfo(base::Time first_visit) {
499 if (first_visit == base::Time()) {
500 ui_->SetFirstVisit(string16());
501 return;
502 }
503
504 bool visited_before_today = false;
505 base::Time today = base::Time::Now().LocalMidnight();
506 base::Time first_visit_midnight = first_visit.LocalMidnight();
507 visited_before_today = (first_visit_midnight < today);
508
509 string16 first_visit_text;
510 if (visited_before_today) {
511 first_visit_text = l10n_util::GetStringFUTF16(
512 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY,
513 base::TimeFormatShortDate(first_visit));
514 } else {
515 first_visit_text = l10n_util::GetStringUTF16(
516 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY);
517
518 }
519 ui_->SetFirstVisit(first_visit_text);
520}