blob: 8bb29e8bea93072a8f48d95244f064a499e600bf [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"
[email protected]eb2140c2013-07-29 12:37:3412#include "base/command_line.h"
[email protected]15b092542012-05-16 13:08:1413#include "base/i18n/time_formatting.h"
[email protected]71cd5ef2014-08-13 21:22:0414#include "base/metrics/field_trial.h"
[email protected]3ea1b182013-02-08 22:38:4115#include "base/metrics/histogram.h"
16#include "base/strings/string_number_conversions.h"
[email protected]774cc3c2013-06-07 20:26:4517#include "base/strings/utf_string_conversions.h"
[email protected]0b9fdd72012-04-04 10:00:3318#include "base/values.h"
[email protected]6b8a3c742014-07-25 00:25:3519#include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h"
[email protected]b0cb5e82012-07-19 19:22:4720#include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
21#include "chrome/browser/browsing_data/browsing_data_database_helper.h"
22#include "chrome/browser/browsing_data/browsing_data_file_system_helper.h"
23#include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
24#include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
[email protected]77a91c72012-08-13 16:19:3425#include "chrome/browser/history/history_service_factory.h"
[email protected]03ef4b2a2012-03-06 15:04:2026#include "chrome/browser/profiles/profile.h"
[email protected]71cd5ef2014-08-13 21:22:0427#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
28#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
[email protected]03ef4b2a2012-03-06 15:04:2029#include "chrome/browser/ssl/ssl_error_info.h"
[email protected]66f157312012-08-01 13:50:2630#include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h"
[email protected]4237dd52012-06-05 00:00:3231#include "chrome/browser/ui/website_settings/website_settings_ui.h"
[email protected]71cd5ef2014-08-13 21:22:0432#include "chrome/common/chrome_switches.h"
thestig884a1602014-08-27 01:29:3933#include "chrome/grit/chromium_strings.h"
34#include "chrome/grit/generated_resources.h"
mukai8eaec822014-10-25 17:53:1635#include "components/content_settings/core/browser/content_settings_utils.h"
36#include "components/content_settings/core/browser/host_content_settings_map.h"
vabr48565592014-10-08 15:06:0237#include "components/content_settings/core/browser/local_shared_objects_counter.h"
vasiliif62dbf92014-09-05 10:23:1338#include "components/content_settings/core/common/content_settings_pattern.h"
[email protected]0b9fdd72012-04-04 10:00:3339#include "content/public/browser/browser_thread.h"
[email protected]b59c6cf02012-03-12 20:51:4240#include "content/public/browser/cert_store.h"
[email protected]e22d64f2012-09-10 09:03:2341#include "content/public/browser/user_metrics.h"
[email protected]eb2140c2013-07-29 12:37:3442#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2043#include "content/public/common/ssl_status.h"
44#include "content/public/common/url_constants.h"
[email protected]be28b5f42012-07-20 11:31:2545#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
[email protected]6e7845ae2013-03-29 21:48:1146#include "net/cert/cert_status_flags.h"
47#include "net/cert/x509_certificate.h"
[email protected]536fd0b2013-03-14 17:41:5748#include "net/ssl/ssl_cipher_suite_names.h"
49#include "net/ssl/ssl_connection_status_flags.h"
[email protected]03ef4b2a2012-03-06 15:04:2050#include "ui/base/l10n/l10n_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2051
[email protected]24a9f1c92013-11-13 12:33:3752#if defined(OS_CHROMEOS)
53#include "chrome/browser/chromeos/policy/policy_cert_service.h"
54#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
55#endif
56
[email protected]ab6df3b12013-12-24 23:32:2657using base::ASCIIToUTF16;
58using base::UTF8ToUTF16;
[email protected]f729d7a2013-12-26 07:07:5659using base::UTF16ToUTF8;
[email protected]0b9fdd72012-04-04 10:00:3360using content::BrowserThread;
61
62namespace {
63
jww1ed8ea72014-09-02 20:43:2564// Events for UMA. Do not reorder or change!
65enum SSLCertificateDecisionsDidRevoke {
66 USER_CERT_DECISIONS_NOT_REVOKED = 0,
67 USER_CERT_DECISIONS_REVOKED,
68 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM
69};
70
[email protected]b1d113d2012-06-27 21:27:3471// The list of content settings types to display on the Website Settings UI.
[email protected]0b9fdd72012-04-04 10:00:3372ContentSettingsType kPermissionType[] = {
[email protected]b1d113d2012-06-27 21:27:3473 CONTENT_SETTINGS_TYPE_IMAGES,
74 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
[email protected]0b9fdd72012-04-04 10:00:3375 CONTENT_SETTINGS_TYPE_PLUGINS,
[email protected]b1d113d2012-06-27 21:27:3476 CONTENT_SETTINGS_TYPE_POPUPS,
[email protected]0b9fdd72012-04-04 10:00:3377 CONTENT_SETTINGS_TYPE_GEOLOCATION,
[email protected]b1d113d2012-06-27 21:27:3478 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
79 CONTENT_SETTINGS_TYPE_FULLSCREEN,
80 CONTENT_SETTINGS_TYPE_MOUSELOCK,
81 CONTENT_SETTINGS_TYPE_MEDIASTREAM,
[email protected]62167c12013-07-10 23:02:0882 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
[email protected]eb2140c2013-07-29 12:37:3483 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
benwellsa68ed4b2014-11-13 03:25:3684#if defined(OS_ANDROID)
85 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
86#endif
[email protected]0b9fdd72012-04-04 10:00:3387};
88
[email protected]94c74b42013-12-02 15:19:4989bool CertificateTransparencyStatusMatch(
90 const content::SignedCertificateTimestampIDStatusList& scts,
91 net::ct::SCTVerifyStatus status) {
92 for (content::SignedCertificateTimestampIDStatusList::const_iterator it =
93 scts.begin();
94 it != scts.end();
95 ++it) {
96 if (it->status == status)
97 return true;
98 }
99
100 return false;
101}
102
103int GetSiteIdentityDetailsMessageByCTInfo(
104 const content::SignedCertificateTimestampIDStatusList& scts,
105 bool is_ev) {
106 // No SCTs - no CT information.
107 if (scts.empty())
108 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_NO_CT
109 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_NO_CT);
110
111 if (CertificateTransparencyStatusMatch(scts, net::ct::SCT_STATUS_OK))
112 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_VERIFIED
113 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_VERIFIED);
114
115 if (CertificateTransparencyStatusMatch(scts, net::ct::SCT_STATUS_INVALID))
116 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_INVALID
117 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_INVALID);
118
119 // status is SCT_STATUS_LOG_UNKNOWN
120 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_UNVERIFIED
121 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_UNVERIFIED);
122}
123
124// This function will return SITE_IDENTITY_STATUS_CERT or
125// SITE_IDENTITY_STATUS_EV_CERT depending on |is_ev| unless there are SCTs
126// which failed verification, in which case it will return
127// SITE_IDENTITY_STATUS_ERROR.
128WebsiteSettings::SiteIdentityStatus GetSiteIdentityStatusByCTInfo(
129 const content::SignedCertificateTimestampIDStatusList& scts,
130 bool is_ev) {
131 if (CertificateTransparencyStatusMatch(scts, net::ct::SCT_STATUS_INVALID))
132 return WebsiteSettings::SITE_IDENTITY_STATUS_ERROR;
133
134 return is_ev ? WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT
135 : WebsiteSettings::SITE_IDENTITY_STATUS_CERT;
136}
137
[email protected]71cd5ef2014-08-13 21:22:04138const char kRememberCertificateErrorDecisionsFieldTrialName[] =
139 "RememberCertificateErrorDecisions";
140const char kRememberCertificateErrorDecisionsFieldTrialDefaultGroup[] =
141 "Default";
142const char kRememberCertificateErrorDecisionsFieldTrialDisableGroup[] =
143 "Disable";
144// Returns true if the user is in the experimental group or has the flag enabled
145// for remembering SSL error decisions, otherwise false.
146//
147// TODO(jww): The field trial is scheduled to end 2015/02/28. This should be
148// removed at that point unless the field trial or flag continues.
149bool InRememberCertificateErrorDecisionsGroup() {
150 std::string group_name = base::FieldTrialList::FindFullName(
151 kRememberCertificateErrorDecisionsFieldTrialName);
152
153 // The Default and Disable groups are the "old-style" forget-at-session
154 // restart groups, so they do not get the button.
155 bool in_experimental_group = !group_name.empty() &&
156 group_name.compare(
157 kRememberCertificateErrorDecisionsFieldTrialDefaultGroup) != 0 &&
158 group_name.compare(
159 kRememberCertificateErrorDecisionsFieldTrialDisableGroup) != 0;
avi556c05022014-12-22 23:31:43160 bool has_command_line_switch =
161 base::CommandLine::ForCurrentProcess()->HasSwitch(
162 switches::kRememberCertErrorDecisions);
[email protected]71cd5ef2014-08-13 21:22:04163 return in_experimental_group || has_command_line_switch;
164}
165
[email protected]0b9fdd72012-04-04 10:00:33166} // namespace
167
168WebsiteSettings::WebsiteSettings(
169 WebsiteSettingsUI* ui,
170 Profile* profile,
[email protected]df818272012-04-20 13:10:50171 TabSpecificContentSettings* tab_specific_content_settings,
[email protected]4f822f022012-12-20 19:11:42172 InfoBarService* infobar_service,
[email protected]0b9fdd72012-04-04 10:00:33173 const GURL& url,
174 const content::SSLStatus& ssl,
175 content::CertStore* cert_store)
[email protected]df818272012-04-20 13:10:50176 : TabSpecificContentSettings::SiteDataObserver(
177 tab_specific_content_settings),
178 ui_(ui),
[email protected]4f822f022012-12-20 19:11:42179 infobar_service_(infobar_service),
[email protected]66f157312012-08-01 13:50:26180 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33181 site_url_(url),
182 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]f61c1ce2012-05-09 13:55:11183 cert_id_(0),
[email protected]03ef4b2a2012-03-06 15:04:20184 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
[email protected]0b9fdd72012-04-04 10:00:33185 cert_store_(cert_store),
[email protected]71cd5ef2014-08-13 21:22:04186 content_settings_(profile->GetHostContentSettingsMap()),
187 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25188 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
189 did_revoke_user_ssl_decisions_(false) {
[email protected]03ef4b2a2012-03-06 15:04:20190 Init(profile, url, ssl);
[email protected]0b9fdd72012-04-04 10:00:33191
[email protected]78a1fd90a2012-07-19 08:11:25192 HistoryService* history_service = HistoryServiceFactory::GetForProfile(
sdefresnee9ea3c22015-01-10 10:10:04193 profile, ServiceAccessType::EXPLICIT_ACCESS);
[email protected]15b092542012-05-16 13:08:14194 if (history_service) {
195 history_service->GetVisibleVisitCountToHost(
196 site_url_,
[email protected]15b092542012-05-16 13:08:14197 base::Bind(&WebsiteSettings::OnGotVisitCountToHost,
[email protected]e800fe742014-07-01 10:38:19198 base::Unretained(this)),
199 &visit_count_task_tracker_);
[email protected]15b092542012-05-16 13:08:14200 }
201
[email protected]0b9fdd72012-04-04 10:00:33202 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50203 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41204 PresentSiteIdentity();
[email protected]15b092542012-05-16 13:08:14205 PresentHistoryInfo(base::Time());
[email protected]e22d64f2012-09-10 09:03:23206
207 // Every time the Website Settings UI is opened a |WebsiteSettings| object is
208 // created. So this counts how ofter the Website Settings UI is opened.
lgarron04a93502014-11-04 22:25:04209 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20210}
211
[email protected]0b9fdd72012-04-04 10:00:33212WebsiteSettings::~WebsiteSettings() {
[email protected]03ef4b2a2012-03-06 15:04:20213}
214
lgarron04a93502014-11-04 22:25:04215void WebsiteSettings::RecordWebsiteSettingsAction(
216 WebsiteSettingsAction action) {
217 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action",
218 action,
219 WEBSITE_SETTINGS_COUNT);
220
221 // Use a separate histogram to record actions if they are done on a page with
222 // an HTTPS URL. Note that this *disregards* security status.
223 if (site_url_.SchemeIs(url::kHttpsScheme)) {
224 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action.HttpsUrl",
225 action,
226 WEBSITE_SETTINGS_COUNT);
227 }
228}
229
230
[email protected]df818272012-04-20 13:10:50231void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type,
232 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23233 // Count how often a permission for a specific content type is changed using
234 // the Website Settings UI.
sashab9debecd2014-12-18 04:15:56235 ContentSettingsTypeHistogram histogram_value =
236 ContentSettingTypeToHistogramValue(type);
237 DCHECK_NE(histogram_value, CONTENT_SETTINGS_TYPE_HISTOGRAM_INVALID)
238 << "Invalid content setting type specified.";
239 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.OriginInfo.PermissionChanged",
240 histogram_value,
241 CONTENT_SETTINGS_HISTOGRAM_NUM_TYPES);
242
243 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
244 UMA_HISTOGRAM_ENUMERATION(
245 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
246 CONTENT_SETTINGS_HISTOGRAM_NUM_TYPES);
247 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
248 UMA_HISTOGRAM_ENUMERATION(
249 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
250 CONTENT_SETTINGS_HISTOGRAM_NUM_TYPES);
251 }
[email protected]e22d64f2012-09-10 09:03:23252
lgarron04a93502014-11-04 22:25:04253 // This is technically redundant given the histogram above, but putting the
254 // total count of permission changes in another histogram makes it easier to
255 // compare it against other kinds of actions in WebsiteSettings[PopupView].
256 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_CHANGED_PERMISSION);
257
[email protected]df818272012-04-20 13:10:50258 ContentSettingsPattern primary_pattern;
259 ContentSettingsPattern secondary_pattern;
260 switch (type) {
261 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
[email protected]eb2140c2013-07-29 12:37:34262 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
[email protected]df818272012-04-20 13:10:50263 // TODO(markusheintz): The rule we create here should also change the
264 // location permission for iframed content.
265 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_);
266 secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_);
267 break;
268 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
269 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_);
270 secondary_pattern = ContentSettingsPattern::Wildcard();
271 break;
[email protected]b1d113d2012-06-27 21:27:34272 case CONTENT_SETTINGS_TYPE_IMAGES:
273 case CONTENT_SETTINGS_TYPE_JAVASCRIPT:
[email protected]df818272012-04-20 13:10:50274 case CONTENT_SETTINGS_TYPE_PLUGINS:
275 case CONTENT_SETTINGS_TYPE_POPUPS:
[email protected]b1d113d2012-06-27 21:27:34276 case CONTENT_SETTINGS_TYPE_FULLSCREEN:
277 case CONTENT_SETTINGS_TYPE_MOUSELOCK:
[email protected]ad635b12013-07-22 21:53:27278 case CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS:
benwellsa68ed4b2014-11-13 03:25:36279 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
[email protected]df818272012-04-20 13:10:50280 primary_pattern = ContentSettingsPattern::FromURL(site_url_);
281 secondary_pattern = ContentSettingsPattern::Wildcard();
282 break;
[email protected]0bacc1912012-12-11 11:05:34283 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: {
284 // We need to use the same same patterns as other places like infobar code
285 // to override the existing rule instead of creating the new one.
286 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_);
287 secondary_pattern = ContentSettingsPattern::Wildcard();
288 // Set permission for both microphone and camera.
289 content_settings_->SetContentSetting(
[email protected]007b3f82013-04-09 08:46:45290 primary_pattern,
291 secondary_pattern,
292 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
293 std::string(),
294 setting);
[email protected]0bacc1912012-12-11 11:05:34295
296 content_settings_->SetContentSetting(
[email protected]007b3f82013-04-09 08:46:45297 primary_pattern,
298 secondary_pattern,
299 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
300 std::string(),
301 setting);
[email protected]0bacc1912012-12-11 11:05:34302 break;
303 }
[email protected]df818272012-04-20 13:10:50304 default:
305 NOTREACHED() << "ContentSettingsType " << type << "is not supported.";
306 break;
[email protected]0b9fdd72012-04-04 10:00:33307 }
308
[email protected]0bacc1912012-12-11 11:05:34309 if (type != CONTENT_SETTINGS_TYPE_MEDIASTREAM) {
310 // Permission settings are specified via rules. There exists always at least
311 // one rule for the default setting. Get the rule that currently defines
312 // the permission for the given permission |type|. Then test whether the
313 // existing rule is more specific than the rule we are about to create. If
314 // the existing rule is more specific, than change the existing rule instead
315 // of creating a new rule that would be hidden behind the existing rule.
316 // This is not a concern for CONTENT_SETTINGS_TYPE_MEDIASTREAM since users
317 // can not create media settings exceptions by hand.
318 content_settings::SettingInfo info;
dhnishid5770d212014-09-18 21:59:18319 scoped_ptr<base::Value> v =
320 content_settings_->GetWebsiteSettingWithoutOverride(
321 site_url_, site_url_, type, std::string(), &info);
[email protected]6b3552a2014-08-21 21:10:12322 content_settings_->SetNarrowestWebsiteSetting(
323 primary_pattern, secondary_pattern, type, std::string(), setting, info);
324 } else {
[email protected]2c95d102013-12-23 20:42:16325 base::Value* value = NULL;
[email protected]0bacc1912012-12-11 11:05:34326 if (setting != CONTENT_SETTING_DEFAULT)
[email protected]a7965a42014-07-22 02:35:56327 value = new base::FundamentalValue(setting);
[email protected]0bacc1912012-12-11 11:05:34328 content_settings_->SetWebsiteSetting(
[email protected]007b3f82013-04-09 08:46:45329 primary_pattern, secondary_pattern, type, std::string(), value);
[email protected]df818272012-04-20 13:10:50330 }
331
[email protected]66f157312012-08-01 13:50:26332 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24333
[email protected]76955932012-12-06 11:01:10334// TODO(markusheintz): This is a temporary hack to fix issue:
335// http://crbug.com/144203.
[email protected]e379ba42012-08-22 22:40:25336#if defined(OS_MACOSX)
[email protected]2f45d542012-08-22 08:47:24337 // Refresh the UI to reflect the new setting.
338 PresentSitePermissions();
[email protected]e379ba42012-08-22 22:40:25339#endif
[email protected]df818272012-04-20 13:10:50340}
341
[email protected]e800fe742014-07-01 10:38:19342void WebsiteSettings::OnGotVisitCountToHost(bool found_visits,
[email protected]15b092542012-05-16 13:08:14343 int visit_count,
344 base::Time first_visit) {
345 if (!found_visits) {
346 // This indicates an error, such as the page's URL scheme wasn't
347 // http/https.
348 first_visit = base::Time();
349 } else if (visit_count == 0) {
350 first_visit = base::Time::Now();
351 }
352 PresentHistoryInfo(first_visit);
353}
354
[email protected]df818272012-04-20 13:10:50355void WebsiteSettings::OnSiteDataAccessed() {
356 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33357}
358
[email protected]66f157312012-08-01 13:50:26359void WebsiteSettings::OnUIClosing() {
[email protected]0be09932013-01-08 02:03:50360 if (show_info_bar_)
[email protected]ed9bc652013-07-11 17:17:36361 WebsiteSettingsInfoBarDelegate::Create(infobar_service_);
jww1ed8ea72014-09-02 20:43:25362
363 SSLCertificateDecisionsDidRevoke user_decision =
364 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
365 : USER_CERT_DECISIONS_NOT_REVOKED;
366
367 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
368 user_decision,
369 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
370}
371
372void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() {
373 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29374 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
375 site_url().host());
jww1ed8ea72014-09-02 20:43:25376 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26377}
378
[email protected]0b9fdd72012-04-04 10:00:33379void WebsiteSettings::Init(Profile* profile,
380 const GURL& url,
381 const content::SSLStatus& ssl) {
sashab97894ce2014-10-22 10:08:33382 bool isChromeUINativeScheme = false;
383#if defined(OS_ANDROID)
384 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
385#endif
386
387 if (url.SchemeIs(content::kChromeUIScheme) ||
388 url.SchemeIs(url::kAboutScheme) || isChromeUINativeScheme) {
[email protected]03ef4b2a2012-03-06 15:04:20389 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
390 site_identity_details_ =
391 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
392 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
393 return;
394 }
395
396 scoped_refptr<net::X509Certificate> cert;
397
398 // Identity section.
[email protected]a04db822013-12-11 19:14:40399 base::string16 subject_name(UTF8ToUTF16(url.host()));
[email protected]03ef4b2a2012-03-06 15:04:20400 if (subject_name.empty()) {
401 subject_name.assign(
402 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
[email protected]03ef4b2a2012-03-06 15:04:20403 }
404
[email protected]f61c1ce2012-05-09 13:55:11405 cert_id_ = ssl.cert_id;
406
[email protected]3d6d34b12013-12-23 00:34:02407 if (ssl.cert_id && !ssl.signed_certificate_timestamp_ids.empty()) {
408 signed_certificate_timestamp_ids_.assign(
409 ssl.signed_certificate_timestamp_ids.begin(),
410 ssl.signed_certificate_timestamp_ids.end());
411 }
412
[email protected]03ef4b2a2012-03-06 15:04:20413 if (ssl.cert_id &&
414 cert_store_->RetrieveCert(ssl.cert_id, &cert) &&
415 (!net::IsCertStatusError(ssl.cert_status) ||
416 net::IsCertStatusMinorError(ssl.cert_status))) {
417 // There are no major errors. Check for minor errors.
[email protected]24a9f1c92013-11-13 12:33:37418#if defined(OS_CHROMEOS)
419 policy::PolicyCertService* service =
420 policy::PolicyCertServiceFactory::GetForProfile(profile);
421 const bool used_policy_certs = service && service->UsedPolicyCertificates();
422#else
423 const bool used_policy_certs = false;
424#endif
425 if (used_policy_certs) {
[email protected]eaf3f322013-04-25 21:53:59426 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37427 site_identity_details_ = l10n_util::GetStringFUTF16(
428 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
[email protected]eaf3f322013-04-25 21:53:59429 } else if (net::IsCertStatusMinorError(ssl.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20430 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
[email protected]a04db822013-12-11 19:14:40431 base::string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20432 if (issuer_name.empty()) {
433 issuer_name.assign(l10n_util::GetStringUTF16(
434 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
435 }
[email protected]94c74b42013-12-02 15:19:49436
[email protected]03ef4b2a2012-03-06 15:04:20437 site_identity_details_.assign(l10n_util::GetStringFUTF16(
[email protected]94c74b42013-12-02 15:19:49438 GetSiteIdentityDetailsMessageByCTInfo(
439 ssl.signed_certificate_timestamp_ids, false /* not EV */),
440 issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20441
442 site_identity_details_ += ASCIIToUTF16("\n\n");
443 if (ssl.cert_status & net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
444 site_identity_details_ += l10n_util::GetStringUTF16(
445 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
446 } else if (ssl.cert_status & net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
447 site_identity_details_ += l10n_util::GetStringUTF16(
448 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
449 } else {
450 NOTREACHED() << "Need to specify string for this warning";
451 }
[email protected]03ef4b2a2012-03-06 15:04:20452 } else {
rsleevi4f8012722014-09-30 01:28:01453 if (ssl.cert_status & net::CERT_STATUS_IS_EV) {
454 // EV HTTPS page.
455 site_identity_status_ = GetSiteIdentityStatusByCTInfo(
456 ssl.signed_certificate_timestamp_ids, true);
457 DCHECK(!cert->subject().organization_names.empty());
458 organization_name_ = UTF8ToUTF16(cert->subject().organization_names[0]);
459 // An EV Cert is required to have a city (localityName) and country but
460 // state is "if any".
461 DCHECK(!cert->subject().locality_name.empty());
462 DCHECK(!cert->subject().country_name.empty());
463 base::string16 locality;
464 if (!cert->subject().state_or_province_name.empty()) {
465 locality = l10n_util::GetStringFUTF16(
466 IDS_PAGEINFO_ADDRESS,
467 UTF8ToUTF16(cert->subject().locality_name),
468 UTF8ToUTF16(cert->subject().state_or_province_name),
469 UTF8ToUTF16(cert->subject().country_name));
470 } else {
471 locality = l10n_util::GetStringFUTF16(
472 IDS_PAGEINFO_PARTIAL_ADDRESS,
473 UTF8ToUTF16(cert->subject().locality_name),
474 UTF8ToUTF16(cert->subject().country_name));
475 }
476 DCHECK(!cert->subject().organization_names.empty());
477 site_identity_details_.assign(l10n_util::GetStringFUTF16(
478 GetSiteIdentityDetailsMessageByCTInfo(
479 ssl.signed_certificate_timestamp_ids, true /* is EV */),
480 UTF8ToUTF16(cert->subject().organization_names[0]),
481 locality,
482 UTF8ToUTF16(cert->issuer().GetDisplayName())));
483 } else {
484 // Non-EV OK HTTPS page.
485 site_identity_status_ = GetSiteIdentityStatusByCTInfo(
486 ssl.signed_certificate_timestamp_ids, false);
487 base::string16 issuer_name(
488 UTF8ToUTF16(cert->issuer().GetDisplayName()));
489 if (issuer_name.empty()) {
490 issuer_name.assign(l10n_util::GetStringUTF16(
491 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
492 }
[email protected]94c74b42013-12-02 15:19:49493
rsleevi4f8012722014-09-30 01:28:01494 site_identity_details_.assign(l10n_util::GetStringFUTF16(
495 GetSiteIdentityDetailsMessageByCTInfo(
496 ssl.signed_certificate_timestamp_ids, false /* not EV */),
497 issuer_name));
498 }
499 // The date after which no new SHA-1 certificates may be issued.
500 // 2016-01-01 00:00:00 UTC
501 static const int64_t kSHA1LastIssuanceDate = INT64_C(13096080000000000);
502 if ((ssl.cert_status & net::CERT_STATUS_SHA1_SIGNATURE_PRESENT) &&
503 cert->valid_expiry() >
504 base::Time::FromInternalValue(kSHA1LastIssuanceDate) &&
505 base::FieldTrialList::FindFullName("SHA1IdentityUIWarning") ==
506 "Enabled") {
507 site_identity_status_ =
508 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM;
509 site_identity_details_ +=
510 UTF8ToUTF16("\n\n") +
511 l10n_util::GetStringUTF16(
512 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM);
513 }
[email protected]03ef4b2a2012-03-06 15:04:20514 }
515 } else {
516 // HTTP or HTTPS with errors (not warnings).
517 site_identity_details_.assign(l10n_util::GetStringUTF16(
518 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
519 if (ssl.security_style == content::SECURITY_STYLE_UNAUTHENTICATED)
520 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
521 else
522 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
523
[email protected]a04db822013-12-11 19:14:40524 const base::string16 bullet = UTF8ToUTF16("\n • ");
[email protected]03ef4b2a2012-03-06 15:04:20525 std::vector<SSLErrorInfo> errors;
526 SSLErrorInfo::GetErrorsForCertStatus(ssl.cert_id, ssl.cert_status,
527 url, &errors);
528 for (size_t i = 0; i < errors.size(); ++i) {
529 site_identity_details_ += bullet;
530 site_identity_details_ += errors[i].short_description();
531 }
532
533 if (ssl.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
534 site_identity_details_ += ASCIIToUTF16("\n\n");
535 site_identity_details_ += l10n_util::GetStringUTF16(
536 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
537 }
538 }
539
540 // Site Connection
541 // We consider anything less than 80 bits encryption to be weak encryption.
542 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
543 // weakly encrypted connections.
544 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
545
[email protected]1c1051d2014-05-10 11:39:58546 if (ssl.security_style == content::SECURITY_STYLE_UNKNOWN) {
547 // Page is still loading, so SSL status is not yet available. Say nothing.
548 DCHECK_EQ(ssl.security_bits, -1);
549 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
550
551 site_connection_details_.assign(l10n_util::GetStringFUTF16(
552 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
553 subject_name));
554 } else if (ssl.security_style == content::SECURITY_STYLE_UNAUTHENTICATED) {
555 // HTTPS without a certificate, or not HTTPS.
556 DCHECK(!ssl.cert_id);
557 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
[email protected]03ef4b2a2012-03-06 15:04:20558
559 site_connection_details_.assign(l10n_util::GetStringFUTF16(
560 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
561 subject_name));
562 } else if (ssl.security_bits < 0) {
563 // Security strength is unknown. Say nothing.
564 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
565 } else if (ssl.security_bits == 0) {
566 DCHECK_NE(ssl.security_style, content::SECURITY_STYLE_UNAUTHENTICATED);
567 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
568 site_connection_details_.assign(l10n_util::GetStringFUTF16(
569 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
570 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20571 } else {
572 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22573
574 if (net::SSLConnectionStatusToVersion(ssl.connection_status) >=
575 net::SSL_CONNECTION_VERSION_TLS1_2 &&
576 net::IsSecureTLSCipherSuite(
577 net::SSLConnectionStatusToCipherSuite(ssl.connection_status))) {
578 site_connection_details_.assign(l10n_util::GetStringFUTF16(
579 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
580 subject_name));
581 } else {
582 site_connection_details_.assign(l10n_util::GetStringFUTF16(
583 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
584 subject_name));
585 }
586
[email protected]03ef4b2a2012-03-06 15:04:20587 if (ssl.content_status) {
588 bool ran_insecure_content =
589 !!(ssl.content_status & content::SSLStatus::RAN_INSECURE_CONTENT);
590 site_connection_status_ = ran_insecure_content ?
591 SITE_CONNECTION_STATUS_ENCRYPTED_ERROR
592 : SITE_CONNECTION_STATUS_MIXED_CONTENT;
593 site_connection_details_.assign(l10n_util::GetStringFUTF16(
594 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
595 site_connection_details_,
596 l10n_util::GetStringUTF16(ran_insecure_content ?
597 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR :
598 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
599 }
600 }
601
602 uint16 cipher_suite =
603 net::SSLConnectionStatusToCipherSuite(ssl.connection_status);
604 if (ssl.security_bits > 0 && cipher_suite) {
605 int ssl_version =
606 net::SSLConnectionStatusToVersion(ssl.connection_status);
607 const char* ssl_version_str;
608 net::SSLVersionToString(&ssl_version_str, ssl_version);
609 site_connection_details_ += ASCIIToUTF16("\n\n");
610 site_connection_details_ += l10n_util::GetStringFUTF16(
611 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION,
612 ASCIIToUTF16(ssl_version_str));
613
[email protected]03ef4b2a2012-03-06 15:04:20614 bool no_renegotiation =
615 (ssl.connection_status &
616 net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0;
617 const char *key_exchange, *cipher, *mac;
[email protected]b6c1d9e82013-06-12 17:26:57618 bool is_aead;
619 net::SSLCipherSuiteToStrings(
620 &key_exchange, &cipher, &mac, &is_aead, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20621
622 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57623 if (is_aead) {
624 site_connection_details_ += l10n_util::GetStringFUTF16(
625 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
626 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
627 } else {
628 site_connection_details_ += l10n_util::GetStringFUTF16(
629 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS,
630 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
631 }
[email protected]03ef4b2a2012-03-06 15:04:20632
agl078d2102014-10-20 22:03:22633 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 &&
634 site_connection_status_ < SITE_CONNECTION_STATUS_MIXED_CONTENT) {
635 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
636 }
637
638 const bool did_fallback =
639 (ssl.connection_status & net::SSL_CONNECTION_VERSION_FALLBACK) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20640 if (did_fallback) {
[email protected]03ef4b2a2012-03-06 15:04:20641 site_connection_details_ += ASCIIToUTF16("\n\n");
642 site_connection_details_ += l10n_util::GetStringUTF16(
643 IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE);
644 }
agl078d2102014-10-20 22:03:22645
[email protected]03ef4b2a2012-03-06 15:04:20646 if (no_renegotiation) {
647 site_connection_details_ += ASCIIToUTF16("\n\n");
648 site_connection_details_ += l10n_util::GetStringUTF16(
649 IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE);
650 }
651 }
[email protected]e583f752012-08-30 13:26:21652
[email protected]71cd5ef2014-08-13 21:22:04653 // Check if a user decision has been made to allow or deny certificates with
654 // errors on this site.
655 ChromeSSLHostStateDelegate* delegate =
656 ChromeSSLHostStateDelegateFactory::GetForProfile(profile);
657 DCHECK(delegate);
658 // Only show an SSL decision revoke button if both the user has chosen to
659 // bypass SSL host errors for this host in the past and the user is not using
660 // the traditional "forget-at-session-restart" error decision memory.
jww6a55df72014-09-05 19:59:29661 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host()) &&
662 InRememberCertificateErrorDecisionsGroup();
[email protected]71cd5ef2014-08-13 21:22:04663
[email protected]e583f752012-08-30 13:26:21664 // By default select the permissions tab that displays all the site
665 // permissions. In case of a connection error or an issue with the
666 // certificate presented by the website, select the connection tab to draw
667 // the user's attention to the issue. If the site does not provide a
668 // certificate because it was loaded over an unencrypted connection, don't
669 // select the connection tab.
670 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS;
671 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR ||
672 site_connection_status_ == SITE_CONNECTION_STATUS_MIXED_CONTENT ||
673 site_identity_status_ == SITE_IDENTITY_STATUS_ERROR ||
[email protected]eaf3f322013-04-25 21:53:59674 site_identity_status_ == SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN ||
rsleevi4f8012722014-09-30 01:28:01675 site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT ||
676 site_identity_status_ ==
lgarron04a93502014-11-04 22:25:04677 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM) {
[email protected]e583f752012-08-30 13:26:21678 tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION;
lgarron04a93502014-11-04 22:25:04679 RecordWebsiteSettingsAction(
680 WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY);
681 }
[email protected]e583f752012-08-30 13:26:21682 ui_->SetSelectedTab(tab_id);
[email protected]03ef4b2a2012-03-06 15:04:20683}
[email protected]0b9fdd72012-04-04 10:00:33684
[email protected]df818272012-04-20 13:10:50685void WebsiteSettings::PresentSitePermissions() {
686 PermissionInfoList permission_info_list;
687
688 WebsiteSettingsUI::PermissionInfo permission_info;
689 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
690 permission_info.type = kPermissionType[i];
[email protected]eb2140c2013-07-29 12:37:34691 if (permission_info.type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
avi556c05022014-12-22 23:31:43692 const base::CommandLine* command_line =
693 base::CommandLine::ForCurrentProcess();
[email protected]eb2140c2013-07-29 12:37:34694 if (!command_line->HasSwitch(switches::kEnableWebMIDI))
695 continue;
696 }
[email protected]df818272012-04-20 13:10:50697
698 content_settings::SettingInfo info;
[email protected]0bacc1912012-12-11 11:05:34699 if (permission_info.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) {
dhnishid5770d212014-09-18 21:59:18700 scoped_ptr<base::Value> mic_value =
701 content_settings_->GetWebsiteSettingWithoutOverride(
702 site_url_,
703 site_url_,
704 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
705 std::string(),
706 &info);
[email protected]0bacc1912012-12-11 11:05:34707 ContentSetting mic_setting =
708 content_settings::ValueToContentSetting(mic_value.get());
709
dhnishid5770d212014-09-18 21:59:18710 scoped_ptr<base::Value> camera_value =
711 content_settings_->GetWebsiteSettingWithoutOverride(
712 site_url_,
713 site_url_,
714 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
715 std::string(),
716 &info);
[email protected]0bacc1912012-12-11 11:05:34717 ContentSetting camera_setting =
718 content_settings::ValueToContentSetting(camera_value.get());
719
720 if (mic_setting != camera_setting || mic_setting == CONTENT_SETTING_ASK)
721 permission_info.setting = CONTENT_SETTING_DEFAULT;
722 else
723 permission_info.setting = mic_setting;
[email protected]fe4686a2012-10-19 15:38:26724 } else {
dhnishid5770d212014-09-18 21:59:18725 scoped_ptr<base::Value> value =
726 content_settings_->GetWebsiteSettingWithoutOverride(
727 site_url_, site_url_, permission_info.type, std::string(), &info);
[email protected]0bacc1912012-12-11 11:05:34728 DCHECK(value.get());
[email protected]2c95d102013-12-23 20:42:16729 if (value->GetType() == base::Value::TYPE_INTEGER) {
[email protected]0bacc1912012-12-11 11:05:34730 permission_info.setting =
731 content_settings::ValueToContentSetting(value.get());
732 } else {
733 NOTREACHED();
734 }
[email protected]fe4686a2012-10-19 15:38:26735 }
736
[email protected]8bdf45c32012-08-04 00:12:55737 permission_info.source = info.source;
[email protected]df818272012-04-20 13:10:50738
[email protected]b1d113d2012-06-27 21:27:34739 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
[email protected]0bacc1912012-12-11 11:05:34740 info.secondary_pattern == ContentSettingsPattern::Wildcard() &&
741 permission_info.type != CONTENT_SETTINGS_TYPE_MEDIASTREAM) {
[email protected]b1d113d2012-06-27 21:27:34742 permission_info.default_setting = permission_info.setting;
743 permission_info.setting = CONTENT_SETTING_DEFAULT;
744 } else {
745 permission_info.default_setting =
746 content_settings_->GetDefaultContentSetting(permission_info.type,
747 NULL);
[email protected]df818272012-04-20 13:10:50748 }
[email protected]b1d113d2012-06-27 21:27:34749 permission_info_list.push_back(permission_info);
[email protected]df818272012-04-20 13:10:50750 }
751
752 ui_->SetPermissionInfo(permission_info_list);
[email protected]0b9fdd72012-04-04 10:00:33753}
754
[email protected]df818272012-04-20 13:10:50755void WebsiteSettings::PresentSiteData() {
756 CookieInfoList cookie_info_list;
vabrd5e30cd2014-10-02 11:06:03757 const LocalSharedObjectsCounter& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34758 tab_specific_content_settings()->allowed_local_shared_objects();
vabrd5e30cd2014-10-02 11:06:03759 const LocalSharedObjectsCounter& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34760 tab_specific_content_settings()->blocked_local_shared_objects();
761
762 // Add first party cookie and site data counts.
[email protected]df818272012-04-20 13:10:50763 WebsiteSettingsUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34764 std::string cookie_source =
[email protected]ed32c212013-05-14 20:49:29765 net::registry_controlled_domains::GetDomainAndRegistry(
766 site_url_,
[email protected]aabe1792014-01-30 21:37:46767 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
[email protected]e0ac35892012-05-15 12:53:34768 if (cookie_source.empty())
769 cookie_source = site_url_.host();
770 cookie_info.cookie_source = cookie_source;
771 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
772 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
773 cookie_info_list.push_back(cookie_info);
774
775 // Add third party cookie counts.
776 cookie_info.cookie_source = l10n_util::GetStringUTF8(
777 IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA);
778 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
779 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
[email protected]df818272012-04-20 13:10:50780 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33781
[email protected]df818272012-04-20 13:10:50782 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33783}
[email protected]16de6de2012-04-04 12:24:14784
[email protected]24c8818c2012-04-25 09:57:41785void WebsiteSettings::PresentSiteIdentity() {
786 // After initialization the status about the site's connection
787 // and it's identity must be available.
788 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
789 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
790 WebsiteSettingsUI::IdentityInfo info;
791 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
792 info.site_identity = UTF16ToUTF8(organization_name());
793 else
794 info.site_identity = site_url_.host();
795
796 info.connection_status = site_connection_status_;
797 info.connection_status_description =
798 UTF16ToUTF8(site_connection_details_);
799 info.identity_status = site_identity_status_;
800 info.identity_status_description =
801 UTF16ToUTF8(site_identity_details_);
[email protected]f61c1ce2012-05-09 13:55:11802 info.cert_id = cert_id_;
[email protected]3d6d34b12013-12-23 00:34:02803 info.signed_certificate_timestamp_ids.assign(
804 signed_certificate_timestamp_ids_.begin(),
805 signed_certificate_timestamp_ids_.end());
[email protected]71cd5ef2014-08-13 21:22:04806 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
[email protected]24c8818c2012-04-25 09:57:41807 ui_->SetIdentityInfo(info);
808}
809
[email protected]15b092542012-05-16 13:08:14810void WebsiteSettings::PresentHistoryInfo(base::Time first_visit) {
811 if (first_visit == base::Time()) {
[email protected]b959d7d42013-12-13 17:26:37812 ui_->SetFirstVisit(base::string16());
[email protected]15b092542012-05-16 13:08:14813 return;
814 }
815
816 bool visited_before_today = false;
817 base::Time today = base::Time::Now().LocalMidnight();
818 base::Time first_visit_midnight = first_visit.LocalMidnight();
819 visited_before_today = (first_visit_midnight < today);
820
[email protected]a04db822013-12-11 19:14:40821 base::string16 first_visit_text;
[email protected]15b092542012-05-16 13:08:14822 if (visited_before_today) {
823 first_visit_text = l10n_util::GetStringFUTF16(
824 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY,
825 base::TimeFormatShortDate(first_visit));
826 } else {
827 first_visit_text = l10n_util::GetStringUTF16(
828 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY);
[email protected]15b092542012-05-16 13:08:14829 }
830 ui_->SetFirstVisit(first_visit_text);
831}