blob: 767fc98a18d67e12918414b24a5797d42d90ab39 [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]eb2140c2013-07-29 12:37:3410#include "base/command_line.h"
[email protected]15b092542012-05-16 13:08:1411#include "base/i18n/time_formatting.h"
[email protected]71cd5ef2014-08-13 21:22:0412#include "base/metrics/field_trial.h"
[email protected]3ea1b182013-02-08 22:38:4113#include "base/metrics/histogram.h"
14#include "base/strings/string_number_conversions.h"
jialiul02aad2d2015-04-01 18:56:0315#include "base/strings/stringprintf.h"
[email protected]774cc3c2013-06-07 20:26:4516#include "base/strings/utf_string_conversions.h"
[email protected]0b9fdd72012-04-04 10:00:3317#include "base/values.h"
jialiul02aad2d2015-04-01 18:56:0318#include "chrome/browser/browser_process.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"
peconn5100d432015-09-16 12:03:0825#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
[email protected]77a91c72012-08-13 16:19:3426#include "chrome/browser/history/history_service_factory.h"
palmerf2cba0d2015-08-27 23:15:0627#include "chrome/browser/infobars/infobar_service.h"
[email protected]03ef4b2a2012-03-06 15:04:2028#include "chrome/browser/profiles/profile.h"
[email protected]71cd5ef2014-08-13 21:22:0429#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
30#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.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"
palmer153af982015-09-15 02:04:1933#include "chrome/common/pref_names.h"
jsbellddb849e2015-08-27 00:12:5634#include "chrome/common/url_constants.h"
thestig884a1602014-08-27 01:29:3935#include "chrome/grit/chromium_strings.h"
36#include "chrome/grit/generated_resources.h"
mukai8eaec822014-10-25 17:53:1637#include "components/content_settings/core/browser/content_settings_utils.h"
38#include "components/content_settings/core/browser/host_content_settings_map.h"
vabr48565592014-10-08 15:06:0239#include "components/content_settings/core/browser/local_shared_objects_counter.h"
palmer0da10b32015-02-11 00:42:1940#include "components/content_settings/core/common/content_settings.h"
vasiliif62dbf92014-09-05 10:23:1341#include "components/content_settings/core/common/content_settings_pattern.h"
jialiul02aad2d2015-04-01 18:56:0342#include "components/rappor/rappor_utils.h"
felt2493b4452015-09-17 20:33:5943#include "components/ssl_errors/error_info.h"
palmer153af982015-09-15 02:04:1944#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3345#include "content/public/browser/browser_thread.h"
[email protected]b59c6cf02012-03-12 20:51:4246#include "content/public/browser/cert_store.h"
[email protected]e22d64f2012-09-10 09:03:2347#include "content/public/browser/user_metrics.h"
[email protected]eb2140c2013-07-29 12:37:3448#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2049#include "content/public/common/url_constants.h"
[email protected]6e7845ae2013-03-29 21:48:1150#include "net/cert/cert_status_flags.h"
51#include "net/cert/x509_certificate.h"
[email protected]536fd0b2013-03-14 17:41:5752#include "net/ssl/ssl_cipher_suite_names.h"
53#include "net/ssl/ssl_connection_status_flags.h"
[email protected]03ef4b2a2012-03-06 15:04:2054#include "ui/base/l10n/l10n_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2055
[email protected]24a9f1c92013-11-13 12:33:3756#if defined(OS_CHROMEOS)
57#include "chrome/browser/chromeos/policy/policy_cert_service.h"
58#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
59#endif
60
estade3feb83f2015-09-01 23:00:4961#if !defined(OS_ANDROID)
62#include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h"
63#endif
64
[email protected]ab6df3b12013-12-24 23:32:2665using base::ASCIIToUTF16;
66using base::UTF8ToUTF16;
[email protected]f729d7a2013-12-26 07:07:5667using base::UTF16ToUTF8;
[email protected]0b9fdd72012-04-04 10:00:3368using content::BrowserThread;
69
70namespace {
71
jww1ed8ea72014-09-02 20:43:2572// Events for UMA. Do not reorder or change!
73enum SSLCertificateDecisionsDidRevoke {
74 USER_CERT_DECISIONS_NOT_REVOKED = 0,
75 USER_CERT_DECISIONS_REVOKED,
76 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM
77};
78
palmer0da10b32015-02-11 00:42:1979// The list of content settings types to display on the Website Settings UI. THE
80// ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, email
81// [email protected].
[email protected]0b9fdd72012-04-04 10:00:3382ContentSettingsType kPermissionType[] = {
sashab2b2a314f2015-01-17 06:42:2183 CONTENT_SETTINGS_TYPE_GEOLOCATION,
sashab2b2a314f2015-01-17 06:42:2184 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
85 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
palmer0da10b32015-02-11 00:42:1986 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
87 CONTENT_SETTINGS_TYPE_IMAGES,
88 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
89 CONTENT_SETTINGS_TYPE_POPUPS,
90 CONTENT_SETTINGS_TYPE_FULLSCREEN,
sashab2b2a314f2015-01-17 06:42:2191 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
palmer0da10b32015-02-11 00:42:1992 CONTENT_SETTINGS_TYPE_PLUGINS,
93 CONTENT_SETTINGS_TYPE_MOUSELOCK,
sashab2b2a314f2015-01-17 06:42:2194 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
benwellsa68ed4b2014-11-13 03:25:3695#if defined(OS_ANDROID)
sashab2b2a314f2015-01-17 06:42:2196 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
benwellsa68ed4b2014-11-13 03:25:3697#endif
[email protected]0b9fdd72012-04-04 10:00:3398};
99
[email protected]94c74b42013-12-02 15:19:49100bool CertificateTransparencyStatusMatch(
estarka3121f6b2015-09-18 21:15:59101 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49102 net::ct::SCTVerifyStatus status) {
estarka3121f6b2015-09-18 21:15:59103 for (const auto& verify_status : sct_verify_statuses) {
104 if (verify_status == status)
[email protected]94c74b42013-12-02 15:19:49105 return true;
106 }
[email protected]94c74b42013-12-02 15:19:49107 return false;
108}
109
110int GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59111 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49112 bool is_ev) {
113 // No SCTs - no CT information.
estarka3121f6b2015-09-18 21:15:59114 if (sct_verify_statuses.empty())
[email protected]94c74b42013-12-02 15:19:49115 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_NO_CT
116 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_NO_CT);
117
estarka3121f6b2015-09-18 21:15:59118 if (CertificateTransparencyStatusMatch(sct_verify_statuses,
119 net::ct::SCT_STATUS_OK))
[email protected]94c74b42013-12-02 15:19:49120 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_VERIFIED
121 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_VERIFIED);
122
estarka3121f6b2015-09-18 21:15:59123 if (CertificateTransparencyStatusMatch(sct_verify_statuses,
124 net::ct::SCT_STATUS_INVALID))
[email protected]94c74b42013-12-02 15:19:49125 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_INVALID
126 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_INVALID);
127
128 // status is SCT_STATUS_LOG_UNKNOWN
129 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_UNVERIFIED
130 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_UNVERIFIED);
131}
132
133// This function will return SITE_IDENTITY_STATUS_CERT or
134// SITE_IDENTITY_STATUS_EV_CERT depending on |is_ev| unless there are SCTs
135// which failed verification, in which case it will return
136// SITE_IDENTITY_STATUS_ERROR.
137WebsiteSettings::SiteIdentityStatus GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59138 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49139 bool is_ev) {
estarka3121f6b2015-09-18 21:15:59140 if (CertificateTransparencyStatusMatch(sct_verify_statuses,
141 net::ct::SCT_STATUS_INVALID))
[email protected]94c74b42013-12-02 15:19:49142 return WebsiteSettings::SITE_IDENTITY_STATUS_ERROR;
143
144 return is_ev ? WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT
145 : WebsiteSettings::SITE_IDENTITY_STATUS_CERT;
146}
147
palmer153af982015-09-15 02:04:19148base::string16 GetSimpleSiteName(const GURL& url, Profile* profile) {
149 std::string languages;
150 if (profile)
151 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
152 return url_formatter::FormatUrlForSecurityDisplayOmitScheme(url, languages);
153}
154
[email protected]0b9fdd72012-04-04 10:00:33155} // namespace
156
157WebsiteSettings::WebsiteSettings(
158 WebsiteSettingsUI* ui,
159 Profile* profile,
[email protected]df818272012-04-20 13:10:50160 TabSpecificContentSettings* tab_specific_content_settings,
palmerf2cba0d2015-08-27 23:15:06161 content::WebContents* web_contents,
[email protected]0b9fdd72012-04-04 10:00:33162 const GURL& url,
estarka3121f6b2015-09-18 21:15:59163 const SecurityStateModel::SecurityInfo& security_info,
[email protected]0b9fdd72012-04-04 10:00:33164 content::CertStore* cert_store)
[email protected]df818272012-04-20 13:10:50165 : TabSpecificContentSettings::SiteDataObserver(
166 tab_specific_content_settings),
167 ui_(ui),
palmerf2cba0d2015-08-27 23:15:06168 web_contents_(web_contents),
[email protected]66f157312012-08-01 13:50:26169 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33170 site_url_(url),
171 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]f61c1ce2012-05-09 13:55:11172 cert_id_(0),
[email protected]03ef4b2a2012-03-06 15:04:20173 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
[email protected]0b9fdd72012-04-04 10:00:33174 cert_store_(cert_store),
peconn5100d432015-09-16 12:03:08175 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04176 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25177 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19178 did_revoke_user_ssl_decisions_(false),
179 profile_(profile) {
estarka3121f6b2015-09-18 21:15:59180 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33181
182 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50183 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41184 PresentSiteIdentity();
[email protected]e22d64f2012-09-10 09:03:23185
186 // Every time the Website Settings UI is opened a |WebsiteSettings| object is
187 // created. So this counts how ofter the Website Settings UI is opened.
lgarron04a93502014-11-04 22:25:04188 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20189}
190
[email protected]0b9fdd72012-04-04 10:00:33191WebsiteSettings::~WebsiteSettings() {
[email protected]03ef4b2a2012-03-06 15:04:20192}
193
lgarron04a93502014-11-04 22:25:04194void WebsiteSettings::RecordWebsiteSettingsAction(
195 WebsiteSettingsAction action) {
196 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action",
197 action,
198 WEBSITE_SETTINGS_COUNT);
199
200 // Use a separate histogram to record actions if they are done on a page with
201 // an HTTPS URL. Note that this *disregards* security status.
palmeree0e5af2015-06-05 03:10:40202 //
203
204 // TODO(palmer): Consider adding a new histogram for
205 // GURL::SchemeIsCryptographic. (We don't want to replace this call with a
206 // call to that function because we don't want to change the meanings of
207 // existing metrics.) This would inform the decision to mark non-secure
208 // origins as Dubious or Non-Secure; the overall bug for that is
209 // crbug.com/454579.
lgarron04a93502014-11-04 22:25:04210 if (site_url_.SchemeIs(url::kHttpsScheme)) {
211 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action.HttpsUrl",
212 action,
213 WEBSITE_SETTINGS_COUNT);
214 }
215}
216
raymes9d48b07b2015-10-19 04:32:35217// Get corresponding Rappor Metric. TODO(raymes): This should use the same
218// code that's in permission_context_uma_util.cc. Figure out how to do that.
219// crbug.com/544745.
jialiul02aad2d2015-04-01 18:56:03220const std::string GetRapporMetric(ContentSettingsType permission) {
221 std::string permission_str;
raymes9d48b07b2015-10-19 04:32:35222
223 if (permission == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
224 permission_str = "Geolocation";
225 } else if (permission == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
226 permission_str = "Notifications";
227 } else if (permission == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) {
228 permission_str = "Mic";
229 } else if (permission == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) {
230 permission_str = "Camera";
jialiul02aad2d2015-04-01 18:56:03231 }
232
233 return base::StringPrintf("ContentSettings.PermissionActions_%s.Revoked.Url",
234 permission_str.c_str());
235}
lgarron04a93502014-11-04 22:25:04236
[email protected]df818272012-04-20 13:10:50237void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type,
238 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23239 // Count how often a permission for a specific content type is changed using
240 // the Website Settings UI.
raymes4a13d432015-09-08 00:44:07241 size_t num_values;
242 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
sashab9debecd2014-12-18 04:15:56243 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.OriginInfo.PermissionChanged",
raymes4a13d432015-09-08 00:44:07244 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56245
246 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
247 UMA_HISTOGRAM_ENUMERATION(
248 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07249 num_values);
sashab9debecd2014-12-18 04:15:56250 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
251 UMA_HISTOGRAM_ENUMERATION(
252 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07253 num_values);
jialiul02aad2d2015-04-01 18:56:03254 // Trigger Rappor sampling if it is a permission revoke action.
255 const std::string& rappor_metric = GetRapporMetric(type);
256 if (!rappor_metric.empty()) {
257 rappor::SampleDomainAndRegistryFromGURL(
258 g_browser_process->rappor_service(), rappor_metric, this->site_url_);
259 }
sashab9debecd2014-12-18 04:15:56260 }
[email protected]e22d64f2012-09-10 09:03:23261
lgarron04a93502014-11-04 22:25:04262 // This is technically redundant given the histogram above, but putting the
263 // total count of permission changes in another histogram makes it easier to
264 // compare it against other kinds of actions in WebsiteSettings[PopupView].
265 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_CHANGED_PERMISSION);
266
raymes9d48b07b2015-10-19 04:32:35267 // TODO(raymes): The scoping here should be a property of ContentSettingsInfo.
268 // Make this happen! crbug.com/444742.
[email protected]df818272012-04-20 13:10:50269 ContentSettingsPattern primary_pattern;
270 ContentSettingsPattern secondary_pattern;
raymes9d48b07b2015-10-19 04:32:35271 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION ||
272 type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX ||
273 type == CONTENT_SETTINGS_TYPE_FULLSCREEN) {
274 // TODO(markusheintz): The rule we create here should also change the
275 // location permission for iframed content.
276 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_);
277 secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_);
278 } else if (type == CONTENT_SETTINGS_TYPE_IMAGES ||
279 type == CONTENT_SETTINGS_TYPE_JAVASCRIPT ||
280 type == CONTENT_SETTINGS_TYPE_PLUGINS ||
281 type == CONTENT_SETTINGS_TYPE_POPUPS ||
282 type == CONTENT_SETTINGS_TYPE_MOUSELOCK ||
283 type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS ||
284 type == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING) {
285 primary_pattern = ContentSettingsPattern::FromURL(site_url_);
286 secondary_pattern = ContentSettingsPattern::Wildcard();
287 } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
288 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA ||
289 type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
290 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_);
291 secondary_pattern = ContentSettingsPattern::Wildcard();
292 } else {
293 NOTREACHED() << "ContentSettingsType " << type << "is not supported.";
[email protected]0b9fdd72012-04-04 10:00:33294 }
295
jialiul02aad2d2015-04-01 18:56:03296 // Permission settings are specified via rules. There exists always at least
297 // one rule for the default setting. Get the rule that currently defines
298 // the permission for the given permission |type|. Then test whether the
299 // existing rule is more specific than the rule we are about to create. If
300 // the existing rule is more specific, than change the existing rule instead
301 // of creating a new rule that would be hidden behind the existing rule.
302 content_settings::SettingInfo info;
303 scoped_ptr<base::Value> v =
raymes7dec6d862015-07-27 07:02:08304 content_settings_->GetWebsiteSetting(
jialiul02aad2d2015-04-01 18:56:03305 site_url_, site_url_, type, std::string(), &info);
306 content_settings_->SetNarrowestWebsiteSetting(
307 primary_pattern, secondary_pattern, type, std::string(), setting, info);
[email protected]df818272012-04-20 13:10:50308
[email protected]66f157312012-08-01 13:50:26309 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24310
[email protected]2f45d542012-08-22 08:47:24311 // Refresh the UI to reflect the new setting.
312 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50313}
314
315void WebsiteSettings::OnSiteDataAccessed() {
316 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33317}
318
[email protected]66f157312012-08-01 13:50:26319void WebsiteSettings::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49320#if defined(OS_ANDROID)
321 NOTREACHED();
322#else
palmerf2cba0d2015-08-27 23:15:06323 if (show_info_bar_ && web_contents_) {
324 InfoBarService* infobar_service =
325 InfoBarService::FromWebContents(web_contents_);
326 if (infobar_service)
327 WebsiteSettingsInfoBarDelegate::Create(infobar_service);
328 }
jww1ed8ea72014-09-02 20:43:25329
330 SSLCertificateDecisionsDidRevoke user_decision =
331 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
332 : USER_CERT_DECISIONS_NOT_REVOKED;
333
334 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
335 user_decision,
336 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49337#endif
jww1ed8ea72014-09-02 20:43:25338}
339
340void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() {
341 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29342 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
343 site_url().host());
jww1ed8ea72014-09-02 20:43:25344 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26345}
346
estarka3121f6b2015-09-18 21:15:59347void WebsiteSettings::Init(
348 const GURL& url,
349 const SecurityStateModel::SecurityInfo& security_info) {
sashab97894ce2014-10-22 10:08:33350 bool isChromeUINativeScheme = false;
351#if defined(OS_ANDROID)
352 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
353#endif
354
355 if (url.SchemeIs(content::kChromeUIScheme) ||
356 url.SchemeIs(url::kAboutScheme) || isChromeUINativeScheme) {
[email protected]03ef4b2a2012-03-06 15:04:20357 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
358 site_identity_details_ =
359 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
360 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
361 return;
362 }
363
[email protected]03ef4b2a2012-03-06 15:04:20364 // Identity section.
palmer153af982015-09-15 02:04:19365 scoped_refptr<net::X509Certificate> cert;
estarka3121f6b2015-09-18 21:15:59366 cert_id_ = security_info.cert_id;
[email protected]f61c1ce2012-05-09 13:55:11367
estarka3121f6b2015-09-18 21:15:59368 // HTTPS with no or minor errors.
369 if (security_info.cert_id &&
370 cert_store_->RetrieveCert(security_info.cert_id, &cert) &&
371 (!net::IsCertStatusError(security_info.cert_status) ||
372 net::IsCertStatusMinorError(security_info.cert_status))) {
[email protected]03ef4b2a2012-03-06 15:04:20373 // There are no major errors. Check for minor errors.
estarka3121f6b2015-09-18 21:15:59374 if (security_info.security_level ==
375 SecurityStateModel::SECURITY_POLICY_WARNING) {
[email protected]eaf3f322013-04-25 21:53:59376 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37377 site_identity_details_ = l10n_util::GetStringFUTF16(
378 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59379 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20380 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
[email protected]a04db822013-12-11 19:14:40381 base::string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20382 if (issuer_name.empty()) {
383 issuer_name.assign(l10n_util::GetStringUTF16(
384 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
385 }
[email protected]94c74b42013-12-02 15:19:49386
[email protected]03ef4b2a2012-03-06 15:04:20387 site_identity_details_.assign(l10n_util::GetStringFUTF16(
[email protected]94c74b42013-12-02 15:19:49388 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59389 security_info.sct_verify_statuses, false /* not EV */),
[email protected]94c74b42013-12-02 15:19:49390 issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20391
392 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59393 if (security_info.cert_status &
394 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20395 site_identity_details_ += l10n_util::GetStringUTF16(
396 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59397 } else if (security_info.cert_status &
398 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20399 site_identity_details_ += l10n_util::GetStringUTF16(
400 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
401 } else {
402 NOTREACHED() << "Need to specify string for this warning";
403 }
[email protected]03ef4b2a2012-03-06 15:04:20404 } else {
estarka3121f6b2015-09-18 21:15:59405 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01406 // EV HTTPS page.
407 site_identity_status_ = GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59408 security_info.sct_verify_statuses, true);
rsleevi4f8012722014-09-30 01:28:01409 DCHECK(!cert->subject().organization_names.empty());
410 organization_name_ = UTF8ToUTF16(cert->subject().organization_names[0]);
411 // An EV Cert is required to have a city (localityName) and country but
412 // state is "if any".
413 DCHECK(!cert->subject().locality_name.empty());
414 DCHECK(!cert->subject().country_name.empty());
415 base::string16 locality;
416 if (!cert->subject().state_or_province_name.empty()) {
417 locality = l10n_util::GetStringFUTF16(
418 IDS_PAGEINFO_ADDRESS,
419 UTF8ToUTF16(cert->subject().locality_name),
420 UTF8ToUTF16(cert->subject().state_or_province_name),
421 UTF8ToUTF16(cert->subject().country_name));
422 } else {
423 locality = l10n_util::GetStringFUTF16(
424 IDS_PAGEINFO_PARTIAL_ADDRESS,
425 UTF8ToUTF16(cert->subject().locality_name),
426 UTF8ToUTF16(cert->subject().country_name));
427 }
428 DCHECK(!cert->subject().organization_names.empty());
429 site_identity_details_.assign(l10n_util::GetStringFUTF16(
430 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59431 security_info.sct_verify_statuses, true /* is EV */),
432 UTF8ToUTF16(cert->subject().organization_names[0]), locality,
rsleevi4f8012722014-09-30 01:28:01433 UTF8ToUTF16(cert->issuer().GetDisplayName())));
434 } else {
435 // Non-EV OK HTTPS page.
436 site_identity_status_ = GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59437 security_info.sct_verify_statuses, false);
rsleevi4f8012722014-09-30 01:28:01438 base::string16 issuer_name(
439 UTF8ToUTF16(cert->issuer().GetDisplayName()));
440 if (issuer_name.empty()) {
441 issuer_name.assign(l10n_util::GetStringUTF16(
442 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
443 }
[email protected]94c74b42013-12-02 15:19:49444
rsleevi4f8012722014-09-30 01:28:01445 site_identity_details_.assign(l10n_util::GetStringFUTF16(
446 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59447 security_info.sct_verify_statuses, false /* not EV */),
rsleevi4f8012722014-09-30 01:28:01448 issuer_name));
449 }
lgarroncc53de22015-10-05 23:03:17450 switch (security_info.sha1_deprecation_status) {
451 case SecurityStateModel::DEPRECATED_SHA1_MINOR:
452 site_identity_status_ =
453 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR;
454 site_identity_details_ +=
455 UTF8ToUTF16("\n\n") +
456 l10n_util::GetStringUTF16(
457 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MINOR);
458 break;
459 case SecurityStateModel::DEPRECATED_SHA1_MAJOR:
460 site_identity_status_ =
461 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR;
462 site_identity_details_ +=
463 UTF8ToUTF16("\n\n") +
464 l10n_util::GetStringUTF16(
465 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR);
466 break;
467 case SecurityStateModel::NO_DEPRECATED_SHA1:
468 // Nothing to do.
469 break;
rsleevi4f8012722014-09-30 01:28:01470 }
[email protected]03ef4b2a2012-03-06 15:04:20471 }
472 } else {
473 // HTTP or HTTPS with errors (not warnings).
474 site_identity_details_.assign(l10n_util::GetStringUTF16(
475 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
estarka3121f6b2015-09-18 21:15:59476 if (!security_info.scheme_is_cryptographic || !security_info.cert_id)
[email protected]03ef4b2a2012-03-06 15:04:20477 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
478 else
479 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
480
[email protected]a04db822013-12-11 19:14:40481 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59482 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59483 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
484 cert, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20485 for (size_t i = 0; i < errors.size(); ++i) {
486 site_identity_details_ += bullet;
487 site_identity_details_ += errors[i].short_description();
488 }
489
estarka3121f6b2015-09-18 21:15:59490 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20491 site_identity_details_ += ASCIIToUTF16("\n\n");
492 site_identity_details_ += l10n_util::GetStringUTF16(
493 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
494 }
495 }
496
497 // Site Connection
498 // We consider anything less than 80 bits encryption to be weak encryption.
499 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
500 // weakly encrypted connections.
501 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
502
palmer153af982015-09-15 02:04:19503 base::string16 subject_name(GetSimpleSiteName(url, profile_));
504 if (subject_name.empty()) {
505 subject_name.assign(
506 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
507 }
508
estarka3121f6b2015-09-18 21:15:59509 if (!security_info.cert_id || !security_info.scheme_is_cryptographic) {
510 // Page is still loading (so SSL status is not yet available) or
511 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58512 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
513
514 site_connection_details_.assign(l10n_util::GetStringFUTF16(
515 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
516 subject_name));
estarka3121f6b2015-09-18 21:15:59517 } else if (security_info.security_bits < 0) {
518 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20519 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59520 } else if (security_info.security_bits == 0) {
521 DCHECK_NE(security_info.security_level, SecurityStateModel::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20522 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
523 site_connection_details_.assign(l10n_util::GetStringFUTF16(
524 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
525 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20526 } else {
527 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22528
estarka3121f6b2015-09-18 21:15:59529 if (net::SSLConnectionStatusToVersion(security_info.connection_status) >=
Adam Langley71c2b59b2014-11-13 00:34:22530 net::SSL_CONNECTION_VERSION_TLS1_2 &&
estarka3121f6b2015-09-18 21:15:59531 net::IsSecureTLSCipherSuite(net::SSLConnectionStatusToCipherSuite(
532 security_info.connection_status))) {
Adam Langley71c2b59b2014-11-13 00:34:22533 site_connection_details_.assign(l10n_util::GetStringFUTF16(
534 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
535 subject_name));
536 } else {
537 site_connection_details_.assign(l10n_util::GetStringFUTF16(
538 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
539 subject_name));
540 }
541
estarka3121f6b2015-09-18 21:15:59542 if (security_info.mixed_content_status !=
543 SecurityStateModel::NO_MIXED_CONTENT) {
[email protected]03ef4b2a2012-03-06 15:04:20544 bool ran_insecure_content =
estarka3121f6b2015-09-18 21:15:59545 (security_info.mixed_content_status ==
546 SecurityStateModel::RAN_MIXED_CONTENT ||
547 security_info.mixed_content_status ==
548 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT);
palmercc7f5f8c2015-09-04 01:02:59549 site_connection_status_ = ran_insecure_content
550 ? SITE_CONNECTION_STATUS_MIXED_SCRIPT
551 : SITE_CONNECTION_STATUS_MIXED_CONTENT;
[email protected]03ef4b2a2012-03-06 15:04:20552 site_connection_details_.assign(l10n_util::GetStringFUTF16(
553 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
554 site_connection_details_,
555 l10n_util::GetStringUTF16(ran_insecure_content ?
556 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR :
557 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
558 }
559 }
560
561 uint16 cipher_suite =
estarka3121f6b2015-09-18 21:15:59562 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
563 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20564 int ssl_version =
estarka3121f6b2015-09-18 21:15:59565 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20566 const char* ssl_version_str;
567 net::SSLVersionToString(&ssl_version_str, ssl_version);
568 site_connection_details_ += ASCIIToUTF16("\n\n");
569 site_connection_details_ += l10n_util::GetStringFUTF16(
570 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION,
571 ASCIIToUTF16(ssl_version_str));
572
[email protected]03ef4b2a2012-03-06 15:04:20573 bool no_renegotiation =
estarka3121f6b2015-09-18 21:15:59574 (security_info.connection_status &
575 net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20576 const char *key_exchange, *cipher, *mac;
[email protected]b6c1d9e82013-06-12 17:26:57577 bool is_aead;
578 net::SSLCipherSuiteToStrings(
579 &key_exchange, &cipher, &mac, &is_aead, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20580
581 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57582 if (is_aead) {
583 site_connection_details_ += l10n_util::GetStringFUTF16(
584 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
585 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
586 } else {
587 site_connection_details_ += l10n_util::GetStringFUTF16(
588 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS,
589 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
590 }
[email protected]03ef4b2a2012-03-06 15:04:20591
agl078d2102014-10-20 22:03:22592 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 &&
593 site_connection_status_ < SITE_CONNECTION_STATUS_MIXED_CONTENT) {
594 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
595 }
596
estarka3121f6b2015-09-18 21:15:59597 const bool did_fallback = (security_info.connection_status &
598 net::SSL_CONNECTION_VERSION_FALLBACK) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20599 if (did_fallback) {
[email protected]03ef4b2a2012-03-06 15:04:20600 site_connection_details_ += ASCIIToUTF16("\n\n");
601 site_connection_details_ += l10n_util::GetStringUTF16(
602 IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE);
603 }
agl078d2102014-10-20 22:03:22604
[email protected]03ef4b2a2012-03-06 15:04:20605 if (no_renegotiation) {
606 site_connection_details_ += ASCIIToUTF16("\n\n");
607 site_connection_details_ += l10n_util::GetStringUTF16(
608 IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE);
609 }
610 }
[email protected]e583f752012-08-30 13:26:21611
[email protected]71cd5ef2014-08-13 21:22:04612 // Check if a user decision has been made to allow or deny certificates with
613 // errors on this site.
614 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50615 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04616 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40617 // Only show an SSL decision revoke button if the user has chosen to bypass
618 // SSL host errors for this host in the past.
619 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]71cd5ef2014-08-13 21:22:04620
palmer82b1f7b2015-09-17 19:20:41621 // By default select the Permissions Tab that displays all the site
622 // permissions. In case of a connection error or an issue with the certificate
623 // presented by the website, select the Connection Tab to draw the user's
624 // attention to the issue. If the site does not provide a certificate because
625 // it was loaded over an unencrypted connection, don't select the Connection
626 // Tab.
[email protected]e583f752012-08-30 13:26:21627 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS;
628 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR ||
629 site_connection_status_ == SITE_CONNECTION_STATUS_MIXED_CONTENT ||
estarkf62683e2015-09-17 17:52:06630 site_connection_status_ == SITE_CONNECTION_STATUS_MIXED_SCRIPT ||
[email protected]e583f752012-08-30 13:26:21631 site_identity_status_ == SITE_IDENTITY_STATUS_ERROR ||
[email protected]eaf3f322013-04-25 21:53:59632 site_identity_status_ == SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN ||
rsleevi4f8012722014-09-30 01:28:01633 site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT ||
634 site_identity_status_ ==
lgarroncc53de22015-10-05 23:03:17635 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR ||
636 site_identity_status_ ==
637 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR) {
[email protected]e583f752012-08-30 13:26:21638 tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION;
lgarron04a93502014-11-04 22:25:04639 RecordWebsiteSettingsAction(
640 WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY);
641 }
palmer82b1f7b2015-09-17 19:20:41642
[email protected]e583f752012-08-30 13:26:21643 ui_->SetSelectedTab(tab_id);
[email protected]03ef4b2a2012-03-06 15:04:20644}
[email protected]0b9fdd72012-04-04 10:00:33645
[email protected]df818272012-04-20 13:10:50646void WebsiteSettings::PresentSitePermissions() {
647 PermissionInfoList permission_info_list;
648
649 WebsiteSettingsUI::PermissionInfo permission_info;
650 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
651 permission_info.type = kPermissionType[i];
652
653 content_settings::SettingInfo info;
sashab2b2a314f2015-01-17 06:42:21654 scoped_ptr<base::Value> value =
raymes7dec6d862015-07-27 07:02:08655 content_settings_->GetWebsiteSetting(
sashab2b2a314f2015-01-17 06:42:21656 site_url_, site_url_, permission_info.type, std::string(), &info);
657 DCHECK(value.get());
658 if (value->GetType() == base::Value::TYPE_INTEGER) {
659 permission_info.setting =
660 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26661 } else {
sashab2b2a314f2015-01-17 06:42:21662 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26663 }
664
[email protected]8bdf45c32012-08-04 00:12:55665 permission_info.source = info.source;
[email protected]df818272012-04-20 13:10:50666
[email protected]b1d113d2012-06-27 21:27:34667 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21668 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34669 permission_info.default_setting = permission_info.setting;
670 permission_info.setting = CONTENT_SETTING_DEFAULT;
671 } else {
672 permission_info.default_setting =
673 content_settings_->GetDefaultContentSetting(permission_info.type,
674 NULL);
[email protected]df818272012-04-20 13:10:50675 }
palmer0da10b32015-02-11 00:42:19676
677 if (permission_info.setting != CONTENT_SETTING_DEFAULT &&
678 permission_info.setting != permission_info.default_setting) {
679 permission_info_list.push_back(permission_info);
680 }
[email protected]df818272012-04-20 13:10:50681 }
682
683 ui_->SetPermissionInfo(permission_info_list);
[email protected]0b9fdd72012-04-04 10:00:33684}
685
[email protected]df818272012-04-20 13:10:50686void WebsiteSettings::PresentSiteData() {
687 CookieInfoList cookie_info_list;
vabrd5e30cd2014-10-02 11:06:03688 const LocalSharedObjectsCounter& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34689 tab_specific_content_settings()->allowed_local_shared_objects();
vabrd5e30cd2014-10-02 11:06:03690 const LocalSharedObjectsCounter& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34691 tab_specific_content_settings()->blocked_local_shared_objects();
692
693 // Add first party cookie and site data counts.
[email protected]df818272012-04-20 13:10:50694 WebsiteSettingsUI::CookieInfo cookie_info;
palmerb145264922015-08-28 23:53:15695 cookie_info.cookie_source =
696 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_FIRST_PARTY_SITE_DATA);
[email protected]e0ac35892012-05-15 12:53:34697 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
698 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15699 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34700 cookie_info_list.push_back(cookie_info);
701
702 // Add third party cookie counts.
703 cookie_info.cookie_source = l10n_util::GetStringUTF8(
704 IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA);
705 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
706 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15707 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50708 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33709
[email protected]df818272012-04-20 13:10:50710 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33711}
[email protected]16de6de2012-04-04 12:24:14712
[email protected]24c8818c2012-04-25 09:57:41713void WebsiteSettings::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04714 // After initialization the status about the site's connection and its
715 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41716 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
717 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
718 WebsiteSettingsUI::IdentityInfo info;
719 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
720 info.site_identity = UTF16ToUTF8(organization_name());
721 else
palmer153af982015-09-15 02:04:19722 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_, profile_));
[email protected]24c8818c2012-04-25 09:57:41723
724 info.connection_status = site_connection_status_;
725 info.connection_status_description =
726 UTF16ToUTF8(site_connection_details_);
727 info.identity_status = site_identity_status_;
728 info.identity_status_description =
729 UTF16ToUTF8(site_identity_details_);
[email protected]f61c1ce2012-05-09 13:55:11730 info.cert_id = cert_id_;
[email protected]71cd5ef2014-08-13 21:22:04731 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
[email protected]24c8818c2012-04-25 09:57:41732 ui_->SetIdentityInfo(info);
733}