blob: dc13e594ef5f2ecfe265aa8ee3e325257c3ed82c [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"
avi09dd4d02016-10-14 20:40:0916#include "base/memory/ptr_util.h"
[email protected]71cd5ef2014-08-13 21:22:0417#include "base/metrics/field_trial.h"
asvitkine75036032016-09-01 20:49:3418#include "base/metrics/histogram_macros.h"
[email protected]3ea1b182013-02-08 22:38:4119#include "base/strings/string_number_conversions.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"
vabrbab3ffcb2016-10-04 10:08:1031#include "chrome/browser/content_settings/local_shared_objects_container.h"
[email protected]77a91c72012-08-13 16:19:3432#include "chrome/browser/history/history_service_factory.h"
palmerf2cba0d2015-08-27 23:15:0633#include "chrome/browser/infobars/infobar_service.h"
reillyg85f57db2016-01-12 23:14:3834#include "chrome/browser/permissions/chooser_context_base.h"
tsergeantf1e89352016-01-15 20:34:5435#include "chrome/browser/permissions/permission_uma_util.h"
36#include "chrome/browser/permissions/permission_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2037#include "chrome/browser/profiles/profile.h"
[email protected]71cd5ef2014-08-13 21:22:0438#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
39#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
[email protected]4237dd52012-06-05 00:00:3240#include "chrome/browser/ui/website_settings/website_settings_ui.h"
reillyg85f57db2016-01-12 23:14:3841#include "chrome/browser/usb/usb_chooser_context.h"
42#include "chrome/browser/usb/usb_chooser_context_factory.h"
[email protected]71cd5ef2014-08-13 21:22:0443#include "chrome/common/chrome_switches.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"
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"
nzolghadrd87a308d2016-12-07 15:45:5652#include "components/rappor/public/rappor_utils.h"
53#include "components/rappor/rappor_service_impl.h"
felt2493b4452015-09-17 20:33:5954#include "components/ssl_errors/error_info.h"
thestig4a2e88e2016-08-27 23:23:5155#include "components/strings/grit/components_chromium_strings.h"
56#include "components/strings/grit/components_strings.h"
palmer153af982015-09-15 02:04:1957#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3358#include "content/public/browser/browser_thread.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"
tfarina29a3a1742016-10-28 18:47:3367#include "third_party/boringssl/src/include/openssl/ssl.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;
[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,
palmer7715e332016-05-27 00:41:19102 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
lshange085f202016-06-14 01:25:08103#if !defined(OS_ANDROID)
palmer7715e332016-05-27 00:41:19104 CONTENT_SETTINGS_TYPE_PLUGINS,
105 CONTENT_SETTINGS_TYPE_IMAGES,
lshange085f202016-06-14 01:25:08106#endif
palmer7715e332016-05-27 00:41:19107 CONTENT_SETTINGS_TYPE_POPUPS,
nsatragno670fe922016-04-08 14:10:50108 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
palmer7715e332016-05-27 00:41:19109 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
finnur46cafd42016-09-22 10:27:17110 CONTENT_SETTINGS_TYPE_AUTOPLAY,
palmer7715e332016-05-27 00:41:19111 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
[email protected]0b9fdd72012-04-04 10:00:33112};
113
mgiucaa319f212016-01-14 03:30:11114// Determines whether to show permission |type| in the Website Settings UI. Only
115// applies to permissions listed in |kPermissionType|.
116bool ShouldShowPermission(ContentSettingsType type) {
mgiucaa319f212016-01-14 03:30:11117#if !defined(OS_ANDROID)
finnur46cafd42016-09-22 10:27:17118 // Autoplay is Android-only at the moment.
mgiuca273b9672016-11-11 02:22:20119 if (type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
mgiuca0f3e1f72016-05-13 01:56:27120 return false;
mgiucaa319f212016-01-14 03:30:11121#endif
122
123 return true;
124}
125
esecklercac56b62016-11-16 13:49:44126void CheckContentStatus(security_state::ContentStatus content_status,
estark00e83f12016-08-19 18:24:04127 bool* displayed,
128 bool* ran) {
129 switch (content_status) {
esecklercac56b62016-11-16 13:49:44130 case security_state::CONTENT_STATUS_DISPLAYED:
estark00e83f12016-08-19 18:24:04131 *displayed = true;
132 break;
esecklercac56b62016-11-16 13:49:44133 case security_state::CONTENT_STATUS_RAN:
estark00e83f12016-08-19 18:24:04134 *ran = true;
135 break;
esecklercac56b62016-11-16 13:49:44136 case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN:
estark00e83f12016-08-19 18:24:04137 *displayed = true;
138 *ran = true;
139 break;
esecklercac56b62016-11-16 13:49:44140 case security_state::CONTENT_STATUS_UNKNOWN:
141 case security_state::CONTENT_STATUS_NONE:
estark00e83f12016-08-19 18:24:04142 break;
143 }
144}
145
146void CheckForInsecureContent(
esecklercac56b62016-11-16 13:49:44147 const security_state::SecurityInfo& security_info,
estark00e83f12016-08-19 18:24:04148 bool* displayed,
149 bool* ran) {
150 CheckContentStatus(security_info.mixed_content_status, displayed, ran);
151 // Only consider subresources with certificate errors if the main
152 // resource was loaded over HTTPS without major certificate errors. If
153 // the main resource had a certificate error, then it would not be
154 // that useful (and would potentially be confusing) to warn about
155 // subesources that had certificate errors too.
156 if (net::IsCertStatusError(security_info.cert_status) &&
157 !net::IsCertStatusMinorError(security_info.cert_status)) {
158 return;
159 }
160 CheckContentStatus(security_info.content_with_cert_errors_status, displayed,
161 ran);
162}
163
estarkfcfccdb82016-11-14 02:17:29164void GetSiteIdentityByMaliciousContentStatus(
esecklercac56b62016-11-16 13:49:44165 security_state::MaliciousContentStatus malicious_content_status,
estarkfcfccdb82016-11-14 02:17:29166 WebsiteSettings::SiteIdentityStatus* status,
167 base::string16* details) {
168 switch (malicious_content_status) {
esecklercac56b62016-11-16 13:49:44169 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
estarkfcfccdb82016-11-14 02:17:29170 NOTREACHED();
171 break;
esecklercac56b62016-11-16 13:49:44172 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
estarkfcfccdb82016-11-14 02:17:29173 *status = WebsiteSettings::SITE_IDENTITY_STATUS_MALWARE;
174 *details =
lgarrona0a14a482017-01-12 03:04:10175 l10n_util::GetStringUTF16(IDS_PAGEINFO_MALWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29176 break;
esecklercac56b62016-11-16 13:49:44177 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
estarkfcfccdb82016-11-14 02:17:29178 *status = WebsiteSettings::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
179 *details = l10n_util::GetStringUTF16(
lgarrona0a14a482017-01-12 03:04:10180 IDS_PAGEINFO_SOCIAL_ENGINEERING_DETAILS);
estarkfcfccdb82016-11-14 02:17:29181 break;
esecklercac56b62016-11-16 13:49:44182 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
estarkfcfccdb82016-11-14 02:17:29183 *status = WebsiteSettings::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
184 *details = l10n_util::GetStringUTF16(
lgarrona0a14a482017-01-12 03:04:10185 IDS_PAGEINFO_UNWANTED_SOFTWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29186 break;
187 }
188}
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,
esecklercac56b62016-11-16 13:49:44216 const security_state::SecurityInfo& security_info)
[email protected]df818272012-04-20 13:10:50217 : TabSpecificContentSettings::SiteDataObserver(
218 tab_specific_content_settings),
dominicknbdd53b5f2016-09-28 01:08:13219 content::WebContentsObserver(web_contents),
[email protected]df818272012-04-20 13:10:50220 ui_(ui),
[email protected]66f157312012-08-01 13:50:26221 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33222 site_url_(url),
223 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]03ef4b2a2012-03-06 15:04:20224 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
alshabalin5e894c12016-10-25 06:47:46225 show_ssl_decision_revoke_button_(false),
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),
estark8d67cd7a2016-10-24 05:06:41230 profile_(profile),
esecklercac56b62016-11-16 13:49:44231 security_level_(security_state::NONE) {
estarka3121f6b2015-09-18 21:15:59232 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33233
234 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50235 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41236 PresentSiteIdentity();
[email protected]e22d64f2012-09-10 09:03:23237
238 // Every time the Website Settings UI is opened a |WebsiteSettings| object is
239 // created. So this counts how ofter the Website Settings UI is opened.
lgarron04a93502014-11-04 22:25:04240 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20241}
242
[email protected]0b9fdd72012-04-04 10:00:33243WebsiteSettings::~WebsiteSettings() {
[email protected]03ef4b2a2012-03-06 15:04:20244}
245
lgarron04a93502014-11-04 22:25:04246void WebsiteSettings::RecordWebsiteSettingsAction(
247 WebsiteSettingsAction action) {
248 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action",
249 action,
250 WEBSITE_SETTINGS_COUNT);
251
estark8d67cd7a2016-10-24 05:06:41252 std::string histogram_name;
palmeree0e5af2015-06-05 03:10:40253
estark8d67cd7a2016-10-24 05:06:41254 if (site_url_.SchemeIsCryptographic()) {
esecklercac56b62016-11-16 13:49:44255 if (security_level_ == security_state::SECURE ||
256 security_level_ == security_state::EV_SECURE) {
estark8d67cd7a2016-10-24 05:06:41257 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Valid",
258 action, WEBSITE_SETTINGS_COUNT);
esecklercac56b62016-11-16 13:49:44259 } else if (security_level_ == security_state::NONE) {
estark8d67cd7a2016-10-24 05:06:41260 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded",
261 action, WEBSITE_SETTINGS_COUNT);
esecklercac56b62016-11-16 13:49:44262 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41263 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous",
264 action, WEBSITE_SETTINGS_COUNT);
265 }
266 return;
267 }
268
esecklercac56b62016-11-16 13:49:44269 if (security_level_ == security_state::HTTP_SHOW_WARNING) {
estark8d67cd7a2016-10-24 05:06:41270 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning",
271 action, WEBSITE_SETTINGS_COUNT);
esecklercac56b62016-11-16 13:49:44272 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41273 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous",
274 action, WEBSITE_SETTINGS_COUNT);
275 } else {
276 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral",
277 action, WEBSITE_SETTINGS_COUNT);
lgarron04a93502014-11-04 22:25:04278 }
279}
280
[email protected]df818272012-04-20 13:10:50281void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type,
282 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23283 // Count how often a permission for a specific content type is changed using
284 // the Website Settings UI.
raymes4a13d432015-09-08 00:44:07285 size_t num_values;
286 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
sashab9debecd2014-12-18 04:15:56287 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.OriginInfo.PermissionChanged",
raymes4a13d432015-09-08 00:44:07288 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56289
290 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
291 UMA_HISTOGRAM_ENUMERATION(
292 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07293 num_values);
tommycli34cf29bf2016-09-08 05:46:25294
295 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
296 rappor::SampleDomainAndRegistryFromGURL(
297 g_browser_process->rappor_service(),
298 "ContentSettings.Plugins.AddedAllowException", site_url_);
299 }
sashab9debecd2014-12-18 04:15:56300 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
301 UMA_HISTOGRAM_ENUMERATION(
302 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07303 num_values);
sashab9debecd2014-12-18 04:15:56304 }
[email protected]e22d64f2012-09-10 09:03:23305
lgarron04a93502014-11-04 22:25:04306 // This is technically redundant given the histogram above, but putting the
307 // total count of permission changes in another histogram makes it easier to
308 // compare it against other kinds of actions in WebsiteSettings[PopupView].
309 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_CHANGED_PERMISSION);
310
stefanocs8b3490cc2016-07-28 05:32:52311 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
312 this->profile_, this->site_url_, this->site_url_, type,
313 PermissionSourceUI::OIB);
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_);
reillyg36a7fab32016-01-28 19:15:10329 const GURL origin = site_url_.GetOrigin();
330 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38331
332 show_info_bar_ = true;
333
334 // Refresh the UI to reflect the changed settings.
335 PresentSitePermissions();
336}
337
[email protected]df818272012-04-20 13:10:50338void WebsiteSettings::OnSiteDataAccessed() {
339 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33340}
341
[email protected]66f157312012-08-01 13:50:26342void WebsiteSettings::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49343#if defined(OS_ANDROID)
344 NOTREACHED();
345#else
dominicknbdd53b5f2016-09-28 01:08:13346 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
palmerf2cba0d2015-08-27 23:15:06347 InfoBarService* infobar_service =
dominicknbdd53b5f2016-09-28 01:08:13348 InfoBarService::FromWebContents(web_contents());
palmerf2cba0d2015-08-27 23:15:06349 if (infobar_service)
350 WebsiteSettingsInfoBarDelegate::Create(infobar_service);
351 }
jww1ed8ea72014-09-02 20:43:25352
353 SSLCertificateDecisionsDidRevoke user_decision =
354 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
355 : USER_CERT_DECISIONS_NOT_REVOKED;
356
357 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
358 user_decision,
359 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49360#endif
jww1ed8ea72014-09-02 20:43:25361}
362
363void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() {
364 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29365 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
366 site_url().host());
jww1ed8ea72014-09-02 20:43:25367 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26368}
369
esecklercac56b62016-11-16 13:49:44370void WebsiteSettings::Init(const GURL& url,
371 const security_state::SecurityInfo& security_info) {
meacerde53fcff2016-10-12 19:21:57372#if !defined(OS_ANDROID) && !defined(OS_IOS)
373 // On desktop, internal URLs aren't handled by this class. Instead, a
374 // custom and simpler popup is shown.
375 DCHECK(!url.SchemeIs(content::kChromeUIScheme) &&
376 !url.SchemeIs(content::kChromeDevToolsScheme) &&
377 !url.SchemeIs(content::kViewSourceScheme) &&
378 !url.SchemeIs(content_settings::kExtensionScheme));
379#endif
380
sashab97894ce2014-10-22 10:08:33381 bool isChromeUINativeScheme = false;
zpengdb4a58e2017-01-10 17:40:32382#if defined(OS_ANDROID)
sashab97894ce2014-10-22 10:08:33383 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
384#endif
385
estark8d67cd7a2016-10-24 05:06:41386 security_level_ = security_info.security_level;
387
upendrag.gowda60886a6e2015-10-31 05:51:09388 if (url.SchemeIs(url::kAboutScheme)) {
389 // All about: URLs except about:blank are redirected.
390 DCHECK_EQ(url::kAboutBlankURL, url.spec());
391 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
392 site_identity_details_ =
393 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
394 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
395 site_connection_details_ = l10n_util::GetStringFUTF16(
396 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
397 UTF8ToUTF16(url.spec()));
398 return;
399 }
400
401 if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) {
[email protected]03ef4b2a2012-03-06 15:04:20402 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
403 site_identity_details_ =
404 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
405 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
406 return;
407 }
408
[email protected]03ef4b2a2012-03-06 15:04:20409 // Identity section.
jam8ae7cad2016-09-08 23:55:21410 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11411
estarkfcfccdb82016-11-14 02:17:29412 if (security_info.malicious_content_status !=
esecklercac56b62016-11-16 13:49:44413 security_state::MALICIOUS_CONTENT_STATUS_NONE) {
estarkfcfccdb82016-11-14 02:17:29414 // The site has been flagged by Safe Browsing as dangerous.
415 GetSiteIdentityByMaliciousContentStatus(
416 security_info.malicious_content_status, &site_identity_status_,
417 &site_identity_details_);
418 } else if (certificate_ &&
419 (!net::IsCertStatusError(security_info.cert_status) ||
420 net::IsCertStatusMinorError(security_info.cert_status))) {
421 // HTTPS with no or minor errors.
estarka3121f6b2015-09-18 21:15:59422 if (security_info.security_level ==
esecklercac56b62016-11-16 13:49:44423 security_state::SECURE_WITH_POLICY_INSTALLED_CERT) {
[email protected]eaf3f322013-04-25 21:53:59424 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37425 site_identity_details_ = l10n_util::GetStringFUTF16(
426 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59427 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20428 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21429 base::string16 issuer_name(
430 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20431 if (issuer_name.empty()) {
432 issuer_name.assign(l10n_util::GetStringUTF16(
433 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
434 }
[email protected]94c74b42013-12-02 15:19:49435
[email protected]03ef4b2a2012-03-06 15:04:20436 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39437 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20438
439 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59440 if (security_info.cert_status &
441 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20442 site_identity_details_ += l10n_util::GetStringUTF16(
443 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59444 } else if (security_info.cert_status &
445 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20446 site_identity_details_ += l10n_util::GetStringUTF16(
447 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
448 } else {
449 NOTREACHED() << "Need to specify string for this warning";
450 }
[email protected]03ef4b2a2012-03-06 15:04:20451 } else {
estarkcf305562016-11-15 03:45:39452 // No major or minor errors.
estarka3121f6b2015-09-18 21:15:59453 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01454 // EV HTTPS page.
estarkcf305562016-11-15 03:45:39455 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
jam8ae7cad2016-09-08 23:55:21456 DCHECK(!certificate_->subject().organization_names.empty());
457 organization_name_ =
458 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01459 // An EV Cert is required to have a city (localityName) and country but
460 // state is "if any".
jam8ae7cad2016-09-08 23:55:21461 DCHECK(!certificate_->subject().locality_name.empty());
462 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01463 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21464 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01465 locality = l10n_util::GetStringFUTF16(
466 IDS_PAGEINFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21467 UTF8ToUTF16(certificate_->subject().locality_name),
468 UTF8ToUTF16(certificate_->subject().state_or_province_name),
469 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01470 } else {
471 locality = l10n_util::GetStringFUTF16(
472 IDS_PAGEINFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21473 UTF8ToUTF16(certificate_->subject().locality_name),
474 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01475 }
jam8ae7cad2016-09-08 23:55:21476 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01477 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39478 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED,
jam8ae7cad2016-09-08 23:55:21479 UTF8ToUTF16(certificate_->subject().organization_names[0]),
estarkcf305562016-11-15 03:45:39480 locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01481 } else {
482 // Non-EV OK HTTPS page.
estarkcf305562016-11-15 03:45:39483 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
rsleevi4f8012722014-09-30 01:28:01484 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21485 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01486 if (issuer_name.empty()) {
487 issuer_name.assign(l10n_util::GetStringUTF16(
488 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
489 }
[email protected]94c74b42013-12-02 15:19:49490
rsleevi4f8012722014-09-30 01:28:01491 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39492 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
rsleevi4f8012722014-09-30 01:28:01493 }
elawrencebe87bd62017-01-10 16:08:59494 if (security_info.sha1_in_chain) {
495 site_identity_status_ =
496 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM;
497 site_identity_details_ +=
498 UTF8ToUTF16("\n\n") +
499 l10n_util::GetStringUTF16(
500 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM);
rsleevi4f8012722014-09-30 01:28:01501 }
[email protected]03ef4b2a2012-03-06 15:04:20502 }
503 } else {
504 // HTTP or HTTPS with errors (not warnings).
505 site_identity_details_.assign(l10n_util::GetStringUTF16(
506 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
jam8ae7cad2016-09-08 23:55:21507 if (!security_info.scheme_is_cryptographic || !security_info.certificate)
[email protected]03ef4b2a2012-03-06 15:04:20508 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
509 else
510 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
511
[email protected]a04db822013-12-11 19:14:40512 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59513 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59514 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
jam8ae7cad2016-09-08 23:55:21515 certificate_, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20516 for (size_t i = 0; i < errors.size(); ++i) {
517 site_identity_details_ += bullet;
518 site_identity_details_ += errors[i].short_description();
519 }
520
estarka3121f6b2015-09-18 21:15:59521 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20522 site_identity_details_ += ASCIIToUTF16("\n\n");
523 site_identity_details_ += l10n_util::GetStringUTF16(
524 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
525 }
526 }
527
528 // Site Connection
529 // We consider anything less than 80 bits encryption to be weak encryption.
530 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
531 // weakly encrypted connections.
532 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
533
jshin1fb76462016-04-05 22:13:03534 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19535 if (subject_name.empty()) {
536 subject_name.assign(
537 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
538 }
539
jam8ae7cad2016-09-08 23:55:21540 if (!security_info.certificate || !security_info.scheme_is_cryptographic) {
estarka3121f6b2015-09-18 21:15:59541 // Page is still loading (so SSL status is not yet available) or
542 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58543 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
544
545 site_connection_details_.assign(l10n_util::GetStringFUTF16(
546 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
547 subject_name));
estarka3121f6b2015-09-18 21:15:59548 } else if (security_info.security_bits < 0) {
549 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20550 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59551 } else if (security_info.security_bits == 0) {
esecklercac56b62016-11-16 13:49:44552 DCHECK_NE(security_info.security_level, security_state::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20553 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
554 site_connection_details_.assign(l10n_util::GetStringFUTF16(
555 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
556 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20557 } else {
558 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22559
lgarron3e2c33e2016-08-25 06:33:43560 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22561 site_connection_details_.assign(l10n_util::GetStringFUTF16(
562 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
563 subject_name));
564 } else {
565 site_connection_details_.assign(l10n_util::GetStringFUTF16(
566 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
567 subject_name));
568 }
569
estark00e83f12016-08-19 18:24:04570 bool ran_insecure_content = false;
571 bool displayed_insecure_content = false;
572 CheckForInsecureContent(security_info, &displayed_insecure_content,
573 &ran_insecure_content);
574 if (ran_insecure_content || displayed_insecure_content) {
575 site_connection_status_ =
576 ran_insecure_content
577 ? SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE
578 : SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
[email protected]03ef4b2a2012-03-06 15:04:20579 site_connection_details_.assign(l10n_util::GetStringFUTF16(
580 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
581 site_connection_details_,
estark00e83f12016-08-19 18:24:04582 l10n_util::GetStringUTF16(
583 ran_insecure_content
584 ? IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR
585 : IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
[email protected]03ef4b2a2012-03-06 15:04:20586 }
587 }
588
avi655876a2015-12-25 07:18:15589 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59590 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
591 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20592 int ssl_version =
estarka3121f6b2015-09-18 21:15:59593 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20594 const char* ssl_version_str;
595 net::SSLVersionToString(&ssl_version_str, ssl_version);
596 site_connection_details_ += ASCIIToUTF16("\n\n");
597 site_connection_details_ += l10n_util::GetStringFUTF16(
598 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION,
599 ASCIIToUTF16(ssl_version_str));
600
[email protected]03ef4b2a2012-03-06 15:04:20601 bool no_renegotiation =
estarka3121f6b2015-09-18 21:15:59602 (security_info.connection_status &
603 net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20604 const char *key_exchange, *cipher, *mac;
davidben56a8aece2016-10-14 18:20:56605 bool is_aead, is_tls13;
606 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
607 &is_tls13, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20608
609 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57610 if (is_aead) {
davidben56a8aece2016-10-14 18:20:56611 if (is_tls13) {
612 // For TLS 1.3 ciphers, report the group (historically, curve) as the
613 // key exchange.
614 key_exchange = SSL_get_curve_name(security_info.key_exchange_group);
615 if (!key_exchange) {
616 NOTREACHED();
617 key_exchange = "";
618 }
619 }
[email protected]b6c1d9e82013-06-12 17:26:57620 site_connection_details_ += l10n_util::GetStringFUTF16(
621 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
622 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
623 } else {
624 site_connection_details_ += l10n_util::GetStringFUTF16(
625 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS,
626 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
627 }
[email protected]03ef4b2a2012-03-06 15:04:20628
agl078d2102014-10-20 22:03:22629 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 &&
estark00e83f12016-08-19 18:24:04630 site_connection_status_ <
631 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE) {
agl078d2102014-10-20 22:03:22632 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
633 }
634
[email protected]03ef4b2a2012-03-06 15:04:20635 if (no_renegotiation) {
636 site_connection_details_ += ASCIIToUTF16("\n\n");
637 site_connection_details_ += l10n_util::GetStringUTF16(
638 IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE);
639 }
640 }
[email protected]e583f752012-08-30 13:26:21641
[email protected]71cd5ef2014-08-13 21:22:04642 // Check if a user decision has been made to allow or deny certificates with
643 // errors on this site.
644 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50645 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04646 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40647 // Only show an SSL decision revoke button if the user has chosen to bypass
648 // SSL host errors for this host in the past.
649 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]03ef4b2a2012-03-06 15:04:20650}
[email protected]0b9fdd72012-04-04 10:00:33651
[email protected]df818272012-04-20 13:10:50652void WebsiteSettings::PresentSitePermissions() {
653 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38654 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50655
656 WebsiteSettingsUI::PermissionInfo permission_info;
657 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
658 permission_info.type = kPermissionType[i];
659
mgiucaa319f212016-01-14 03:30:11660 if (!ShouldShowPermission(permission_info.type))
661 continue;
662
[email protected]df818272012-04-20 13:10:50663 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32664 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
665 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21666 DCHECK(value.get());
jdoerriedc72ee942016-12-07 15:43:28667 if (value->GetType() == base::Value::Type::INTEGER) {
sashab2b2a314f2015-01-17 06:42:21668 permission_info.setting =
669 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26670 } else {
sashab2b2a314f2015-01-17 06:42:21671 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26672 }
673
[email protected]8bdf45c32012-08-04 00:12:55674 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28675 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50676
[email protected]b1d113d2012-06-27 21:27:34677 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21678 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34679 permission_info.default_setting = permission_info.setting;
680 permission_info.setting = CONTENT_SETTING_DEFAULT;
681 } else {
682 permission_info.default_setting =
683 content_settings_->GetDefaultContentSetting(permission_info.type,
684 NULL);
[email protected]df818272012-04-20 13:10:50685 }
palmer0da10b32015-02-11 00:42:19686
palmer64a099982016-03-09 21:26:11687 permission_info_list.push_back(permission_info);
[email protected]df818272012-04-20 13:10:50688 }
689
reillyg85f57db2016-01-12 23:14:38690 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
691 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10692 const GURL origin = site_url_.GetOrigin();
693 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32694 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38695 chosen_object_info_list.push_back(
avi09dd4d02016-10-14 20:40:09696 base::MakeUnique<WebsiteSettingsUI::ChosenObjectInfo>(
697 ui_info, std::move(object)));
reillyg85f57db2016-01-12 23:14:38698 }
699 }
700
avi09dd4d02016-10-14 20:40:09701 ui_->SetPermissionInfo(permission_info_list,
702 std::move(chosen_object_info_list));
[email protected]0b9fdd72012-04-04 10:00:33703}
704
[email protected]df818272012-04-20 13:10:50705void WebsiteSettings::PresentSiteData() {
706 CookieInfoList cookie_info_list;
vabrbab3ffcb2016-10-04 10:08:10707 const LocalSharedObjectsContainer& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34708 tab_specific_content_settings()->allowed_local_shared_objects();
vabrbab3ffcb2016-10-04 10:08:10709 const LocalSharedObjectsContainer& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34710 tab_specific_content_settings()->blocked_local_shared_objects();
711
712 // Add first party cookie and site data counts.
[email protected]df818272012-04-20 13:10:50713 WebsiteSettingsUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34714 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
715 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15716 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34717 cookie_info_list.push_back(cookie_info);
718
719 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34720 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
721 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15722 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50723 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33724
[email protected]df818272012-04-20 13:10:50725 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33726}
[email protected]16de6de2012-04-04 12:24:14727
[email protected]24c8818c2012-04-25 09:57:41728void WebsiteSettings::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04729 // After initialization the status about the site's connection and its
730 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41731 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
732 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
733 WebsiteSettingsUI::IdentityInfo info;
734 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
735 info.site_identity = UTF16ToUTF8(organization_name());
736 else
jshin1fb76462016-04-05 22:13:03737 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41738
739 info.connection_status = site_connection_status_;
740 info.connection_status_description =
741 UTF16ToUTF8(site_connection_details_);
742 info.identity_status = site_identity_status_;
743 info.identity_status_description =
744 UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21745 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04746 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
[email protected]24c8818c2012-04-25 09:57:41747 ui_->SetIdentityInfo(info);
748}