blob: 6f817da72787f5c51510c2d1cf38a475e3b78390 [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
avi655876a2015-12-25 07:18:157#include <stddef.h>
8#include <stdint.h>
9
[email protected]03ef4b2a2012-03-06 15:04:2010#include <string>
11#include <vector>
12
[email protected]eb2140c2013-07-29 12:37:3413#include "base/command_line.h"
[email protected]15b092542012-05-16 13:08:1414#include "base/i18n/time_formatting.h"
avi655876a2015-12-25 07:18:1515#include "base/macros.h"
[email protected]71cd5ef2014-08-13 21:22:0416#include "base/metrics/field_trial.h"
[email protected]3ea1b182013-02-08 22:38:4117#include "base/metrics/histogram.h"
18#include "base/strings/string_number_conversions.h"
jialiul02aad2d2015-04-01 18:56:0319#include "base/strings/stringprintf.h"
[email protected]774cc3c2013-06-07 20:26:4520#include "base/strings/utf_string_conversions.h"
[email protected]0b9fdd72012-04-04 10:00:3321#include "base/values.h"
avi655876a2015-12-25 07:18:1522#include "build/build_config.h"
jialiul02aad2d2015-04-01 18:56:0323#include "chrome/browser/browser_process.h"
[email protected]6b8a3c742014-07-25 00:25:3524#include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h"
[email protected]b0cb5e82012-07-19 19:22:4725#include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
26#include "chrome/browser/browsing_data/browsing_data_database_helper.h"
27#include "chrome/browser/browsing_data/browsing_data_file_system_helper.h"
28#include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
29#include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
peconn5100d432015-09-16 12:03:0830#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
[email protected]77a91c72012-08-13 16:19:3431#include "chrome/browser/history/history_service_factory.h"
palmerf2cba0d2015-08-27 23:15:0632#include "chrome/browser/infobars/infobar_service.h"
reillyg85f57db2016-01-12 23:14:3833#include "chrome/browser/permissions/chooser_context_base.h"
[email protected]03ef4b2a2012-03-06 15:04:2034#include "chrome/browser/profiles/profile.h"
[email protected]71cd5ef2014-08-13 21:22:0435#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
36#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
[email protected]4237dd52012-06-05 00:00:3237#include "chrome/browser/ui/website_settings/website_settings_ui.h"
reillyg85f57db2016-01-12 23:14:3838#include "chrome/browser/usb/usb_chooser_context.h"
39#include "chrome/browser/usb/usb_chooser_context_factory.h"
[email protected]71cd5ef2014-08-13 21:22:0440#include "chrome/common/chrome_switches.h"
sievers2f1e8112015-12-04 18:43:5641#include "chrome/common/features.h"
palmer153af982015-09-15 02:04:1942#include "chrome/common/pref_names.h"
jsbellddb849e2015-08-27 00:12:5643#include "chrome/common/url_constants.h"
thestig884a1602014-08-27 01:29:3944#include "chrome/grit/chromium_strings.h"
45#include "chrome/grit/generated_resources.h"
reillyg85f57db2016-01-12 23:14:3846#include "chrome/grit/theme_resources.h"
mukai8eaec822014-10-25 17:53:1647#include "components/content_settings/core/browser/content_settings_utils.h"
48#include "components/content_settings/core/browser/host_content_settings_map.h"
vabr48565592014-10-08 15:06:0249#include "components/content_settings/core/browser/local_shared_objects_counter.h"
palmer0da10b32015-02-11 00:42:1950#include "components/content_settings/core/common/content_settings.h"
vasiliif62dbf92014-09-05 10:23:1351#include "components/content_settings/core/common/content_settings_pattern.h"
jialiul02aad2d2015-04-01 18:56:0352#include "components/rappor/rappor_utils.h"
felt2493b4452015-09-17 20:33:5953#include "components/ssl_errors/error_info.h"
palmer153af982015-09-15 02:04:1954#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3355#include "content/public/browser/browser_thread.h"
[email protected]b59c6cf02012-03-12 20:51:4256#include "content/public/browser/cert_store.h"
[email protected]e22d64f2012-09-10 09:03:2357#include "content/public/browser/user_metrics.h"
[email protected]eb2140c2013-07-29 12:37:3458#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2059#include "content/public/common/url_constants.h"
[email protected]6e7845ae2013-03-29 21:48:1160#include "net/cert/cert_status_flags.h"
61#include "net/cert/x509_certificate.h"
[email protected]536fd0b2013-03-14 17:41:5762#include "net/ssl/ssl_cipher_suite_names.h"
63#include "net/ssl/ssl_connection_status_flags.h"
[email protected]03ef4b2a2012-03-06 15:04:2064#include "ui/base/l10n/l10n_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2065
[email protected]24a9f1c92013-11-13 12:33:3766#if defined(OS_CHROMEOS)
67#include "chrome/browser/chromeos/policy/policy_cert_service.h"
68#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
69#endif
70
estade3feb83f2015-09-01 23:00:4971#if !defined(OS_ANDROID)
mgiucaa319f212016-01-14 03:30:1172#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
estade3feb83f2015-09-01 23:00:4973#include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h"
74#endif
75
[email protected]ab6df3b12013-12-24 23:32:2676using base::ASCIIToUTF16;
77using base::UTF8ToUTF16;
[email protected]f729d7a2013-12-26 07:07:5678using base::UTF16ToUTF8;
[email protected]0b9fdd72012-04-04 10:00:3379using content::BrowserThread;
estarkd9e54fb2016-01-11 19:37:1280using security_state::SecurityStateModel;
[email protected]0b9fdd72012-04-04 10:00:3381
82namespace {
83
jww1ed8ea72014-09-02 20:43:2584// Events for UMA. Do not reorder or change!
85enum SSLCertificateDecisionsDidRevoke {
86 USER_CERT_DECISIONS_NOT_REVOKED = 0,
87 USER_CERT_DECISIONS_REVOKED,
88 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM
89};
90
palmer0da10b32015-02-11 00:42:1991// The list of content settings types to display on the Website Settings UI. THE
92// ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, email
93// [email protected].
[email protected]0b9fdd72012-04-04 10:00:3394ContentSettingsType kPermissionType[] = {
sashab2b2a314f2015-01-17 06:42:2195 CONTENT_SETTINGS_TYPE_GEOLOCATION,
sashab2b2a314f2015-01-17 06:42:2196 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
97 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
palmer0da10b32015-02-11 00:42:1998 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
99 CONTENT_SETTINGS_TYPE_IMAGES,
100 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
101 CONTENT_SETTINGS_TYPE_POPUPS,
102 CONTENT_SETTINGS_TYPE_FULLSCREEN,
sashab2b2a314f2015-01-17 06:42:21103 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
palmer0da10b32015-02-11 00:42:19104 CONTENT_SETTINGS_TYPE_PLUGINS,
105 CONTENT_SETTINGS_TYPE_MOUSELOCK,
sashab2b2a314f2015-01-17 06:42:21106 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
benwellsa68ed4b2014-11-13 03:25:36107#if defined(OS_ANDROID)
sashab2b2a314f2015-01-17 06:42:21108 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
benwellsa68ed4b2014-11-13 03:25:36109#endif
svaldez18120952016-01-14 21:12:49110 CONTENT_SETTINGS_TYPE_KEYGEN,
[email protected]0b9fdd72012-04-04 10:00:33111};
112
mgiucaa319f212016-01-14 03:30:11113// Determines whether to show permission |type| in the Website Settings UI. Only
114// applies to permissions listed in |kPermissionType|.
115bool ShouldShowPermission(ContentSettingsType type) {
116 // TODO(mgiuca): When simplified-fullscreen-ui is enabled on all platforms,
117 // remove these from kPermissionType, rather than having this check
118 // (http://crbug.com/577396).
119#if !defined(OS_ANDROID)
120 // Fullscreen and mouselock settings are not shown in simplified fullscreen
121 // mode (always allow).
122 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN ||
123 type == CONTENT_SETTINGS_TYPE_MOUSELOCK) {
124 return !ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled();
125 }
126#endif
127
128 return true;
129}
130
estark134a9822015-10-29 04:35:18131// Returns true if any of the given statuses match |status|.
132bool CertificateTransparencyStatusMatchAny(
estarka3121f6b2015-09-18 21:15:59133 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49134 net::ct::SCTVerifyStatus status) {
estarka3121f6b2015-09-18 21:15:59135 for (const auto& verify_status : sct_verify_statuses) {
136 if (verify_status == status)
[email protected]94c74b42013-12-02 15:19:49137 return true;
138 }
[email protected]94c74b42013-12-02 15:19:49139 return false;
140}
141
142int GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59143 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49144 bool is_ev) {
145 // No SCTs - no CT information.
estarka3121f6b2015-09-18 21:15:59146 if (sct_verify_statuses.empty())
[email protected]94c74b42013-12-02 15:19:49147 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_NO_CT
148 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_NO_CT);
149
estark134a9822015-10-29 04:35:18150 // Any valid SCT.
151 if (CertificateTransparencyStatusMatchAny(sct_verify_statuses,
152 net::ct::SCT_STATUS_OK))
[email protected]94c74b42013-12-02 15:19:49153 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_VERIFIED
154 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_VERIFIED);
155
estark134a9822015-10-29 04:35:18156 // Any invalid SCT.
157 if (CertificateTransparencyStatusMatchAny(sct_verify_statuses,
158 net::ct::SCT_STATUS_INVALID))
[email protected]94c74b42013-12-02 15:19:49159 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_INVALID
160 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_INVALID);
161
estark134a9822015-10-29 04:35:18162 // All SCTs are from unknown logs.
[email protected]94c74b42013-12-02 15:19:49163 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_UNVERIFIED
164 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_UNVERIFIED);
165}
166
167// This function will return SITE_IDENTITY_STATUS_CERT or
estark134a9822015-10-29 04:35:18168// SITE_IDENTITY_STATUS_EV_CERT depending on |is_ev| unless all SCTs
169// failed verification, in which case it will return
[email protected]94c74b42013-12-02 15:19:49170// SITE_IDENTITY_STATUS_ERROR.
171WebsiteSettings::SiteIdentityStatus GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59172 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49173 bool is_ev) {
estark134a9822015-10-29 04:35:18174 if (sct_verify_statuses.empty() ||
175 CertificateTransparencyStatusMatchAny(sct_verify_statuses,
176 net::ct::SCT_STATUS_OK))
177 return is_ev ? WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT
178 : WebsiteSettings::SITE_IDENTITY_STATUS_CERT;
[email protected]94c74b42013-12-02 15:19:49179
estark134a9822015-10-29 04:35:18180 return WebsiteSettings::SITE_IDENTITY_STATUS_CT_ERROR;
[email protected]94c74b42013-12-02 15:19:49181}
182
palmer153af982015-09-15 02:04:19183base::string16 GetSimpleSiteName(const GURL& url, Profile* profile) {
184 std::string languages;
185 if (profile)
186 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
187 return url_formatter::FormatUrlForSecurityDisplayOmitScheme(url, languages);
188}
189
reillyg85f57db2016-01-12 23:14:38190ChooserContextBase* GetUsbChooserContext(Profile* profile) {
191 return UsbChooserContextFactory::GetForProfile(profile);
192}
193
194// The list of chooser types that need to display entries in the Website
195// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
196// email [email protected].
197WebsiteSettings::ChooserUIInfo kChooserUIInfo[] = {
198 {&GetUsbChooserContext, IDR_BLOCKED_USB, IDR_ALLOWED_USB,
199 IDS_WEBSITE_SETTINGS_USB_DEVICE_LABEL,
200 IDS_WEBSITE_SETTINGS_DELETE_USB_DEVICE, "name"},
201};
202
[email protected]0b9fdd72012-04-04 10:00:33203} // namespace
204
205WebsiteSettings::WebsiteSettings(
206 WebsiteSettingsUI* ui,
207 Profile* profile,
[email protected]df818272012-04-20 13:10:50208 TabSpecificContentSettings* tab_specific_content_settings,
palmerf2cba0d2015-08-27 23:15:06209 content::WebContents* web_contents,
[email protected]0b9fdd72012-04-04 10:00:33210 const GURL& url,
estarka3121f6b2015-09-18 21:15:59211 const SecurityStateModel::SecurityInfo& security_info,
[email protected]0b9fdd72012-04-04 10:00:33212 content::CertStore* cert_store)
[email protected]df818272012-04-20 13:10:50213 : TabSpecificContentSettings::SiteDataObserver(
214 tab_specific_content_settings),
215 ui_(ui),
palmerf2cba0d2015-08-27 23:15:06216 web_contents_(web_contents),
[email protected]66f157312012-08-01 13:50:26217 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33218 site_url_(url),
219 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]f61c1ce2012-05-09 13:55:11220 cert_id_(0),
[email protected]03ef4b2a2012-03-06 15:04:20221 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
[email protected]0b9fdd72012-04-04 10:00:33222 cert_store_(cert_store),
peconn5100d432015-09-16 12:03:08223 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04224 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25225 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19226 did_revoke_user_ssl_decisions_(false),
227 profile_(profile) {
estarka3121f6b2015-09-18 21:15:59228 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33229
230 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50231 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41232 PresentSiteIdentity();
[email protected]e22d64f2012-09-10 09:03:23233
234 // Every time the Website Settings UI is opened a |WebsiteSettings| object is
235 // created. So this counts how ofter the Website Settings UI is opened.
lgarron04a93502014-11-04 22:25:04236 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20237}
238
[email protected]0b9fdd72012-04-04 10:00:33239WebsiteSettings::~WebsiteSettings() {
[email protected]03ef4b2a2012-03-06 15:04:20240}
241
lgarron04a93502014-11-04 22:25:04242void WebsiteSettings::RecordWebsiteSettingsAction(
243 WebsiteSettingsAction action) {
244 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action",
245 action,
246 WEBSITE_SETTINGS_COUNT);
247
248 // Use a separate histogram to record actions if they are done on a page with
249 // an HTTPS URL. Note that this *disregards* security status.
palmeree0e5af2015-06-05 03:10:40250 //
251
252 // TODO(palmer): Consider adding a new histogram for
253 // GURL::SchemeIsCryptographic. (We don't want to replace this call with a
254 // call to that function because we don't want to change the meanings of
255 // existing metrics.) This would inform the decision to mark non-secure
256 // origins as Dubious or Non-Secure; the overall bug for that is
257 // crbug.com/454579.
lgarron04a93502014-11-04 22:25:04258 if (site_url_.SchemeIs(url::kHttpsScheme)) {
259 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action.HttpsUrl",
260 action,
261 WEBSITE_SETTINGS_COUNT);
262 }
263}
264
raymes9d48b07b2015-10-19 04:32:35265// Get corresponding Rappor Metric. TODO(raymes): This should use the same
266// code that's in permission_context_uma_util.cc. Figure out how to do that.
267// crbug.com/544745.
jialiul02aad2d2015-04-01 18:56:03268const std::string GetRapporMetric(ContentSettingsType permission) {
269 std::string permission_str;
raymes9d48b07b2015-10-19 04:32:35270
271 if (permission == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
272 permission_str = "Geolocation";
273 } else if (permission == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
274 permission_str = "Notifications";
275 } else if (permission == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) {
276 permission_str = "Mic";
277 } else if (permission == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) {
278 permission_str = "Camera";
jialiul02aad2d2015-04-01 18:56:03279 }
280
281 return base::StringPrintf("ContentSettings.PermissionActions_%s.Revoked.Url",
282 permission_str.c_str());
283}
lgarron04a93502014-11-04 22:25:04284
[email protected]df818272012-04-20 13:10:50285void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type,
286 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23287 // Count how often a permission for a specific content type is changed using
288 // the Website Settings UI.
raymes4a13d432015-09-08 00:44:07289 size_t num_values;
290 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
sashab9debecd2014-12-18 04:15:56291 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.OriginInfo.PermissionChanged",
raymes4a13d432015-09-08 00:44:07292 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56293
294 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
295 UMA_HISTOGRAM_ENUMERATION(
296 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07297 num_values);
sashab9debecd2014-12-18 04:15:56298 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
299 UMA_HISTOGRAM_ENUMERATION(
300 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07301 num_values);
jialiul02aad2d2015-04-01 18:56:03302 // Trigger Rappor sampling if it is a permission revoke action.
303 const std::string& rappor_metric = GetRapporMetric(type);
304 if (!rappor_metric.empty()) {
305 rappor::SampleDomainAndRegistryFromGURL(
306 g_browser_process->rappor_service(), rappor_metric, this->site_url_);
307 }
sashab9debecd2014-12-18 04:15:56308 }
[email protected]e22d64f2012-09-10 09:03:23309
lgarron04a93502014-11-04 22:25:04310 // This is technically redundant given the histogram above, but putting the
311 // total count of permission changes in another histogram makes it easier to
312 // compare it against other kinds of actions in WebsiteSettings[PopupView].
313 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_CHANGED_PERMISSION);
314
raymesfbaaaaa2015-11-10 02:20:40315 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
316 setting);
[email protected]df818272012-04-20 13:10:50317
[email protected]66f157312012-08-01 13:50:26318 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24319
[email protected]2f45d542012-08-22 08:47:24320 // Refresh the UI to reflect the new setting.
321 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50322}
323
reillyg85f57db2016-01-12 23:14:38324void WebsiteSettings::OnSiteChosenObjectDeleted(
325 const ChooserUIInfo& ui_info,
326 const base::DictionaryValue& object) {
327 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
328 ChooserContextBase* context = ui_info.get_context(profile_);
329 context->RevokeObjectPermission(site_url_, site_url_, object);
330
331 show_info_bar_ = true;
332
333 // Refresh the UI to reflect the changed settings.
334 PresentSitePermissions();
335}
336
[email protected]df818272012-04-20 13:10:50337void WebsiteSettings::OnSiteDataAccessed() {
338 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33339}
340
[email protected]66f157312012-08-01 13:50:26341void WebsiteSettings::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49342#if defined(OS_ANDROID)
343 NOTREACHED();
344#else
palmerf2cba0d2015-08-27 23:15:06345 if (show_info_bar_ && web_contents_) {
346 InfoBarService* infobar_service =
347 InfoBarService::FromWebContents(web_contents_);
348 if (infobar_service)
349 WebsiteSettingsInfoBarDelegate::Create(infobar_service);
350 }
jww1ed8ea72014-09-02 20:43:25351
352 SSLCertificateDecisionsDidRevoke user_decision =
353 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
354 : USER_CERT_DECISIONS_NOT_REVOKED;
355
356 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
357 user_decision,
358 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49359#endif
jww1ed8ea72014-09-02 20:43:25360}
361
362void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() {
363 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29364 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
365 site_url().host());
jww1ed8ea72014-09-02 20:43:25366 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26367}
368
estarka3121f6b2015-09-18 21:15:59369void WebsiteSettings::Init(
370 const GURL& url,
371 const SecurityStateModel::SecurityInfo& security_info) {
sashab97894ce2014-10-22 10:08:33372 bool isChromeUINativeScheme = false;
sievers2f1e8112015-12-04 18:43:56373#if BUILDFLAG(ANDROID_JAVA_UI)
sashab97894ce2014-10-22 10:08:33374 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
375#endif
376
upendrag.gowda60886a6e2015-10-31 05:51:09377 if (url.SchemeIs(url::kAboutScheme)) {
378 // All about: URLs except about:blank are redirected.
379 DCHECK_EQ(url::kAboutBlankURL, url.spec());
380 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
381 site_identity_details_ =
382 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
383 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
384 site_connection_details_ = l10n_util::GetStringFUTF16(
385 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
386 UTF8ToUTF16(url.spec()));
387 return;
388 }
389
390 if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) {
[email protected]03ef4b2a2012-03-06 15:04:20391 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
392 site_identity_details_ =
393 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
394 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
395 return;
396 }
397
[email protected]03ef4b2a2012-03-06 15:04:20398 // Identity section.
palmer153af982015-09-15 02:04:19399 scoped_refptr<net::X509Certificate> cert;
estarka3121f6b2015-09-18 21:15:59400 cert_id_ = security_info.cert_id;
[email protected]f61c1ce2012-05-09 13:55:11401
estarka3121f6b2015-09-18 21:15:59402 // HTTPS with no or minor errors.
403 if (security_info.cert_id &&
404 cert_store_->RetrieveCert(security_info.cert_id, &cert) &&
405 (!net::IsCertStatusError(security_info.cert_status) ||
406 net::IsCertStatusMinorError(security_info.cert_status))) {
[email protected]03ef4b2a2012-03-06 15:04:20407 // There are no major errors. Check for minor errors.
estarka3121f6b2015-09-18 21:15:59408 if (security_info.security_level ==
409 SecurityStateModel::SECURITY_POLICY_WARNING) {
[email protected]eaf3f322013-04-25 21:53:59410 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37411 site_identity_details_ = l10n_util::GetStringFUTF16(
412 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59413 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20414 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
[email protected]a04db822013-12-11 19:14:40415 base::string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20416 if (issuer_name.empty()) {
417 issuer_name.assign(l10n_util::GetStringUTF16(
418 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
419 }
[email protected]94c74b42013-12-02 15:19:49420
[email protected]03ef4b2a2012-03-06 15:04:20421 site_identity_details_.assign(l10n_util::GetStringFUTF16(
[email protected]94c74b42013-12-02 15:19:49422 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59423 security_info.sct_verify_statuses, false /* not EV */),
[email protected]94c74b42013-12-02 15:19:49424 issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20425
426 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59427 if (security_info.cert_status &
428 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20429 site_identity_details_ += l10n_util::GetStringUTF16(
430 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59431 } else if (security_info.cert_status &
432 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20433 site_identity_details_ += l10n_util::GetStringUTF16(
434 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
435 } else {
436 NOTREACHED() << "Need to specify string for this warning";
437 }
[email protected]03ef4b2a2012-03-06 15:04:20438 } else {
estarka3121f6b2015-09-18 21:15:59439 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01440 // EV HTTPS page.
441 site_identity_status_ = GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59442 security_info.sct_verify_statuses, true);
rsleevi4f8012722014-09-30 01:28:01443 DCHECK(!cert->subject().organization_names.empty());
444 organization_name_ = UTF8ToUTF16(cert->subject().organization_names[0]);
445 // An EV Cert is required to have a city (localityName) and country but
446 // state is "if any".
447 DCHECK(!cert->subject().locality_name.empty());
448 DCHECK(!cert->subject().country_name.empty());
449 base::string16 locality;
450 if (!cert->subject().state_or_province_name.empty()) {
451 locality = l10n_util::GetStringFUTF16(
452 IDS_PAGEINFO_ADDRESS,
453 UTF8ToUTF16(cert->subject().locality_name),
454 UTF8ToUTF16(cert->subject().state_or_province_name),
455 UTF8ToUTF16(cert->subject().country_name));
456 } else {
457 locality = l10n_util::GetStringFUTF16(
458 IDS_PAGEINFO_PARTIAL_ADDRESS,
459 UTF8ToUTF16(cert->subject().locality_name),
460 UTF8ToUTF16(cert->subject().country_name));
461 }
462 DCHECK(!cert->subject().organization_names.empty());
463 site_identity_details_.assign(l10n_util::GetStringFUTF16(
464 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59465 security_info.sct_verify_statuses, true /* is EV */),
466 UTF8ToUTF16(cert->subject().organization_names[0]), locality,
rsleevi4f8012722014-09-30 01:28:01467 UTF8ToUTF16(cert->issuer().GetDisplayName())));
468 } else {
469 // Non-EV OK HTTPS page.
470 site_identity_status_ = GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59471 security_info.sct_verify_statuses, false);
rsleevi4f8012722014-09-30 01:28:01472 base::string16 issuer_name(
473 UTF8ToUTF16(cert->issuer().GetDisplayName()));
474 if (issuer_name.empty()) {
475 issuer_name.assign(l10n_util::GetStringUTF16(
476 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
477 }
[email protected]94c74b42013-12-02 15:19:49478
rsleevi4f8012722014-09-30 01:28:01479 site_identity_details_.assign(l10n_util::GetStringFUTF16(
480 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59481 security_info.sct_verify_statuses, false /* not EV */),
rsleevi4f8012722014-09-30 01:28:01482 issuer_name));
483 }
lgarroncc53de22015-10-05 23:03:17484 switch (security_info.sha1_deprecation_status) {
485 case SecurityStateModel::DEPRECATED_SHA1_MINOR:
486 site_identity_status_ =
487 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR;
488 site_identity_details_ +=
489 UTF8ToUTF16("\n\n") +
490 l10n_util::GetStringUTF16(
491 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MINOR);
492 break;
493 case SecurityStateModel::DEPRECATED_SHA1_MAJOR:
494 site_identity_status_ =
495 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR;
496 site_identity_details_ +=
497 UTF8ToUTF16("\n\n") +
498 l10n_util::GetStringUTF16(
499 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR);
500 break;
501 case SecurityStateModel::NO_DEPRECATED_SHA1:
502 // Nothing to do.
503 break;
rsleevi4f8012722014-09-30 01:28:01504 }
[email protected]03ef4b2a2012-03-06 15:04:20505 }
506 } else {
507 // HTTP or HTTPS with errors (not warnings).
508 site_identity_details_.assign(l10n_util::GetStringUTF16(
509 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
estarka3121f6b2015-09-18 21:15:59510 if (!security_info.scheme_is_cryptographic || !security_info.cert_id)
[email protected]03ef4b2a2012-03-06 15:04:20511 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
512 else
513 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
514
[email protected]a04db822013-12-11 19:14:40515 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59516 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59517 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
518 cert, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20519 for (size_t i = 0; i < errors.size(); ++i) {
520 site_identity_details_ += bullet;
521 site_identity_details_ += errors[i].short_description();
522 }
523
estarka3121f6b2015-09-18 21:15:59524 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20525 site_identity_details_ += ASCIIToUTF16("\n\n");
526 site_identity_details_ += l10n_util::GetStringUTF16(
527 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
528 }
529 }
530
531 // Site Connection
532 // We consider anything less than 80 bits encryption to be weak encryption.
533 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
534 // weakly encrypted connections.
535 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
536
palmer153af982015-09-15 02:04:19537 base::string16 subject_name(GetSimpleSiteName(url, profile_));
538 if (subject_name.empty()) {
539 subject_name.assign(
540 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
541 }
542
estarka3121f6b2015-09-18 21:15:59543 if (!security_info.cert_id || !security_info.scheme_is_cryptographic) {
544 // Page is still loading (so SSL status is not yet available) or
545 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58546 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
547
548 site_connection_details_.assign(l10n_util::GetStringFUTF16(
549 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
550 subject_name));
estarka3121f6b2015-09-18 21:15:59551 } else if (security_info.security_bits < 0) {
552 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20553 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59554 } else if (security_info.security_bits == 0) {
555 DCHECK_NE(security_info.security_level, SecurityStateModel::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20556 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
557 site_connection_details_.assign(l10n_util::GetStringFUTF16(
558 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
559 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20560 } else {
561 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22562
estarkfd5ca022015-10-29 21:07:55563 if (security_info.is_secure_protocol_and_ciphersuite) {
Adam Langley71c2b59b2014-11-13 00:34:22564 site_connection_details_.assign(l10n_util::GetStringFUTF16(
565 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
566 subject_name));
567 } else {
568 site_connection_details_.assign(l10n_util::GetStringFUTF16(
569 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
570 subject_name));
571 }
572
estarka3121f6b2015-09-18 21:15:59573 if (security_info.mixed_content_status !=
574 SecurityStateModel::NO_MIXED_CONTENT) {
[email protected]03ef4b2a2012-03-06 15:04:20575 bool ran_insecure_content =
estarka3121f6b2015-09-18 21:15:59576 (security_info.mixed_content_status ==
577 SecurityStateModel::RAN_MIXED_CONTENT ||
578 security_info.mixed_content_status ==
579 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT);
palmercc7f5f8c2015-09-04 01:02:59580 site_connection_status_ = ran_insecure_content
581 ? SITE_CONNECTION_STATUS_MIXED_SCRIPT
582 : SITE_CONNECTION_STATUS_MIXED_CONTENT;
[email protected]03ef4b2a2012-03-06 15:04:20583 site_connection_details_.assign(l10n_util::GetStringFUTF16(
584 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
585 site_connection_details_,
586 l10n_util::GetStringUTF16(ran_insecure_content ?
587 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR :
588 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
589 }
590 }
591
avi655876a2015-12-25 07:18:15592 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59593 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
594 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20595 int ssl_version =
estarka3121f6b2015-09-18 21:15:59596 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20597 const char* ssl_version_str;
598 net::SSLVersionToString(&ssl_version_str, ssl_version);
599 site_connection_details_ += ASCIIToUTF16("\n\n");
600 site_connection_details_ += l10n_util::GetStringFUTF16(
601 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION,
602 ASCIIToUTF16(ssl_version_str));
603
[email protected]03ef4b2a2012-03-06 15:04:20604 bool no_renegotiation =
estarka3121f6b2015-09-18 21:15:59605 (security_info.connection_status &
606 net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20607 const char *key_exchange, *cipher, *mac;
[email protected]b6c1d9e82013-06-12 17:26:57608 bool is_aead;
609 net::SSLCipherSuiteToStrings(
610 &key_exchange, &cipher, &mac, &is_aead, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20611
612 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57613 if (is_aead) {
614 site_connection_details_ += l10n_util::GetStringFUTF16(
615 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
616 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
617 } else {
618 site_connection_details_ += l10n_util::GetStringFUTF16(
619 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS,
620 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
621 }
[email protected]03ef4b2a2012-03-06 15:04:20622
agl078d2102014-10-20 22:03:22623 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 &&
624 site_connection_status_ < SITE_CONNECTION_STATUS_MIXED_CONTENT) {
625 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
626 }
627
estarka3121f6b2015-09-18 21:15:59628 const bool did_fallback = (security_info.connection_status &
629 net::SSL_CONNECTION_VERSION_FALLBACK) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20630 if (did_fallback) {
[email protected]03ef4b2a2012-03-06 15:04:20631 site_connection_details_ += ASCIIToUTF16("\n\n");
632 site_connection_details_ += l10n_util::GetStringUTF16(
633 IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE);
634 }
agl078d2102014-10-20 22:03:22635
[email protected]03ef4b2a2012-03-06 15:04:20636 if (no_renegotiation) {
637 site_connection_details_ += ASCIIToUTF16("\n\n");
638 site_connection_details_ += l10n_util::GetStringUTF16(
639 IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE);
640 }
641 }
[email protected]e583f752012-08-30 13:26:21642
[email protected]71cd5ef2014-08-13 21:22:04643 // Check if a user decision has been made to allow or deny certificates with
644 // errors on this site.
645 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50646 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04647 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40648 // Only show an SSL decision revoke button if the user has chosen to bypass
649 // SSL host errors for this host in the past.
650 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]71cd5ef2014-08-13 21:22:04651
palmer82b1f7b2015-09-17 19:20:41652 // By default select the Permissions Tab that displays all the site
653 // permissions. In case of a connection error or an issue with the certificate
654 // presented by the website, select the Connection Tab to draw the user's
655 // attention to the issue. If the site does not provide a certificate because
656 // it was loaded over an unencrypted connection, don't select the Connection
657 // Tab.
[email protected]e583f752012-08-30 13:26:21658 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS;
659 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR ||
660 site_connection_status_ == SITE_CONNECTION_STATUS_MIXED_CONTENT ||
estarkf62683e2015-09-17 17:52:06661 site_connection_status_ == SITE_CONNECTION_STATUS_MIXED_SCRIPT ||
[email protected]e583f752012-08-30 13:26:21662 site_identity_status_ == SITE_IDENTITY_STATUS_ERROR ||
estark134a9822015-10-29 04:35:18663 site_identity_status_ == SITE_IDENTITY_STATUS_CT_ERROR ||
[email protected]eaf3f322013-04-25 21:53:59664 site_identity_status_ == SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN ||
rsleevi4f8012722014-09-30 01:28:01665 site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT ||
666 site_identity_status_ ==
lgarroncc53de22015-10-05 23:03:17667 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR ||
668 site_identity_status_ ==
669 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR) {
[email protected]e583f752012-08-30 13:26:21670 tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION;
lgarron04a93502014-11-04 22:25:04671 RecordWebsiteSettingsAction(
672 WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY);
673 }
palmer82b1f7b2015-09-17 19:20:41674
[email protected]e583f752012-08-30 13:26:21675 ui_->SetSelectedTab(tab_id);
[email protected]03ef4b2a2012-03-06 15:04:20676}
[email protected]0b9fdd72012-04-04 10:00:33677
[email protected]df818272012-04-20 13:10:50678void WebsiteSettings::PresentSitePermissions() {
679 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38680 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50681
682 WebsiteSettingsUI::PermissionInfo permission_info;
683 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
684 permission_info.type = kPermissionType[i];
685
mgiucaa319f212016-01-14 03:30:11686 if (!ShouldShowPermission(permission_info.type))
687 continue;
688
[email protected]df818272012-04-20 13:10:50689 content_settings::SettingInfo info;
sashab2b2a314f2015-01-17 06:42:21690 scoped_ptr<base::Value> value =
raymes7dec6d862015-07-27 07:02:08691 content_settings_->GetWebsiteSetting(
sashab2b2a314f2015-01-17 06:42:21692 site_url_, site_url_, permission_info.type, std::string(), &info);
693 DCHECK(value.get());
694 if (value->GetType() == base::Value::TYPE_INTEGER) {
695 permission_info.setting =
696 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26697 } else {
sashab2b2a314f2015-01-17 06:42:21698 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26699 }
700
[email protected]8bdf45c32012-08-04 00:12:55701 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28702 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50703
[email protected]b1d113d2012-06-27 21:27:34704 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21705 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34706 permission_info.default_setting = permission_info.setting;
707 permission_info.setting = CONTENT_SETTING_DEFAULT;
708 } else {
709 permission_info.default_setting =
710 content_settings_->GetDefaultContentSetting(permission_info.type,
711 NULL);
[email protected]df818272012-04-20 13:10:50712 }
palmer0da10b32015-02-11 00:42:19713
svaldez18120952016-01-14 21:12:49714 if ((permission_info.setting != CONTENT_SETTING_DEFAULT &&
715 permission_info.setting != permission_info.default_setting) ||
716 (permission_info.type == CONTENT_SETTINGS_TYPE_KEYGEN &&
717 tab_specific_content_settings()->IsContentBlocked(
718 permission_info.type))) {
palmer0da10b32015-02-11 00:42:19719 permission_info_list.push_back(permission_info);
720 }
[email protected]df818272012-04-20 13:10:50721 }
722
reillyg85f57db2016-01-12 23:14:38723 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
724 ChooserContextBase* context = ui_info.get_context(profile_);
725 auto chosen_objects = context->GetGrantedObjects(site_url_, site_url_);
726 for (scoped_ptr<base::DictionaryValue>& object : chosen_objects) {
727 chosen_object_info_list.push_back(
728 new WebsiteSettingsUI::ChosenObjectInfo(ui_info, std::move(object)));
729 }
730 }
731
732 ui_->SetPermissionInfo(permission_info_list, chosen_object_info_list);
[email protected]0b9fdd72012-04-04 10:00:33733}
734
[email protected]df818272012-04-20 13:10:50735void WebsiteSettings::PresentSiteData() {
736 CookieInfoList cookie_info_list;
vabrd5e30cd2014-10-02 11:06:03737 const LocalSharedObjectsCounter& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34738 tab_specific_content_settings()->allowed_local_shared_objects();
vabrd5e30cd2014-10-02 11:06:03739 const LocalSharedObjectsCounter& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34740 tab_specific_content_settings()->blocked_local_shared_objects();
741
742 // Add first party cookie and site data counts.
[email protected]df818272012-04-20 13:10:50743 WebsiteSettingsUI::CookieInfo cookie_info;
palmerb145264922015-08-28 23:53:15744 cookie_info.cookie_source =
745 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_FIRST_PARTY_SITE_DATA);
[email protected]e0ac35892012-05-15 12:53:34746 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
747 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15748 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34749 cookie_info_list.push_back(cookie_info);
750
751 // Add third party cookie counts.
752 cookie_info.cookie_source = l10n_util::GetStringUTF8(
753 IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA);
754 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
755 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15756 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50757 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33758
[email protected]df818272012-04-20 13:10:50759 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33760}
[email protected]16de6de2012-04-04 12:24:14761
[email protected]24c8818c2012-04-25 09:57:41762void WebsiteSettings::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04763 // After initialization the status about the site's connection and its
764 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41765 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
766 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
767 WebsiteSettingsUI::IdentityInfo info;
768 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
769 info.site_identity = UTF16ToUTF8(organization_name());
770 else
palmer153af982015-09-15 02:04:19771 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_, profile_));
[email protected]24c8818c2012-04-25 09:57:41772
773 info.connection_status = site_connection_status_;
774 info.connection_status_description =
775 UTF16ToUTF8(site_connection_details_);
776 info.identity_status = site_identity_status_;
777 info.identity_status_description =
778 UTF16ToUTF8(site_identity_details_);
[email protected]f61c1ce2012-05-09 13:55:11779 info.cert_id = cert_id_;
[email protected]71cd5ef2014-08-13 21:22:04780 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
[email protected]24c8818c2012-04-25 09:57:41781 ui_->SetIdentityInfo(info);
782}