blob: b634f64148d000faeb4ce4c59bb9c10b359718b5 [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"
tsergeantf1e89352016-01-15 20:34:5434#include "chrome/browser/permissions/permission_uma_util.h"
35#include "chrome/browser/permissions/permission_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2036#include "chrome/browser/profiles/profile.h"
[email protected]71cd5ef2014-08-13 21:22:0437#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
38#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
[email protected]4237dd52012-06-05 00:00:3239#include "chrome/browser/ui/website_settings/website_settings_ui.h"
reillyg85f57db2016-01-12 23:14:3840#include "chrome/browser/usb/usb_chooser_context.h"
41#include "chrome/browser/usb/usb_chooser_context_factory.h"
[email protected]71cd5ef2014-08-13 21:22:0442#include "chrome/common/chrome_switches.h"
sievers2f1e8112015-12-04 18:43:5643#include "chrome/common/features.h"
jsbellddb849e2015-08-27 00:12:5644#include "chrome/common/url_constants.h"
thestig884a1602014-08-27 01:29:3945#include "chrome/grit/chromium_strings.h"
46#include "chrome/grit/generated_resources.h"
reillyg85f57db2016-01-12 23:14:3847#include "chrome/grit/theme_resources.h"
mukai8eaec822014-10-25 17:53:1648#include "components/content_settings/core/browser/content_settings_utils.h"
49#include "components/content_settings/core/browser/host_content_settings_map.h"
vabr48565592014-10-08 15:06:0250#include "components/content_settings/core/browser/local_shared_objects_counter.h"
palmer0da10b32015-02-11 00:42:1951#include "components/content_settings/core/common/content_settings.h"
vasiliif62dbf92014-09-05 10:23:1352#include "components/content_settings/core/common/content_settings_pattern.h"
jialiul02aad2d2015-04-01 18:56:0353#include "components/rappor/rappor_utils.h"
felt2493b4452015-09-17 20:33:5954#include "components/ssl_errors/error_info.h"
palmer153af982015-09-15 02:04:1955#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3356#include "content/public/browser/browser_thread.h"
[email protected]b59c6cf02012-03-12 20:51:4257#include "content/public/browser/cert_store.h"
tsergeantf1e89352016-01-15 20:34:5458#include "content/public/browser/permission_type.h"
[email protected]e22d64f2012-09-10 09:03:2359#include "content/public/browser/user_metrics.h"
[email protected]eb2140c2013-07-29 12:37:3460#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2061#include "content/public/common/url_constants.h"
sdefresne21a6eaf2016-02-11 22:30:1962#include "grit/components_chromium_strings.h"
sdefresne21a6eaf2016-02-11 22:30:1963#include "grit/components_strings.h"
[email protected]6e7845ae2013-03-29 21:48:1164#include "net/cert/cert_status_flags.h"
65#include "net/cert/x509_certificate.h"
[email protected]536fd0b2013-03-14 17:41:5766#include "net/ssl/ssl_cipher_suite_names.h"
67#include "net/ssl/ssl_connection_status_flags.h"
[email protected]03ef4b2a2012-03-06 15:04:2068#include "ui/base/l10n/l10n_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2069
[email protected]24a9f1c92013-11-13 12:33:3770#if defined(OS_CHROMEOS)
71#include "chrome/browser/chromeos/policy/policy_cert_service.h"
72#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
73#endif
74
estade3feb83f2015-09-01 23:00:4975#if !defined(OS_ANDROID)
mgiucaa319f212016-01-14 03:30:1176#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
estade3feb83f2015-09-01 23:00:4977#include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h"
78#endif
79
[email protected]ab6df3b12013-12-24 23:32:2680using base::ASCIIToUTF16;
81using base::UTF8ToUTF16;
[email protected]f729d7a2013-12-26 07:07:5682using base::UTF16ToUTF8;
[email protected]0b9fdd72012-04-04 10:00:3383using content::BrowserThread;
estarkd9e54fb2016-01-11 19:37:1284using security_state::SecurityStateModel;
[email protected]0b9fdd72012-04-04 10:00:3385
86namespace {
87
jww1ed8ea72014-09-02 20:43:2588// Events for UMA. Do not reorder or change!
89enum SSLCertificateDecisionsDidRevoke {
90 USER_CERT_DECISIONS_NOT_REVOKED = 0,
91 USER_CERT_DECISIONS_REVOKED,
92 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM
93};
94
palmer0da10b32015-02-11 00:42:1995// The list of content settings types to display on the Website Settings UI. THE
96// ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, email
97// [email protected].
[email protected]0b9fdd72012-04-04 10:00:3398ContentSettingsType kPermissionType[] = {
sashab2b2a314f2015-01-17 06:42:2199 CONTENT_SETTINGS_TYPE_GEOLOCATION,
sashab2b2a314f2015-01-17 06:42:21100 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
101 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
palmer0da10b32015-02-11 00:42:19102 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
palmer7715e332016-05-27 00:41:19103 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
lshange085f202016-06-14 01:25:08104#if !defined(OS_ANDROID)
palmer7715e332016-05-27 00:41:19105 CONTENT_SETTINGS_TYPE_PLUGINS,
106 CONTENT_SETTINGS_TYPE_IMAGES,
lshange085f202016-06-14 01:25:08107#endif
palmer7715e332016-05-27 00:41:19108 CONTENT_SETTINGS_TYPE_POPUPS,
nsatragno670fe922016-04-08 14:10:50109 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
palmer7715e332016-05-27 00:41:19110 CONTENT_SETTINGS_TYPE_KEYGEN,
111 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
lshange085f202016-06-14 01:25:08112#if !defined(OS_ANDROID)
palmer7715e332016-05-27 00:41:19113 CONTENT_SETTINGS_TYPE_MOUSELOCK,
lshange085f202016-06-14 01:25:08114#endif
palmer7715e332016-05-27 00:41:19115 CONTENT_SETTINGS_TYPE_FULLSCREEN,
116 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
[email protected]0b9fdd72012-04-04 10:00:33117};
118
mgiucaa319f212016-01-14 03:30:11119// Determines whether to show permission |type| in the Website Settings UI. Only
120// applies to permissions listed in |kPermissionType|.
121bool ShouldShowPermission(ContentSettingsType type) {
mgiuca0f3e1f72016-05-13 01:56:27122 // TODO(mgiuca): When simplified-fullscreen-ui is enabled permanently on
123 // Android, remove these from kPermissionType, rather than having this check
mgiucaa319f212016-01-14 03:30:11124 // (http://crbug.com/577396).
125#if !defined(OS_ANDROID)
mgiuca0f3e1f72016-05-13 01:56:27126 // Fullscreen and mouselock settings are no longer shown (always allow).
mgiucaa319f212016-01-14 03:30:11127 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN ||
128 type == CONTENT_SETTINGS_TYPE_MOUSELOCK) {
mgiuca0f3e1f72016-05-13 01:56:27129 return false;
mgiucaa319f212016-01-14 03:30:11130 }
131#endif
132
133 return true;
134}
135
estark134a9822015-10-29 04:35:18136// Returns true if any of the given statuses match |status|.
137bool CertificateTransparencyStatusMatchAny(
estarka3121f6b2015-09-18 21:15:59138 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49139 net::ct::SCTVerifyStatus status) {
estarka3121f6b2015-09-18 21:15:59140 for (const auto& verify_status : sct_verify_statuses) {
141 if (verify_status == status)
[email protected]94c74b42013-12-02 15:19:49142 return true;
143 }
[email protected]94c74b42013-12-02 15:19:49144 return false;
145}
146
147int GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59148 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49149 bool is_ev) {
150 // No SCTs - no CT information.
estarka3121f6b2015-09-18 21:15:59151 if (sct_verify_statuses.empty())
[email protected]94c74b42013-12-02 15:19:49152 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_NO_CT
153 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_NO_CT);
154
estark134a9822015-10-29 04:35:18155 // Any valid SCT.
156 if (CertificateTransparencyStatusMatchAny(sct_verify_statuses,
157 net::ct::SCT_STATUS_OK))
[email protected]94c74b42013-12-02 15:19:49158 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_VERIFIED
159 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_VERIFIED);
160
estark134a9822015-10-29 04:35:18161 // Any invalid SCT.
eranm194b45d2016-08-18 10:00:33162 if (CertificateTransparencyStatusMatchAny(
163 sct_verify_statuses, net::ct::SCT_STATUS_INVALID_TIMESTAMP) ||
164 CertificateTransparencyStatusMatchAny(
165 sct_verify_statuses, net::ct::SCT_STATUS_INVALID_SIGNATURE))
[email protected]94c74b42013-12-02 15:19:49166 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_INVALID
167 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_INVALID);
168
estark134a9822015-10-29 04:35:18169 // All SCTs are from unknown logs.
[email protected]94c74b42013-12-02 15:19:49170 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_UNVERIFIED
171 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_UNVERIFIED);
172}
173
174// This function will return SITE_IDENTITY_STATUS_CERT or
estark134a9822015-10-29 04:35:18175// SITE_IDENTITY_STATUS_EV_CERT depending on |is_ev| unless all SCTs
176// failed verification, in which case it will return
[email protected]94c74b42013-12-02 15:19:49177// SITE_IDENTITY_STATUS_ERROR.
178WebsiteSettings::SiteIdentityStatus GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59179 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49180 bool is_ev) {
estark134a9822015-10-29 04:35:18181 if (sct_verify_statuses.empty() ||
182 CertificateTransparencyStatusMatchAny(sct_verify_statuses,
183 net::ct::SCT_STATUS_OK))
184 return is_ev ? WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT
185 : WebsiteSettings::SITE_IDENTITY_STATUS_CERT;
[email protected]94c74b42013-12-02 15:19:49186
estark134a9822015-10-29 04:35:18187 return WebsiteSettings::SITE_IDENTITY_STATUS_CT_ERROR;
[email protected]94c74b42013-12-02 15:19:49188}
189
jshin1fb76462016-04-05 22:13:03190base::string16 GetSimpleSiteName(const GURL& url) {
benwells2337b8102016-04-20 01:53:53191 return url_formatter::FormatUrlForSecurityDisplay(
192 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
palmer153af982015-09-15 02:04:19193}
194
reillyg85f57db2016-01-12 23:14:38195ChooserContextBase* GetUsbChooserContext(Profile* profile) {
196 return UsbChooserContextFactory::GetForProfile(profile);
197}
198
199// The list of chooser types that need to display entries in the Website
200// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
201// email [email protected].
202WebsiteSettings::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52203 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
204 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_WEBSITE_SETTINGS_USB_DEVICE_LABEL,
reillyg85f57db2016-01-12 23:14:38205 IDS_WEBSITE_SETTINGS_DELETE_USB_DEVICE, "name"},
206};
207
[email protected]0b9fdd72012-04-04 10:00:33208} // namespace
209
210WebsiteSettings::WebsiteSettings(
211 WebsiteSettingsUI* ui,
212 Profile* profile,
[email protected]df818272012-04-20 13:10:50213 TabSpecificContentSettings* tab_specific_content_settings,
palmerf2cba0d2015-08-27 23:15:06214 content::WebContents* web_contents,
[email protected]0b9fdd72012-04-04 10:00:33215 const GURL& url,
estarka3121f6b2015-09-18 21:15:59216 const SecurityStateModel::SecurityInfo& security_info,
[email protected]0b9fdd72012-04-04 10:00:33217 content::CertStore* cert_store)
[email protected]df818272012-04-20 13:10:50218 : TabSpecificContentSettings::SiteDataObserver(
219 tab_specific_content_settings),
220 ui_(ui),
pkastingacd1e122016-05-19 23:55:10221#if !defined(OS_ANDROID)
palmerf2cba0d2015-08-27 23:15:06222 web_contents_(web_contents),
pkastingacd1e122016-05-19 23:55:10223#endif
[email protected]66f157312012-08-01 13:50:26224 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33225 site_url_(url),
226 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]f61c1ce2012-05-09 13:55:11227 cert_id_(0),
[email protected]03ef4b2a2012-03-06 15:04:20228 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
[email protected]0b9fdd72012-04-04 10:00:33229 cert_store_(cert_store),
peconn5100d432015-09-16 12:03:08230 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04231 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25232 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19233 did_revoke_user_ssl_decisions_(false),
234 profile_(profile) {
estarka3121f6b2015-09-18 21:15:59235 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33236
237 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50238 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41239 PresentSiteIdentity();
[email protected]e22d64f2012-09-10 09:03:23240
241 // Every time the Website Settings UI is opened a |WebsiteSettings| object is
242 // created. So this counts how ofter the Website Settings UI is opened.
lgarron04a93502014-11-04 22:25:04243 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20244}
245
[email protected]0b9fdd72012-04-04 10:00:33246WebsiteSettings::~WebsiteSettings() {
[email protected]03ef4b2a2012-03-06 15:04:20247}
248
lgarron04a93502014-11-04 22:25:04249void WebsiteSettings::RecordWebsiteSettingsAction(
250 WebsiteSettingsAction action) {
251 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action",
252 action,
253 WEBSITE_SETTINGS_COUNT);
254
255 // Use a separate histogram to record actions if they are done on a page with
256 // an HTTPS URL. Note that this *disregards* security status.
palmeree0e5af2015-06-05 03:10:40257 //
258
259 // TODO(palmer): Consider adding a new histogram for
260 // GURL::SchemeIsCryptographic. (We don't want to replace this call with a
261 // call to that function because we don't want to change the meanings of
262 // existing metrics.) This would inform the decision to mark non-secure
263 // origins as Dubious or Non-Secure; the overall bug for that is
264 // crbug.com/454579.
lgarron04a93502014-11-04 22:25:04265 if (site_url_.SchemeIs(url::kHttpsScheme)) {
266 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action.HttpsUrl",
267 action,
268 WEBSITE_SETTINGS_COUNT);
269 }
270}
271
[email protected]df818272012-04-20 13:10:50272void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type,
273 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23274 // Count how often a permission for a specific content type is changed using
275 // the Website Settings UI.
raymes4a13d432015-09-08 00:44:07276 size_t num_values;
277 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
sashab9debecd2014-12-18 04:15:56278 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.OriginInfo.PermissionChanged",
raymes4a13d432015-09-08 00:44:07279 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56280
281 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
282 UMA_HISTOGRAM_ENUMERATION(
283 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07284 num_values);
sashab9debecd2014-12-18 04:15:56285 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
286 UMA_HISTOGRAM_ENUMERATION(
287 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07288 num_values);
sashab9debecd2014-12-18 04:15:56289 }
[email protected]e22d64f2012-09-10 09:03:23290
lgarron04a93502014-11-04 22:25:04291 // This is technically redundant given the histogram above, but putting the
292 // total count of permission changes in another histogram makes it easier to
293 // compare it against other kinds of actions in WebsiteSettings[PopupView].
294 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_CHANGED_PERMISSION);
295
stefanocs8b3490cc2016-07-28 05:32:52296 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
297 this->profile_, this->site_url_, this->site_url_, type,
298 PermissionSourceUI::OIB);
299
raymesfbaaaaa2015-11-10 02:20:40300 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
301 setting);
[email protected]df818272012-04-20 13:10:50302
[email protected]66f157312012-08-01 13:50:26303 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24304
[email protected]2f45d542012-08-22 08:47:24305 // Refresh the UI to reflect the new setting.
306 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50307}
308
reillyg85f57db2016-01-12 23:14:38309void WebsiteSettings::OnSiteChosenObjectDeleted(
310 const ChooserUIInfo& ui_info,
311 const base::DictionaryValue& object) {
312 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
313 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10314 const GURL origin = site_url_.GetOrigin();
315 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38316
317 show_info_bar_ = true;
318
319 // Refresh the UI to reflect the changed settings.
320 PresentSitePermissions();
321}
322
[email protected]df818272012-04-20 13:10:50323void WebsiteSettings::OnSiteDataAccessed() {
324 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33325}
326
[email protected]66f157312012-08-01 13:50:26327void WebsiteSettings::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49328#if defined(OS_ANDROID)
329 NOTREACHED();
330#else
palmerf2cba0d2015-08-27 23:15:06331 if (show_info_bar_ && web_contents_) {
332 InfoBarService* infobar_service =
333 InfoBarService::FromWebContents(web_contents_);
334 if (infobar_service)
335 WebsiteSettingsInfoBarDelegate::Create(infobar_service);
336 }
jww1ed8ea72014-09-02 20:43:25337
338 SSLCertificateDecisionsDidRevoke user_decision =
339 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
340 : USER_CERT_DECISIONS_NOT_REVOKED;
341
342 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
343 user_decision,
344 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49345#endif
jww1ed8ea72014-09-02 20:43:25346}
347
348void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() {
349 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29350 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
351 site_url().host());
jww1ed8ea72014-09-02 20:43:25352 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26353}
354
estarka3121f6b2015-09-18 21:15:59355void WebsiteSettings::Init(
356 const GURL& url,
357 const SecurityStateModel::SecurityInfo& security_info) {
sashab97894ce2014-10-22 10:08:33358 bool isChromeUINativeScheme = false;
sievers2f1e8112015-12-04 18:43:56359#if BUILDFLAG(ANDROID_JAVA_UI)
sashab97894ce2014-10-22 10:08:33360 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
361#endif
362
upendrag.gowda60886a6e2015-10-31 05:51:09363 if (url.SchemeIs(url::kAboutScheme)) {
364 // All about: URLs except about:blank are redirected.
365 DCHECK_EQ(url::kAboutBlankURL, url.spec());
366 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
367 site_identity_details_ =
368 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
369 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
370 site_connection_details_ = l10n_util::GetStringFUTF16(
371 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
372 UTF8ToUTF16(url.spec()));
373 return;
374 }
375
376 if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) {
[email protected]03ef4b2a2012-03-06 15:04:20377 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
378 site_identity_details_ =
379 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
380 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
381 return;
382 }
383
[email protected]03ef4b2a2012-03-06 15:04:20384 // Identity section.
palmer153af982015-09-15 02:04:19385 scoped_refptr<net::X509Certificate> cert;
estarka3121f6b2015-09-18 21:15:59386 cert_id_ = security_info.cert_id;
[email protected]f61c1ce2012-05-09 13:55:11387
estarka3121f6b2015-09-18 21:15:59388 // HTTPS with no or minor errors.
389 if (security_info.cert_id &&
390 cert_store_->RetrieveCert(security_info.cert_id, &cert) &&
391 (!net::IsCertStatusError(security_info.cert_status) ||
392 net::IsCertStatusMinorError(security_info.cert_status))) {
[email protected]03ef4b2a2012-03-06 15:04:20393 // There are no major errors. Check for minor errors.
estarka3121f6b2015-09-18 21:15:59394 if (security_info.security_level ==
395 SecurityStateModel::SECURITY_POLICY_WARNING) {
[email protected]eaf3f322013-04-25 21:53:59396 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37397 site_identity_details_ = l10n_util::GetStringFUTF16(
398 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59399 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20400 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
[email protected]a04db822013-12-11 19:14:40401 base::string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20402 if (issuer_name.empty()) {
403 issuer_name.assign(l10n_util::GetStringUTF16(
404 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
405 }
[email protected]94c74b42013-12-02 15:19:49406
[email protected]03ef4b2a2012-03-06 15:04:20407 site_identity_details_.assign(l10n_util::GetStringFUTF16(
[email protected]94c74b42013-12-02 15:19:49408 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59409 security_info.sct_verify_statuses, false /* not EV */),
[email protected]94c74b42013-12-02 15:19:49410 issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20411
412 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59413 if (security_info.cert_status &
414 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20415 site_identity_details_ += l10n_util::GetStringUTF16(
416 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59417 } else if (security_info.cert_status &
418 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20419 site_identity_details_ += l10n_util::GetStringUTF16(
420 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
421 } else {
422 NOTREACHED() << "Need to specify string for this warning";
423 }
[email protected]03ef4b2a2012-03-06 15:04:20424 } else {
estarka3121f6b2015-09-18 21:15:59425 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01426 // EV HTTPS page.
427 site_identity_status_ = GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59428 security_info.sct_verify_statuses, true);
rsleevi4f8012722014-09-30 01:28:01429 DCHECK(!cert->subject().organization_names.empty());
430 organization_name_ = UTF8ToUTF16(cert->subject().organization_names[0]);
431 // An EV Cert is required to have a city (localityName) and country but
432 // state is "if any".
433 DCHECK(!cert->subject().locality_name.empty());
434 DCHECK(!cert->subject().country_name.empty());
435 base::string16 locality;
436 if (!cert->subject().state_or_province_name.empty()) {
437 locality = l10n_util::GetStringFUTF16(
438 IDS_PAGEINFO_ADDRESS,
439 UTF8ToUTF16(cert->subject().locality_name),
440 UTF8ToUTF16(cert->subject().state_or_province_name),
441 UTF8ToUTF16(cert->subject().country_name));
442 } else {
443 locality = l10n_util::GetStringFUTF16(
444 IDS_PAGEINFO_PARTIAL_ADDRESS,
445 UTF8ToUTF16(cert->subject().locality_name),
446 UTF8ToUTF16(cert->subject().country_name));
447 }
448 DCHECK(!cert->subject().organization_names.empty());
449 site_identity_details_.assign(l10n_util::GetStringFUTF16(
450 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59451 security_info.sct_verify_statuses, true /* is EV */),
452 UTF8ToUTF16(cert->subject().organization_names[0]), locality,
rsleevi4f8012722014-09-30 01:28:01453 UTF8ToUTF16(cert->issuer().GetDisplayName())));
454 } else {
455 // Non-EV OK HTTPS page.
456 site_identity_status_ = GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59457 security_info.sct_verify_statuses, false);
rsleevi4f8012722014-09-30 01:28:01458 base::string16 issuer_name(
459 UTF8ToUTF16(cert->issuer().GetDisplayName()));
460 if (issuer_name.empty()) {
461 issuer_name.assign(l10n_util::GetStringUTF16(
462 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
463 }
[email protected]94c74b42013-12-02 15:19:49464
rsleevi4f8012722014-09-30 01:28:01465 site_identity_details_.assign(l10n_util::GetStringFUTF16(
466 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59467 security_info.sct_verify_statuses, false /* not EV */),
rsleevi4f8012722014-09-30 01:28:01468 issuer_name));
469 }
lgarroncc53de22015-10-05 23:03:17470 switch (security_info.sha1_deprecation_status) {
471 case SecurityStateModel::DEPRECATED_SHA1_MINOR:
472 site_identity_status_ =
473 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR;
474 site_identity_details_ +=
475 UTF8ToUTF16("\n\n") +
476 l10n_util::GetStringUTF16(
477 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MINOR);
478 break;
479 case SecurityStateModel::DEPRECATED_SHA1_MAJOR:
480 site_identity_status_ =
481 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR;
482 site_identity_details_ +=
483 UTF8ToUTF16("\n\n") +
484 l10n_util::GetStringUTF16(
485 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR);
486 break;
487 case SecurityStateModel::NO_DEPRECATED_SHA1:
488 // Nothing to do.
489 break;
felt61638452016-08-09 22:21:55490 case SecurityStateModel::UNKNOWN_SHA1:
491 // UNKNOWN_SHA1 should only appear when certificate info has not been
492 // initialized, in which case this if-statement should not be running
493 // because there is no other cert info.
494 NOTREACHED();
rsleevi4f8012722014-09-30 01:28:01495 }
[email protected]03ef4b2a2012-03-06 15:04:20496 }
497 } else {
498 // HTTP or HTTPS with errors (not warnings).
499 site_identity_details_.assign(l10n_util::GetStringUTF16(
500 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
estarka3121f6b2015-09-18 21:15:59501 if (!security_info.scheme_is_cryptographic || !security_info.cert_id)
[email protected]03ef4b2a2012-03-06 15:04:20502 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
503 else
504 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
505
[email protected]a04db822013-12-11 19:14:40506 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59507 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59508 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
509 cert, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20510 for (size_t i = 0; i < errors.size(); ++i) {
511 site_identity_details_ += bullet;
512 site_identity_details_ += errors[i].short_description();
513 }
514
estarka3121f6b2015-09-18 21:15:59515 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20516 site_identity_details_ += ASCIIToUTF16("\n\n");
517 site_identity_details_ += l10n_util::GetStringUTF16(
518 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
519 }
520 }
521
522 // Site Connection
523 // We consider anything less than 80 bits encryption to be weak encryption.
524 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
525 // weakly encrypted connections.
526 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
527
jshin1fb76462016-04-05 22:13:03528 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19529 if (subject_name.empty()) {
530 subject_name.assign(
531 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
532 }
533
estarka3121f6b2015-09-18 21:15:59534 if (!security_info.cert_id || !security_info.scheme_is_cryptographic) {
535 // Page is still loading (so SSL status is not yet available) or
536 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58537 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
538
539 site_connection_details_.assign(l10n_util::GetStringFUTF16(
540 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
541 subject_name));
estarka3121f6b2015-09-18 21:15:59542 } else if (security_info.security_bits < 0) {
543 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20544 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59545 } else if (security_info.security_bits == 0) {
546 DCHECK_NE(security_info.security_level, SecurityStateModel::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20547 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
548 site_connection_details_.assign(l10n_util::GetStringFUTF16(
549 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
550 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20551 } else {
552 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22553
estarkfd5ca022015-10-29 21:07:55554 if (security_info.is_secure_protocol_and_ciphersuite) {
Adam Langley71c2b59b2014-11-13 00:34:22555 site_connection_details_.assign(l10n_util::GetStringFUTF16(
556 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
557 subject_name));
558 } else {
559 site_connection_details_.assign(l10n_util::GetStringFUTF16(
560 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
561 subject_name));
562 }
563
estarka3121f6b2015-09-18 21:15:59564 if (security_info.mixed_content_status !=
estark54f191f2016-08-12 00:27:32565 SecurityStateModel::CONTENT_STATUS_NONE) {
[email protected]03ef4b2a2012-03-06 15:04:20566 bool ran_insecure_content =
estarka3121f6b2015-09-18 21:15:59567 (security_info.mixed_content_status ==
estark54f191f2016-08-12 00:27:32568 SecurityStateModel::CONTENT_STATUS_RAN ||
estarka3121f6b2015-09-18 21:15:59569 security_info.mixed_content_status ==
estark54f191f2016-08-12 00:27:32570 SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN);
palmercc7f5f8c2015-09-04 01:02:59571 site_connection_status_ = ran_insecure_content
572 ? SITE_CONNECTION_STATUS_MIXED_SCRIPT
573 : SITE_CONNECTION_STATUS_MIXED_CONTENT;
[email protected]03ef4b2a2012-03-06 15:04:20574 site_connection_details_.assign(l10n_util::GetStringFUTF16(
575 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
576 site_connection_details_,
577 l10n_util::GetStringUTF16(ran_insecure_content ?
578 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR :
579 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
580 }
581 }
582
avi655876a2015-12-25 07:18:15583 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59584 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
585 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20586 int ssl_version =
estarka3121f6b2015-09-18 21:15:59587 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20588 const char* ssl_version_str;
589 net::SSLVersionToString(&ssl_version_str, ssl_version);
590 site_connection_details_ += ASCIIToUTF16("\n\n");
591 site_connection_details_ += l10n_util::GetStringFUTF16(
592 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION,
593 ASCIIToUTF16(ssl_version_str));
594
[email protected]03ef4b2a2012-03-06 15:04:20595 bool no_renegotiation =
estarka3121f6b2015-09-18 21:15:59596 (security_info.connection_status &
597 net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20598 const char *key_exchange, *cipher, *mac;
[email protected]b6c1d9e82013-06-12 17:26:57599 bool is_aead;
600 net::SSLCipherSuiteToStrings(
601 &key_exchange, &cipher, &mac, &is_aead, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20602
603 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57604 if (is_aead) {
605 site_connection_details_ += l10n_util::GetStringFUTF16(
606 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
607 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
608 } else {
609 site_connection_details_ += l10n_util::GetStringFUTF16(
610 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS,
611 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
612 }
[email protected]03ef4b2a2012-03-06 15:04:20613
agl078d2102014-10-20 22:03:22614 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 &&
615 site_connection_status_ < SITE_CONNECTION_STATUS_MIXED_CONTENT) {
616 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
617 }
618
estarka3121f6b2015-09-18 21:15:59619 const bool did_fallback = (security_info.connection_status &
620 net::SSL_CONNECTION_VERSION_FALLBACK) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20621 if (did_fallback) {
[email protected]03ef4b2a2012-03-06 15:04:20622 site_connection_details_ += ASCIIToUTF16("\n\n");
623 site_connection_details_ += l10n_util::GetStringUTF16(
624 IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE);
625 }
agl078d2102014-10-20 22:03:22626
[email protected]03ef4b2a2012-03-06 15:04:20627 if (no_renegotiation) {
628 site_connection_details_ += ASCIIToUTF16("\n\n");
629 site_connection_details_ += l10n_util::GetStringUTF16(
630 IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE);
631 }
632 }
[email protected]e583f752012-08-30 13:26:21633
[email protected]71cd5ef2014-08-13 21:22:04634 // Check if a user decision has been made to allow or deny certificates with
635 // errors on this site.
636 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50637 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04638 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40639 // Only show an SSL decision revoke button if the user has chosen to bypass
640 // SSL host errors for this host in the past.
641 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]71cd5ef2014-08-13 21:22:04642
palmer82b1f7b2015-09-17 19:20:41643 // By default select the Permissions Tab that displays all the site
644 // permissions. In case of a connection error or an issue with the certificate
645 // presented by the website, select the Connection Tab to draw the user's
646 // attention to the issue. If the site does not provide a certificate because
647 // it was loaded over an unencrypted connection, don't select the Connection
648 // Tab.
[email protected]e583f752012-08-30 13:26:21649 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS;
650 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR ||
651 site_connection_status_ == SITE_CONNECTION_STATUS_MIXED_CONTENT ||
estarkf62683e2015-09-17 17:52:06652 site_connection_status_ == SITE_CONNECTION_STATUS_MIXED_SCRIPT ||
[email protected]e583f752012-08-30 13:26:21653 site_identity_status_ == SITE_IDENTITY_STATUS_ERROR ||
estark134a9822015-10-29 04:35:18654 site_identity_status_ == SITE_IDENTITY_STATUS_CT_ERROR ||
[email protected]eaf3f322013-04-25 21:53:59655 site_identity_status_ == SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN ||
rsleevi4f8012722014-09-30 01:28:01656 site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT ||
657 site_identity_status_ ==
lgarroncc53de22015-10-05 23:03:17658 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR ||
659 site_identity_status_ ==
660 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR) {
[email protected]e583f752012-08-30 13:26:21661 tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION;
lgarron04a93502014-11-04 22:25:04662 RecordWebsiteSettingsAction(
663 WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY);
664 }
palmer82b1f7b2015-09-17 19:20:41665
[email protected]e583f752012-08-30 13:26:21666 ui_->SetSelectedTab(tab_id);
[email protected]03ef4b2a2012-03-06 15:04:20667}
[email protected]0b9fdd72012-04-04 10:00:33668
[email protected]df818272012-04-20 13:10:50669void WebsiteSettings::PresentSitePermissions() {
670 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38671 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50672
673 WebsiteSettingsUI::PermissionInfo permission_info;
674 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
675 permission_info.type = kPermissionType[i];
676
mgiucaa319f212016-01-14 03:30:11677 if (!ShouldShowPermission(permission_info.type))
678 continue;
679
[email protected]df818272012-04-20 13:10:50680 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32681 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
682 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21683 DCHECK(value.get());
684 if (value->GetType() == base::Value::TYPE_INTEGER) {
685 permission_info.setting =
686 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26687 } else {
sashab2b2a314f2015-01-17 06:42:21688 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26689 }
690
[email protected]8bdf45c32012-08-04 00:12:55691 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28692 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50693
[email protected]b1d113d2012-06-27 21:27:34694 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21695 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34696 permission_info.default_setting = permission_info.setting;
697 permission_info.setting = CONTENT_SETTING_DEFAULT;
698 } else {
699 permission_info.default_setting =
700 content_settings_->GetDefaultContentSetting(permission_info.type,
701 NULL);
[email protected]df818272012-04-20 13:10:50702 }
palmer0da10b32015-02-11 00:42:19703
palmer64a099982016-03-09 21:26:11704 if (permission_info.type == CONTENT_SETTINGS_TYPE_KEYGEN &&
705 (permission_info.setting == CONTENT_SETTING_DEFAULT ||
706 permission_info.setting == permission_info.default_setting) &&
707 !tab_specific_content_settings()->IsContentBlocked(
708 permission_info.type)) {
709 continue;
palmer0da10b32015-02-11 00:42:19710 }
palmer64a099982016-03-09 21:26:11711 permission_info_list.push_back(permission_info);
[email protected]df818272012-04-20 13:10:50712 }
713
reillyg85f57db2016-01-12 23:14:38714 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
715 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10716 const GURL origin = site_url_.GetOrigin();
717 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32718 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38719 chosen_object_info_list.push_back(
720 new WebsiteSettingsUI::ChosenObjectInfo(ui_info, std::move(object)));
721 }
722 }
723
724 ui_->SetPermissionInfo(permission_info_list, chosen_object_info_list);
[email protected]0b9fdd72012-04-04 10:00:33725}
726
[email protected]df818272012-04-20 13:10:50727void WebsiteSettings::PresentSiteData() {
728 CookieInfoList cookie_info_list;
vabrd5e30cd2014-10-02 11:06:03729 const LocalSharedObjectsCounter& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34730 tab_specific_content_settings()->allowed_local_shared_objects();
vabrd5e30cd2014-10-02 11:06:03731 const LocalSharedObjectsCounter& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34732 tab_specific_content_settings()->blocked_local_shared_objects();
733
734 // Add first party cookie and site data counts.
[email protected]df818272012-04-20 13:10:50735 WebsiteSettingsUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34736 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
737 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15738 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34739 cookie_info_list.push_back(cookie_info);
740
741 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34742 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
743 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15744 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50745 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33746
[email protected]df818272012-04-20 13:10:50747 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33748}
[email protected]16de6de2012-04-04 12:24:14749
[email protected]24c8818c2012-04-25 09:57:41750void WebsiteSettings::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04751 // After initialization the status about the site's connection and its
752 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41753 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
754 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
755 WebsiteSettingsUI::IdentityInfo info;
756 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
757 info.site_identity = UTF16ToUTF8(organization_name());
758 else
jshin1fb76462016-04-05 22:13:03759 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41760
761 info.connection_status = site_connection_status_;
762 info.connection_status_description =
763 UTF16ToUTF8(site_connection_details_);
764 info.identity_status = site_identity_status_;
765 info.identity_status_description =
766 UTF16ToUTF8(site_identity_details_);
[email protected]f61c1ce2012-05-09 13:55:11767 info.cert_id = cert_id_;
[email protected]71cd5ef2014-08-13 21:22:04768 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
[email protected]24c8818c2012-04-25 09:57:41769 ui_->SetIdentityInfo(info);
770}