blob: 773a552e9dcc8bc4ee579926925a70a17b90a32c [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"
palmer153af982015-09-15 02:04:1944#include "chrome/common/pref_names.h"
jsbellddb849e2015-08-27 00:12:5645#include "chrome/common/url_constants.h"
thestig884a1602014-08-27 01:29:3946#include "chrome/grit/chromium_strings.h"
47#include "chrome/grit/generated_resources.h"
reillyg85f57db2016-01-12 23:14:3848#include "chrome/grit/theme_resources.h"
mukai8eaec822014-10-25 17:53:1649#include "components/content_settings/core/browser/content_settings_utils.h"
50#include "components/content_settings/core/browser/host_content_settings_map.h"
vabr48565592014-10-08 15:06:0251#include "components/content_settings/core/browser/local_shared_objects_counter.h"
palmer0da10b32015-02-11 00:42:1952#include "components/content_settings/core/common/content_settings.h"
vasiliif62dbf92014-09-05 10:23:1353#include "components/content_settings/core/common/content_settings_pattern.h"
jialiul02aad2d2015-04-01 18:56:0354#include "components/rappor/rappor_utils.h"
felt2493b4452015-09-17 20:33:5955#include "components/ssl_errors/error_info.h"
palmer153af982015-09-15 02:04:1956#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3357#include "content/public/browser/browser_thread.h"
[email protected]b59c6cf02012-03-12 20:51:4258#include "content/public/browser/cert_store.h"
tsergeantf1e89352016-01-15 20:34:5459#include "content/public/browser/permission_type.h"
[email protected]e22d64f2012-09-10 09:03:2360#include "content/public/browser/user_metrics.h"
[email protected]eb2140c2013-07-29 12:37:3461#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2062#include "content/public/common/url_constants.h"
[email protected]6e7845ae2013-03-29 21:48:1163#include "net/cert/cert_status_flags.h"
64#include "net/cert/x509_certificate.h"
[email protected]536fd0b2013-03-14 17:41:5765#include "net/ssl/ssl_cipher_suite_names.h"
66#include "net/ssl/ssl_connection_status_flags.h"
[email protected]03ef4b2a2012-03-06 15:04:2067#include "ui/base/l10n/l10n_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2068
[email protected]24a9f1c92013-11-13 12:33:3769#if defined(OS_CHROMEOS)
70#include "chrome/browser/chromeos/policy/policy_cert_service.h"
71#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
72#endif
73
estade3feb83f2015-09-01 23:00:4974#if !defined(OS_ANDROID)
mgiucaa319f212016-01-14 03:30:1175#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
estade3feb83f2015-09-01 23:00:4976#include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h"
77#endif
78
[email protected]ab6df3b12013-12-24 23:32:2679using base::ASCIIToUTF16;
80using base::UTF8ToUTF16;
[email protected]f729d7a2013-12-26 07:07:5681using base::UTF16ToUTF8;
[email protected]0b9fdd72012-04-04 10:00:3382using content::BrowserThread;
estarkd9e54fb2016-01-11 19:37:1283using security_state::SecurityStateModel;
[email protected]0b9fdd72012-04-04 10:00:3384
85namespace {
86
jww1ed8ea72014-09-02 20:43:2587// Events for UMA. Do not reorder or change!
88enum SSLCertificateDecisionsDidRevoke {
89 USER_CERT_DECISIONS_NOT_REVOKED = 0,
90 USER_CERT_DECISIONS_REVOKED,
91 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM
92};
93
palmer0da10b32015-02-11 00:42:1994// The list of content settings types to display on the Website Settings UI. THE
95// ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, email
96// [email protected].
[email protected]0b9fdd72012-04-04 10:00:3397ContentSettingsType kPermissionType[] = {
sashab2b2a314f2015-01-17 06:42:2198 CONTENT_SETTINGS_TYPE_GEOLOCATION,
sashab2b2a314f2015-01-17 06:42:2199 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
100 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
palmer0da10b32015-02-11 00:42:19101 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
102 CONTENT_SETTINGS_TYPE_IMAGES,
103 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
104 CONTENT_SETTINGS_TYPE_POPUPS,
105 CONTENT_SETTINGS_TYPE_FULLSCREEN,
sashab2b2a314f2015-01-17 06:42:21106 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
palmer0da10b32015-02-11 00:42:19107 CONTENT_SETTINGS_TYPE_PLUGINS,
108 CONTENT_SETTINGS_TYPE_MOUSELOCK,
sashab2b2a314f2015-01-17 06:42:21109 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
benwellsa68ed4b2014-11-13 03:25:36110#if defined(OS_ANDROID)
sashab2b2a314f2015-01-17 06:42:21111 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
benwellsa68ed4b2014-11-13 03:25:36112#endif
svaldez18120952016-01-14 21:12:49113 CONTENT_SETTINGS_TYPE_KEYGEN,
[email protected]0b9fdd72012-04-04 10:00:33114};
115
mgiucaa319f212016-01-14 03:30:11116// Determines whether to show permission |type| in the Website Settings UI. Only
117// applies to permissions listed in |kPermissionType|.
118bool ShouldShowPermission(ContentSettingsType type) {
119 // TODO(mgiuca): When simplified-fullscreen-ui is enabled on all platforms,
120 // remove these from kPermissionType, rather than having this check
121 // (http://crbug.com/577396).
122#if !defined(OS_ANDROID)
123 // Fullscreen and mouselock settings are not shown in simplified fullscreen
124 // mode (always allow).
125 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN ||
126 type == CONTENT_SETTINGS_TYPE_MOUSELOCK) {
127 return !ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled();
128 }
129#endif
130
131 return true;
132}
133
estark134a9822015-10-29 04:35:18134// Returns true if any of the given statuses match |status|.
135bool CertificateTransparencyStatusMatchAny(
estarka3121f6b2015-09-18 21:15:59136 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49137 net::ct::SCTVerifyStatus status) {
estarka3121f6b2015-09-18 21:15:59138 for (const auto& verify_status : sct_verify_statuses) {
139 if (verify_status == status)
[email protected]94c74b42013-12-02 15:19:49140 return true;
141 }
[email protected]94c74b42013-12-02 15:19:49142 return false;
143}
144
145int GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59146 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49147 bool is_ev) {
148 // No SCTs - no CT information.
estarka3121f6b2015-09-18 21:15:59149 if (sct_verify_statuses.empty())
[email protected]94c74b42013-12-02 15:19:49150 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_NO_CT
151 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_NO_CT);
152
estark134a9822015-10-29 04:35:18153 // Any valid SCT.
154 if (CertificateTransparencyStatusMatchAny(sct_verify_statuses,
155 net::ct::SCT_STATUS_OK))
[email protected]94c74b42013-12-02 15:19:49156 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_VERIFIED
157 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_VERIFIED);
158
estark134a9822015-10-29 04:35:18159 // Any invalid SCT.
160 if (CertificateTransparencyStatusMatchAny(sct_verify_statuses,
161 net::ct::SCT_STATUS_INVALID))
[email protected]94c74b42013-12-02 15:19:49162 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_INVALID
163 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_INVALID);
164
estark134a9822015-10-29 04:35:18165 // All SCTs are from unknown logs.
[email protected]94c74b42013-12-02 15:19:49166 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_UNVERIFIED
167 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_UNVERIFIED);
168}
169
170// This function will return SITE_IDENTITY_STATUS_CERT or
estark134a9822015-10-29 04:35:18171// SITE_IDENTITY_STATUS_EV_CERT depending on |is_ev| unless all SCTs
172// failed verification, in which case it will return
[email protected]94c74b42013-12-02 15:19:49173// SITE_IDENTITY_STATUS_ERROR.
174WebsiteSettings::SiteIdentityStatus GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59175 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49176 bool is_ev) {
estark134a9822015-10-29 04:35:18177 if (sct_verify_statuses.empty() ||
178 CertificateTransparencyStatusMatchAny(sct_verify_statuses,
179 net::ct::SCT_STATUS_OK))
180 return is_ev ? WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT
181 : WebsiteSettings::SITE_IDENTITY_STATUS_CERT;
[email protected]94c74b42013-12-02 15:19:49182
estark134a9822015-10-29 04:35:18183 return WebsiteSettings::SITE_IDENTITY_STATUS_CT_ERROR;
[email protected]94c74b42013-12-02 15:19:49184}
185
palmer153af982015-09-15 02:04:19186base::string16 GetSimpleSiteName(const GURL& url, Profile* profile) {
187 std::string languages;
188 if (profile)
189 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
190 return url_formatter::FormatUrlForSecurityDisplayOmitScheme(url, languages);
191}
192
reillyg85f57db2016-01-12 23:14:38193ChooserContextBase* GetUsbChooserContext(Profile* profile) {
194 return UsbChooserContextFactory::GetForProfile(profile);
195}
196
197// The list of chooser types that need to display entries in the Website
198// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
199// email [email protected].
200WebsiteSettings::ChooserUIInfo kChooserUIInfo[] = {
201 {&GetUsbChooserContext, IDR_BLOCKED_USB, IDR_ALLOWED_USB,
202 IDS_WEBSITE_SETTINGS_USB_DEVICE_LABEL,
203 IDS_WEBSITE_SETTINGS_DELETE_USB_DEVICE, "name"},
204};
205
[email protected]0b9fdd72012-04-04 10:00:33206} // namespace
207
208WebsiteSettings::WebsiteSettings(
209 WebsiteSettingsUI* ui,
210 Profile* profile,
[email protected]df818272012-04-20 13:10:50211 TabSpecificContentSettings* tab_specific_content_settings,
palmerf2cba0d2015-08-27 23:15:06212 content::WebContents* web_contents,
[email protected]0b9fdd72012-04-04 10:00:33213 const GURL& url,
estarka3121f6b2015-09-18 21:15:59214 const SecurityStateModel::SecurityInfo& security_info,
[email protected]0b9fdd72012-04-04 10:00:33215 content::CertStore* cert_store)
[email protected]df818272012-04-20 13:10:50216 : TabSpecificContentSettings::SiteDataObserver(
217 tab_specific_content_settings),
218 ui_(ui),
palmerf2cba0d2015-08-27 23:15:06219 web_contents_(web_contents),
[email protected]66f157312012-08-01 13:50:26220 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33221 site_url_(url),
222 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]f61c1ce2012-05-09 13:55:11223 cert_id_(0),
[email protected]03ef4b2a2012-03-06 15:04:20224 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
[email protected]0b9fdd72012-04-04 10:00:33225 cert_store_(cert_store),
peconn5100d432015-09-16 12:03:08226 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04227 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25228 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19229 did_revoke_user_ssl_decisions_(false),
230 profile_(profile) {
estarka3121f6b2015-09-18 21:15:59231 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33232
233 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50234 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41235 PresentSiteIdentity();
[email protected]e22d64f2012-09-10 09:03:23236
237 // Every time the Website Settings UI is opened a |WebsiteSettings| object is
238 // created. So this counts how ofter the Website Settings UI is opened.
lgarron04a93502014-11-04 22:25:04239 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20240}
241
[email protected]0b9fdd72012-04-04 10:00:33242WebsiteSettings::~WebsiteSettings() {
[email protected]03ef4b2a2012-03-06 15:04:20243}
244
lgarron04a93502014-11-04 22:25:04245void WebsiteSettings::RecordWebsiteSettingsAction(
246 WebsiteSettingsAction action) {
247 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action",
248 action,
249 WEBSITE_SETTINGS_COUNT);
250
251 // Use a separate histogram to record actions if they are done on a page with
252 // an HTTPS URL. Note that this *disregards* security status.
palmeree0e5af2015-06-05 03:10:40253 //
254
255 // TODO(palmer): Consider adding a new histogram for
256 // GURL::SchemeIsCryptographic. (We don't want to replace this call with a
257 // call to that function because we don't want to change the meanings of
258 // existing metrics.) This would inform the decision to mark non-secure
259 // origins as Dubious or Non-Secure; the overall bug for that is
260 // crbug.com/454579.
lgarron04a93502014-11-04 22:25:04261 if (site_url_.SchemeIs(url::kHttpsScheme)) {
262 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action.HttpsUrl",
263 action,
264 WEBSITE_SETTINGS_COUNT);
265 }
266}
267
[email protected]df818272012-04-20 13:10:50268void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type,
269 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23270 // Count how often a permission for a specific content type is changed using
271 // the Website Settings UI.
raymes4a13d432015-09-08 00:44:07272 size_t num_values;
273 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
sashab9debecd2014-12-18 04:15:56274 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.OriginInfo.PermissionChanged",
raymes4a13d432015-09-08 00:44:07275 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56276
277 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
278 UMA_HISTOGRAM_ENUMERATION(
279 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07280 num_values);
sashab9debecd2014-12-18 04:15:56281 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
282 UMA_HISTOGRAM_ENUMERATION(
283 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07284 num_values);
jialiul02aad2d2015-04-01 18:56:03285 // Trigger Rappor sampling if it is a permission revoke action.
tsergeantf1e89352016-01-15 20:34:54286 content::PermissionType permission_type;
287 if (PermissionUtil::GetPermissionType(type, &permission_type)) {
288 PermissionUmaUtil::PermissionRevoked(permission_type,
289 this->site_url_);
jialiul02aad2d2015-04-01 18:56:03290 }
sashab9debecd2014-12-18 04:15:56291 }
[email protected]e22d64f2012-09-10 09:03:23292
lgarron04a93502014-11-04 22:25:04293 // This is technically redundant given the histogram above, but putting the
294 // total count of permission changes in another histogram makes it easier to
295 // compare it against other kinds of actions in WebsiteSettings[PopupView].
296 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_CHANGED_PERMISSION);
297
raymesfbaaaaa2015-11-10 02:20:40298 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
299 setting);
[email protected]df818272012-04-20 13:10:50300
[email protected]66f157312012-08-01 13:50:26301 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24302
[email protected]2f45d542012-08-22 08:47:24303 // Refresh the UI to reflect the new setting.
304 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50305}
306
reillyg85f57db2016-01-12 23:14:38307void WebsiteSettings::OnSiteChosenObjectDeleted(
308 const ChooserUIInfo& ui_info,
309 const base::DictionaryValue& object) {
310 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
311 ChooserContextBase* context = ui_info.get_context(profile_);
312 context->RevokeObjectPermission(site_url_, site_url_, object);
313
314 show_info_bar_ = true;
315
316 // Refresh the UI to reflect the changed settings.
317 PresentSitePermissions();
318}
319
[email protected]df818272012-04-20 13:10:50320void WebsiteSettings::OnSiteDataAccessed() {
321 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33322}
323
[email protected]66f157312012-08-01 13:50:26324void WebsiteSettings::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49325#if defined(OS_ANDROID)
326 NOTREACHED();
327#else
palmerf2cba0d2015-08-27 23:15:06328 if (show_info_bar_ && web_contents_) {
329 InfoBarService* infobar_service =
330 InfoBarService::FromWebContents(web_contents_);
331 if (infobar_service)
332 WebsiteSettingsInfoBarDelegate::Create(infobar_service);
333 }
jww1ed8ea72014-09-02 20:43:25334
335 SSLCertificateDecisionsDidRevoke user_decision =
336 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
337 : USER_CERT_DECISIONS_NOT_REVOKED;
338
339 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
340 user_decision,
341 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49342#endif
jww1ed8ea72014-09-02 20:43:25343}
344
345void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() {
346 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29347 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
348 site_url().host());
jww1ed8ea72014-09-02 20:43:25349 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26350}
351
estarka3121f6b2015-09-18 21:15:59352void WebsiteSettings::Init(
353 const GURL& url,
354 const SecurityStateModel::SecurityInfo& security_info) {
sashab97894ce2014-10-22 10:08:33355 bool isChromeUINativeScheme = false;
sievers2f1e8112015-12-04 18:43:56356#if BUILDFLAG(ANDROID_JAVA_UI)
sashab97894ce2014-10-22 10:08:33357 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
358#endif
359
upendrag.gowda60886a6e2015-10-31 05:51:09360 if (url.SchemeIs(url::kAboutScheme)) {
361 // All about: URLs except about:blank are redirected.
362 DCHECK_EQ(url::kAboutBlankURL, url.spec());
363 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
364 site_identity_details_ =
365 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
366 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
367 site_connection_details_ = l10n_util::GetStringFUTF16(
368 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
369 UTF8ToUTF16(url.spec()));
370 return;
371 }
372
373 if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) {
[email protected]03ef4b2a2012-03-06 15:04:20374 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
375 site_identity_details_ =
376 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
377 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
378 return;
379 }
380
[email protected]03ef4b2a2012-03-06 15:04:20381 // Identity section.
palmer153af982015-09-15 02:04:19382 scoped_refptr<net::X509Certificate> cert;
estarka3121f6b2015-09-18 21:15:59383 cert_id_ = security_info.cert_id;
[email protected]f61c1ce2012-05-09 13:55:11384
estarka3121f6b2015-09-18 21:15:59385 // HTTPS with no or minor errors.
386 if (security_info.cert_id &&
387 cert_store_->RetrieveCert(security_info.cert_id, &cert) &&
388 (!net::IsCertStatusError(security_info.cert_status) ||
389 net::IsCertStatusMinorError(security_info.cert_status))) {
[email protected]03ef4b2a2012-03-06 15:04:20390 // There are no major errors. Check for minor errors.
estarka3121f6b2015-09-18 21:15:59391 if (security_info.security_level ==
392 SecurityStateModel::SECURITY_POLICY_WARNING) {
[email protected]eaf3f322013-04-25 21:53:59393 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37394 site_identity_details_ = l10n_util::GetStringFUTF16(
395 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59396 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20397 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
[email protected]a04db822013-12-11 19:14:40398 base::string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20399 if (issuer_name.empty()) {
400 issuer_name.assign(l10n_util::GetStringUTF16(
401 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
402 }
[email protected]94c74b42013-12-02 15:19:49403
[email protected]03ef4b2a2012-03-06 15:04:20404 site_identity_details_.assign(l10n_util::GetStringFUTF16(
[email protected]94c74b42013-12-02 15:19:49405 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59406 security_info.sct_verify_statuses, false /* not EV */),
[email protected]94c74b42013-12-02 15:19:49407 issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20408
409 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59410 if (security_info.cert_status &
411 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20412 site_identity_details_ += l10n_util::GetStringUTF16(
413 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59414 } else if (security_info.cert_status &
415 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20416 site_identity_details_ += l10n_util::GetStringUTF16(
417 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
418 } else {
419 NOTREACHED() << "Need to specify string for this warning";
420 }
[email protected]03ef4b2a2012-03-06 15:04:20421 } else {
estarka3121f6b2015-09-18 21:15:59422 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01423 // EV HTTPS page.
424 site_identity_status_ = GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59425 security_info.sct_verify_statuses, true);
rsleevi4f8012722014-09-30 01:28:01426 DCHECK(!cert->subject().organization_names.empty());
427 organization_name_ = UTF8ToUTF16(cert->subject().organization_names[0]);
428 // An EV Cert is required to have a city (localityName) and country but
429 // state is "if any".
430 DCHECK(!cert->subject().locality_name.empty());
431 DCHECK(!cert->subject().country_name.empty());
432 base::string16 locality;
433 if (!cert->subject().state_or_province_name.empty()) {
434 locality = l10n_util::GetStringFUTF16(
435 IDS_PAGEINFO_ADDRESS,
436 UTF8ToUTF16(cert->subject().locality_name),
437 UTF8ToUTF16(cert->subject().state_or_province_name),
438 UTF8ToUTF16(cert->subject().country_name));
439 } else {
440 locality = l10n_util::GetStringFUTF16(
441 IDS_PAGEINFO_PARTIAL_ADDRESS,
442 UTF8ToUTF16(cert->subject().locality_name),
443 UTF8ToUTF16(cert->subject().country_name));
444 }
445 DCHECK(!cert->subject().organization_names.empty());
446 site_identity_details_.assign(l10n_util::GetStringFUTF16(
447 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59448 security_info.sct_verify_statuses, true /* is EV */),
449 UTF8ToUTF16(cert->subject().organization_names[0]), locality,
rsleevi4f8012722014-09-30 01:28:01450 UTF8ToUTF16(cert->issuer().GetDisplayName())));
451 } else {
452 // Non-EV OK HTTPS page.
453 site_identity_status_ = GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59454 security_info.sct_verify_statuses, false);
rsleevi4f8012722014-09-30 01:28:01455 base::string16 issuer_name(
456 UTF8ToUTF16(cert->issuer().GetDisplayName()));
457 if (issuer_name.empty()) {
458 issuer_name.assign(l10n_util::GetStringUTF16(
459 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
460 }
[email protected]94c74b42013-12-02 15:19:49461
rsleevi4f8012722014-09-30 01:28:01462 site_identity_details_.assign(l10n_util::GetStringFUTF16(
463 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59464 security_info.sct_verify_statuses, false /* not EV */),
rsleevi4f8012722014-09-30 01:28:01465 issuer_name));
466 }
lgarroncc53de22015-10-05 23:03:17467 switch (security_info.sha1_deprecation_status) {
468 case SecurityStateModel::DEPRECATED_SHA1_MINOR:
469 site_identity_status_ =
470 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR;
471 site_identity_details_ +=
472 UTF8ToUTF16("\n\n") +
473 l10n_util::GetStringUTF16(
474 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MINOR);
475 break;
476 case SecurityStateModel::DEPRECATED_SHA1_MAJOR:
477 site_identity_status_ =
478 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR;
479 site_identity_details_ +=
480 UTF8ToUTF16("\n\n") +
481 l10n_util::GetStringUTF16(
482 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR);
483 break;
484 case SecurityStateModel::NO_DEPRECATED_SHA1:
485 // Nothing to do.
486 break;
rsleevi4f8012722014-09-30 01:28:01487 }
[email protected]03ef4b2a2012-03-06 15:04:20488 }
489 } else {
490 // HTTP or HTTPS with errors (not warnings).
491 site_identity_details_.assign(l10n_util::GetStringUTF16(
492 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
estarka3121f6b2015-09-18 21:15:59493 if (!security_info.scheme_is_cryptographic || !security_info.cert_id)
[email protected]03ef4b2a2012-03-06 15:04:20494 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
495 else
496 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
497
[email protected]a04db822013-12-11 19:14:40498 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59499 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59500 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
501 cert, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20502 for (size_t i = 0; i < errors.size(); ++i) {
503 site_identity_details_ += bullet;
504 site_identity_details_ += errors[i].short_description();
505 }
506
estarka3121f6b2015-09-18 21:15:59507 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20508 site_identity_details_ += ASCIIToUTF16("\n\n");
509 site_identity_details_ += l10n_util::GetStringUTF16(
510 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
511 }
512 }
513
514 // Site Connection
515 // We consider anything less than 80 bits encryption to be weak encryption.
516 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
517 // weakly encrypted connections.
518 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
519
palmer153af982015-09-15 02:04:19520 base::string16 subject_name(GetSimpleSiteName(url, profile_));
521 if (subject_name.empty()) {
522 subject_name.assign(
523 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
524 }
525
estarka3121f6b2015-09-18 21:15:59526 if (!security_info.cert_id || !security_info.scheme_is_cryptographic) {
527 // Page is still loading (so SSL status is not yet available) or
528 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58529 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
530
531 site_connection_details_.assign(l10n_util::GetStringFUTF16(
532 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
533 subject_name));
estarka3121f6b2015-09-18 21:15:59534 } else if (security_info.security_bits < 0) {
535 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20536 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59537 } else if (security_info.security_bits == 0) {
538 DCHECK_NE(security_info.security_level, SecurityStateModel::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20539 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
540 site_connection_details_.assign(l10n_util::GetStringFUTF16(
541 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
542 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20543 } else {
544 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22545
estarkfd5ca022015-10-29 21:07:55546 if (security_info.is_secure_protocol_and_ciphersuite) {
Adam Langley71c2b59b2014-11-13 00:34:22547 site_connection_details_.assign(l10n_util::GetStringFUTF16(
548 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
549 subject_name));
550 } else {
551 site_connection_details_.assign(l10n_util::GetStringFUTF16(
552 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
553 subject_name));
554 }
555
estarka3121f6b2015-09-18 21:15:59556 if (security_info.mixed_content_status !=
557 SecurityStateModel::NO_MIXED_CONTENT) {
[email protected]03ef4b2a2012-03-06 15:04:20558 bool ran_insecure_content =
estarka3121f6b2015-09-18 21:15:59559 (security_info.mixed_content_status ==
560 SecurityStateModel::RAN_MIXED_CONTENT ||
561 security_info.mixed_content_status ==
562 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT);
palmercc7f5f8c2015-09-04 01:02:59563 site_connection_status_ = ran_insecure_content
564 ? SITE_CONNECTION_STATUS_MIXED_SCRIPT
565 : SITE_CONNECTION_STATUS_MIXED_CONTENT;
[email protected]03ef4b2a2012-03-06 15:04:20566 site_connection_details_.assign(l10n_util::GetStringFUTF16(
567 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
568 site_connection_details_,
569 l10n_util::GetStringUTF16(ran_insecure_content ?
570 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR :
571 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
572 }
573 }
574
avi655876a2015-12-25 07:18:15575 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59576 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
577 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20578 int ssl_version =
estarka3121f6b2015-09-18 21:15:59579 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20580 const char* ssl_version_str;
581 net::SSLVersionToString(&ssl_version_str, ssl_version);
582 site_connection_details_ += ASCIIToUTF16("\n\n");
583 site_connection_details_ += l10n_util::GetStringFUTF16(
584 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION,
585 ASCIIToUTF16(ssl_version_str));
586
[email protected]03ef4b2a2012-03-06 15:04:20587 bool no_renegotiation =
estarka3121f6b2015-09-18 21:15:59588 (security_info.connection_status &
589 net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20590 const char *key_exchange, *cipher, *mac;
[email protected]b6c1d9e82013-06-12 17:26:57591 bool is_aead;
592 net::SSLCipherSuiteToStrings(
593 &key_exchange, &cipher, &mac, &is_aead, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20594
595 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57596 if (is_aead) {
597 site_connection_details_ += l10n_util::GetStringFUTF16(
598 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
599 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
600 } else {
601 site_connection_details_ += l10n_util::GetStringFUTF16(
602 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS,
603 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
604 }
[email protected]03ef4b2a2012-03-06 15:04:20605
agl078d2102014-10-20 22:03:22606 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 &&
607 site_connection_status_ < SITE_CONNECTION_STATUS_MIXED_CONTENT) {
608 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
609 }
610
estarka3121f6b2015-09-18 21:15:59611 const bool did_fallback = (security_info.connection_status &
612 net::SSL_CONNECTION_VERSION_FALLBACK) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20613 if (did_fallback) {
[email protected]03ef4b2a2012-03-06 15:04:20614 site_connection_details_ += ASCIIToUTF16("\n\n");
615 site_connection_details_ += l10n_util::GetStringUTF16(
616 IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE);
617 }
agl078d2102014-10-20 22:03:22618
[email protected]03ef4b2a2012-03-06 15:04:20619 if (no_renegotiation) {
620 site_connection_details_ += ASCIIToUTF16("\n\n");
621 site_connection_details_ += l10n_util::GetStringUTF16(
622 IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE);
623 }
624 }
[email protected]e583f752012-08-30 13:26:21625
[email protected]71cd5ef2014-08-13 21:22:04626 // Check if a user decision has been made to allow or deny certificates with
627 // errors on this site.
628 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50629 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04630 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40631 // Only show an SSL decision revoke button if the user has chosen to bypass
632 // SSL host errors for this host in the past.
633 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]71cd5ef2014-08-13 21:22:04634
palmer82b1f7b2015-09-17 19:20:41635 // By default select the Permissions Tab that displays all the site
636 // permissions. In case of a connection error or an issue with the certificate
637 // presented by the website, select the Connection Tab to draw the user's
638 // attention to the issue. If the site does not provide a certificate because
639 // it was loaded over an unencrypted connection, don't select the Connection
640 // Tab.
[email protected]e583f752012-08-30 13:26:21641 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS;
642 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR ||
643 site_connection_status_ == SITE_CONNECTION_STATUS_MIXED_CONTENT ||
estarkf62683e2015-09-17 17:52:06644 site_connection_status_ == SITE_CONNECTION_STATUS_MIXED_SCRIPT ||
[email protected]e583f752012-08-30 13:26:21645 site_identity_status_ == SITE_IDENTITY_STATUS_ERROR ||
estark134a9822015-10-29 04:35:18646 site_identity_status_ == SITE_IDENTITY_STATUS_CT_ERROR ||
[email protected]eaf3f322013-04-25 21:53:59647 site_identity_status_ == SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN ||
rsleevi4f8012722014-09-30 01:28:01648 site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT ||
649 site_identity_status_ ==
lgarroncc53de22015-10-05 23:03:17650 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR ||
651 site_identity_status_ ==
652 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR) {
[email protected]e583f752012-08-30 13:26:21653 tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION;
lgarron04a93502014-11-04 22:25:04654 RecordWebsiteSettingsAction(
655 WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY);
656 }
palmer82b1f7b2015-09-17 19:20:41657
[email protected]e583f752012-08-30 13:26:21658 ui_->SetSelectedTab(tab_id);
[email protected]03ef4b2a2012-03-06 15:04:20659}
[email protected]0b9fdd72012-04-04 10:00:33660
[email protected]df818272012-04-20 13:10:50661void WebsiteSettings::PresentSitePermissions() {
662 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38663 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50664
665 WebsiteSettingsUI::PermissionInfo permission_info;
666 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
667 permission_info.type = kPermissionType[i];
668
mgiucaa319f212016-01-14 03:30:11669 if (!ShouldShowPermission(permission_info.type))
670 continue;
671
[email protected]df818272012-04-20 13:10:50672 content_settings::SettingInfo info;
sashab2b2a314f2015-01-17 06:42:21673 scoped_ptr<base::Value> value =
raymes7dec6d862015-07-27 07:02:08674 content_settings_->GetWebsiteSetting(
sashab2b2a314f2015-01-17 06:42:21675 site_url_, site_url_, permission_info.type, std::string(), &info);
676 DCHECK(value.get());
677 if (value->GetType() == base::Value::TYPE_INTEGER) {
678 permission_info.setting =
679 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26680 } else {
sashab2b2a314f2015-01-17 06:42:21681 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26682 }
683
[email protected]8bdf45c32012-08-04 00:12:55684 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28685 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50686
[email protected]b1d113d2012-06-27 21:27:34687 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21688 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34689 permission_info.default_setting = permission_info.setting;
690 permission_info.setting = CONTENT_SETTING_DEFAULT;
691 } else {
692 permission_info.default_setting =
693 content_settings_->GetDefaultContentSetting(permission_info.type,
694 NULL);
[email protected]df818272012-04-20 13:10:50695 }
palmer0da10b32015-02-11 00:42:19696
svaldez18120952016-01-14 21:12:49697 if ((permission_info.setting != CONTENT_SETTING_DEFAULT &&
698 permission_info.setting != permission_info.default_setting) ||
699 (permission_info.type == CONTENT_SETTINGS_TYPE_KEYGEN &&
700 tab_specific_content_settings()->IsContentBlocked(
701 permission_info.type))) {
palmer0da10b32015-02-11 00:42:19702 permission_info_list.push_back(permission_info);
703 }
[email protected]df818272012-04-20 13:10:50704 }
705
reillyg85f57db2016-01-12 23:14:38706 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
707 ChooserContextBase* context = ui_info.get_context(profile_);
708 auto chosen_objects = context->GetGrantedObjects(site_url_, site_url_);
709 for (scoped_ptr<base::DictionaryValue>& object : chosen_objects) {
710 chosen_object_info_list.push_back(
711 new WebsiteSettingsUI::ChosenObjectInfo(ui_info, std::move(object)));
712 }
713 }
714
715 ui_->SetPermissionInfo(permission_info_list, chosen_object_info_list);
[email protected]0b9fdd72012-04-04 10:00:33716}
717
[email protected]df818272012-04-20 13:10:50718void WebsiteSettings::PresentSiteData() {
719 CookieInfoList cookie_info_list;
vabrd5e30cd2014-10-02 11:06:03720 const LocalSharedObjectsCounter& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34721 tab_specific_content_settings()->allowed_local_shared_objects();
vabrd5e30cd2014-10-02 11:06:03722 const LocalSharedObjectsCounter& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34723 tab_specific_content_settings()->blocked_local_shared_objects();
724
725 // Add first party cookie and site data counts.
[email protected]df818272012-04-20 13:10:50726 WebsiteSettingsUI::CookieInfo cookie_info;
palmerb145264922015-08-28 23:53:15727 cookie_info.cookie_source =
728 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_FIRST_PARTY_SITE_DATA);
[email protected]e0ac35892012-05-15 12:53:34729 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
730 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15731 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34732 cookie_info_list.push_back(cookie_info);
733
734 // Add third party cookie counts.
735 cookie_info.cookie_source = l10n_util::GetStringUTF8(
736 IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA);
737 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
738 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15739 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50740 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33741
[email protected]df818272012-04-20 13:10:50742 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33743}
[email protected]16de6de2012-04-04 12:24:14744
[email protected]24c8818c2012-04-25 09:57:41745void WebsiteSettings::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04746 // After initialization the status about the site's connection and its
747 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41748 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
749 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
750 WebsiteSettingsUI::IdentityInfo info;
751 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
752 info.site_identity = UTF16ToUTF8(organization_name());
753 else
palmer153af982015-09-15 02:04:19754 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_, profile_));
[email protected]24c8818c2012-04-25 09:57:41755
756 info.connection_status = site_connection_status_;
757 info.connection_status_description =
758 UTF16ToUTF8(site_connection_details_);
759 info.identity_status = site_identity_status_;
760 info.identity_status_description =
761 UTF16ToUTF8(site_identity_details_);
[email protected]f61c1ce2012-05-09 13:55:11762 info.cert_id = cert_id_;
[email protected]71cd5ef2014-08-13 21:22:04763 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
[email protected]24c8818c2012-04-25 09:57:41764 ui_->SetIdentityInfo(info);
765}