blob: 88cf98b31fd99384463e3210f3d52e39454f3962 [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"
patricialor2a4f41a2017-03-08 02:52:5635#include "chrome/browser/permissions/permission_manager.h"
36#include "chrome/browser/permissions/permission_result.h"
tsergeantf1e89352016-01-15 20:34:5437#include "chrome/browser/permissions/permission_uma_util.h"
38#include "chrome/browser/permissions/permission_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2039#include "chrome/browser/profiles/profile.h"
[email protected]71cd5ef2014-08-13 21:22:0440#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
41#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
[email protected]4237dd52012-06-05 00:00:3242#include "chrome/browser/ui/website_settings/website_settings_ui.h"
reillyg85f57db2016-01-12 23:14:3843#include "chrome/browser/usb/usb_chooser_context.h"
44#include "chrome/browser/usb/usb_chooser_context_factory.h"
[email protected]71cd5ef2014-08-13 21:22:0445#include "chrome/common/chrome_switches.h"
jsbellddb849e2015-08-27 00:12:5646#include "chrome/common/url_constants.h"
thestig884a1602014-08-27 01:29:3947#include "chrome/grit/chromium_strings.h"
48#include "chrome/grit/generated_resources.h"
reillyg85f57db2016-01-12 23:14:3849#include "chrome/grit/theme_resources.h"
mukai8eaec822014-10-25 17:53:1650#include "components/content_settings/core/browser/content_settings_utils.h"
51#include "components/content_settings/core/browser/host_content_settings_map.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"
nzolghadrd87a308d2016-12-07 15:45:5654#include "components/rappor/public/rappor_utils.h"
55#include "components/rappor/rappor_service_impl.h"
felt2493b4452015-09-17 20:33:5956#include "components/ssl_errors/error_info.h"
thestig4a2e88e2016-08-27 23:23:5157#include "components/strings/grit/components_chromium_strings.h"
58#include "components/strings/grit/components_strings.h"
palmer153af982015-09-15 02:04:1959#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3360#include "content/public/browser/browser_thread.h"
[email protected]e22d64f2012-09-10 09:03:2361#include "content/public/browser/user_metrics.h"
[email protected]eb2140c2013-07-29 12:37:3462#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2063#include "content/public/common/url_constants.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"
tfarina29a3a1742016-10-28 18:47:3368#include "third_party/boringssl/src/include/openssl/ssl.h"
[email protected]03ef4b2a2012-03-06 15:04:2069#include "ui/base/l10n/l10n_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2070
[email protected]24a9f1c92013-11-13 12:33:3771#if defined(OS_CHROMEOS)
72#include "chrome/browser/chromeos/policy/policy_cert_service.h"
73#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
74#endif
75
estade3feb83f2015-09-01 23:00:4976#if !defined(OS_ANDROID)
mgiucaa319f212016-01-14 03:30:1177#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
estade3feb83f2015-09-01 23:00:4978#include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h"
79#endif
80
[email protected]ab6df3b12013-12-24 23:32:2681using base::ASCIIToUTF16;
82using base::UTF8ToUTF16;
[email protected]f729d7a2013-12-26 07:07:5683using base::UTF16ToUTF8;
[email protected]0b9fdd72012-04-04 10:00:3384using content::BrowserThread;
85
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_AUTOMATIC_DOWNLOADS,
finnur46cafd42016-09-22 10:27:17111 CONTENT_SETTINGS_TYPE_AUTOPLAY,
palmer7715e332016-05-27 00:41:19112 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
[email protected]0b9fdd72012-04-04 10:00:33113};
114
mgiucaa319f212016-01-14 03:30:11115// Determines whether to show permission |type| in the Website Settings UI. Only
116// applies to permissions listed in |kPermissionType|.
117bool ShouldShowPermission(ContentSettingsType type) {
mgiucaa319f212016-01-14 03:30:11118#if !defined(OS_ANDROID)
finnur46cafd42016-09-22 10:27:17119 // Autoplay is Android-only at the moment.
mgiuca273b9672016-11-11 02:22:20120 if (type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
mgiuca0f3e1f72016-05-13 01:56:27121 return false;
mgiucaa319f212016-01-14 03:30:11122#endif
123
124 return true;
125}
126
esecklercac56b62016-11-16 13:49:44127void CheckContentStatus(security_state::ContentStatus content_status,
estark00e83f12016-08-19 18:24:04128 bool* displayed,
129 bool* ran) {
130 switch (content_status) {
esecklercac56b62016-11-16 13:49:44131 case security_state::CONTENT_STATUS_DISPLAYED:
estark00e83f12016-08-19 18:24:04132 *displayed = true;
133 break;
esecklercac56b62016-11-16 13:49:44134 case security_state::CONTENT_STATUS_RAN:
estark00e83f12016-08-19 18:24:04135 *ran = true;
136 break;
esecklercac56b62016-11-16 13:49:44137 case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN:
estark00e83f12016-08-19 18:24:04138 *displayed = true;
139 *ran = true;
140 break;
esecklercac56b62016-11-16 13:49:44141 case security_state::CONTENT_STATUS_UNKNOWN:
142 case security_state::CONTENT_STATUS_NONE:
estark00e83f12016-08-19 18:24:04143 break;
144 }
145}
146
147void CheckForInsecureContent(
esecklercac56b62016-11-16 13:49:44148 const security_state::SecurityInfo& security_info,
estark00e83f12016-08-19 18:24:04149 bool* displayed,
150 bool* ran) {
151 CheckContentStatus(security_info.mixed_content_status, displayed, ran);
152 // Only consider subresources with certificate errors if the main
153 // resource was loaded over HTTPS without major certificate errors. If
154 // the main resource had a certificate error, then it would not be
155 // that useful (and would potentially be confusing) to warn about
156 // subesources that had certificate errors too.
157 if (net::IsCertStatusError(security_info.cert_status) &&
158 !net::IsCertStatusMinorError(security_info.cert_status)) {
159 return;
160 }
161 CheckContentStatus(security_info.content_with_cert_errors_status, displayed,
162 ran);
163}
164
estarkfcfccdb82016-11-14 02:17:29165void GetSiteIdentityByMaliciousContentStatus(
esecklercac56b62016-11-16 13:49:44166 security_state::MaliciousContentStatus malicious_content_status,
estarkfcfccdb82016-11-14 02:17:29167 WebsiteSettings::SiteIdentityStatus* status,
168 base::string16* details) {
169 switch (malicious_content_status) {
esecklercac56b62016-11-16 13:49:44170 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
estarkfcfccdb82016-11-14 02:17:29171 NOTREACHED();
172 break;
esecklercac56b62016-11-16 13:49:44173 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
estarkfcfccdb82016-11-14 02:17:29174 *status = WebsiteSettings::SITE_IDENTITY_STATUS_MALWARE;
175 *details =
lgarrona0a14a482017-01-12 03:04:10176 l10n_util::GetStringUTF16(IDS_PAGEINFO_MALWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29177 break;
esecklercac56b62016-11-16 13:49:44178 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
estarkfcfccdb82016-11-14 02:17:29179 *status = WebsiteSettings::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
180 *details = l10n_util::GetStringUTF16(
lgarrona0a14a482017-01-12 03:04:10181 IDS_PAGEINFO_SOCIAL_ENGINEERING_DETAILS);
estarkfcfccdb82016-11-14 02:17:29182 break;
esecklercac56b62016-11-16 13:49:44183 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
estarkfcfccdb82016-11-14 02:17:29184 *status = WebsiteSettings::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
185 *details = l10n_util::GetStringUTF16(
lgarrona0a14a482017-01-12 03:04:10186 IDS_PAGEINFO_UNWANTED_SOFTWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29187 break;
188 }
189}
190
jshin1fb76462016-04-05 22:13:03191base::string16 GetSimpleSiteName(const GURL& url) {
benwells2337b8102016-04-20 01:53:53192 return url_formatter::FormatUrlForSecurityDisplay(
193 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
palmer153af982015-09-15 02:04:19194}
195
reillyg85f57db2016-01-12 23:14:38196ChooserContextBase* GetUsbChooserContext(Profile* profile) {
197 return UsbChooserContextFactory::GetForProfile(profile);
198}
199
200// The list of chooser types that need to display entries in the Website
201// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
202// email [email protected].
203WebsiteSettings::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52204 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
205 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_WEBSITE_SETTINGS_USB_DEVICE_LABEL,
reillyg85f57db2016-01-12 23:14:38206 IDS_WEBSITE_SETTINGS_DELETE_USB_DEVICE, "name"},
207};
208
[email protected]0b9fdd72012-04-04 10:00:33209} // namespace
210
211WebsiteSettings::WebsiteSettings(
212 WebsiteSettingsUI* ui,
213 Profile* profile,
[email protected]df818272012-04-20 13:10:50214 TabSpecificContentSettings* tab_specific_content_settings,
palmerf2cba0d2015-08-27 23:15:06215 content::WebContents* web_contents,
[email protected]0b9fdd72012-04-04 10:00:33216 const GURL& url,
esecklercac56b62016-11-16 13:49:44217 const security_state::SecurityInfo& security_info)
[email protected]df818272012-04-20 13:10:50218 : TabSpecificContentSettings::SiteDataObserver(
219 tab_specific_content_settings),
dominicknbdd53b5f2016-09-28 01:08:13220 content::WebContentsObserver(web_contents),
[email protected]df818272012-04-20 13:10:50221 ui_(ui),
[email protected]66f157312012-08-01 13:50:26222 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33223 site_url_(url),
224 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]03ef4b2a2012-03-06 15:04:20225 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
alshabalin5e894c12016-10-25 06:47:46226 show_ssl_decision_revoke_button_(false),
peconn5100d432015-09-16 12:03:08227 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04228 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25229 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19230 did_revoke_user_ssl_decisions_(false),
estark8d67cd7a2016-10-24 05:06:41231 profile_(profile),
esecklercac56b62016-11-16 13:49:44232 security_level_(security_state::NONE) {
estarka3121f6b2015-09-18 21:15:59233 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33234
235 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50236 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41237 PresentSiteIdentity();
[email protected]e22d64f2012-09-10 09:03:23238
239 // Every time the Website Settings UI is opened a |WebsiteSettings| object is
240 // created. So this counts how ofter the Website Settings UI is opened.
lgarron04a93502014-11-04 22:25:04241 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20242}
243
[email protected]0b9fdd72012-04-04 10:00:33244WebsiteSettings::~WebsiteSettings() {
[email protected]03ef4b2a2012-03-06 15:04:20245}
246
lgarron04a93502014-11-04 22:25:04247void WebsiteSettings::RecordWebsiteSettingsAction(
248 WebsiteSettingsAction action) {
249 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action",
250 action,
251 WEBSITE_SETTINGS_COUNT);
252
estark8d67cd7a2016-10-24 05:06:41253 std::string histogram_name;
palmeree0e5af2015-06-05 03:10:40254
estark8d67cd7a2016-10-24 05:06:41255 if (site_url_.SchemeIsCryptographic()) {
esecklercac56b62016-11-16 13:49:44256 if (security_level_ == security_state::SECURE ||
257 security_level_ == security_state::EV_SECURE) {
estark8d67cd7a2016-10-24 05:06:41258 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Valid",
259 action, WEBSITE_SETTINGS_COUNT);
esecklercac56b62016-11-16 13:49:44260 } else if (security_level_ == security_state::NONE) {
estark8d67cd7a2016-10-24 05:06:41261 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded",
262 action, WEBSITE_SETTINGS_COUNT);
esecklercac56b62016-11-16 13:49:44263 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41264 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous",
265 action, WEBSITE_SETTINGS_COUNT);
266 }
267 return;
268 }
269
esecklercac56b62016-11-16 13:49:44270 if (security_level_ == security_state::HTTP_SHOW_WARNING) {
estark8d67cd7a2016-10-24 05:06:41271 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning",
272 action, WEBSITE_SETTINGS_COUNT);
esecklercac56b62016-11-16 13:49:44273 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41274 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous",
275 action, WEBSITE_SETTINGS_COUNT);
276 } else {
277 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral",
278 action, WEBSITE_SETTINGS_COUNT);
lgarron04a93502014-11-04 22:25:04279 }
280}
281
[email protected]df818272012-04-20 13:10:50282void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type,
283 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23284 // Count how often a permission for a specific content type is changed using
285 // the Website Settings UI.
raymes4a13d432015-09-08 00:44:07286 size_t num_values;
287 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
sashab9debecd2014-12-18 04:15:56288 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.OriginInfo.PermissionChanged",
raymes4a13d432015-09-08 00:44:07289 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56290
291 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
292 UMA_HISTOGRAM_ENUMERATION(
293 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07294 num_values);
tommycli34cf29bf2016-09-08 05:46:25295
296 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
297 rappor::SampleDomainAndRegistryFromGURL(
298 g_browser_process->rappor_service(),
299 "ContentSettings.Plugins.AddedAllowException", site_url_);
300 }
sashab9debecd2014-12-18 04:15:56301 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
302 UMA_HISTOGRAM_ENUMERATION(
303 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07304 num_values);
sashab9debecd2014-12-18 04:15:56305 }
[email protected]e22d64f2012-09-10 09:03:23306
lgarron04a93502014-11-04 22:25:04307 // This is technically redundant given the histogram above, but putting the
308 // total count of permission changes in another histogram makes it easier to
309 // compare it against other kinds of actions in WebsiteSettings[PopupView].
310 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_CHANGED_PERMISSION);
311
stefanocs8b3490cc2016-07-28 05:32:52312 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
313 this->profile_, this->site_url_, this->site_url_, type,
314 PermissionSourceUI::OIB);
315
raymesfbaaaaa2015-11-10 02:20:40316 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
317 setting);
[email protected]df818272012-04-20 13:10:50318
[email protected]66f157312012-08-01 13:50:26319 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24320
321 // Refresh the UI to reflect the new setting.
322 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50323}
324
reillyg85f57db2016-01-12 23:14:38325void WebsiteSettings::OnSiteChosenObjectDeleted(
326 const ChooserUIInfo& ui_info,
327 const base::DictionaryValue& object) {
328 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
329 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10330 const GURL origin = site_url_.GetOrigin();
331 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38332
333 show_info_bar_ = true;
334
335 // Refresh the UI to reflect the changed settings.
336 PresentSitePermissions();
337}
338
[email protected]df818272012-04-20 13:10:50339void WebsiteSettings::OnSiteDataAccessed() {
340 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33341}
342
[email protected]66f157312012-08-01 13:50:26343void WebsiteSettings::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49344#if defined(OS_ANDROID)
345 NOTREACHED();
346#else
dominicknbdd53b5f2016-09-28 01:08:13347 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
palmerf2cba0d2015-08-27 23:15:06348 InfoBarService* infobar_service =
dominicknbdd53b5f2016-09-28 01:08:13349 InfoBarService::FromWebContents(web_contents());
palmerf2cba0d2015-08-27 23:15:06350 if (infobar_service)
351 WebsiteSettingsInfoBarDelegate::Create(infobar_service);
352 }
jww1ed8ea72014-09-02 20:43:25353
354 SSLCertificateDecisionsDidRevoke user_decision =
355 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
356 : USER_CERT_DECISIONS_NOT_REVOKED;
357
358 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
359 user_decision,
360 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49361#endif
jww1ed8ea72014-09-02 20:43:25362}
363
364void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() {
365 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29366 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
367 site_url().host());
jww1ed8ea72014-09-02 20:43:25368 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26369}
370
esecklercac56b62016-11-16 13:49:44371void WebsiteSettings::Init(const GURL& url,
372 const security_state::SecurityInfo& security_info) {
meacerde53fcff2016-10-12 19:21:57373#if !defined(OS_ANDROID) && !defined(OS_IOS)
374 // On desktop, internal URLs aren't handled by this class. Instead, a
375 // custom and simpler popup is shown.
376 DCHECK(!url.SchemeIs(content::kChromeUIScheme) &&
377 !url.SchemeIs(content::kChromeDevToolsScheme) &&
378 !url.SchemeIs(content::kViewSourceScheme) &&
379 !url.SchemeIs(content_settings::kExtensionScheme));
380#endif
381
sashab97894ce2014-10-22 10:08:33382 bool isChromeUINativeScheme = false;
zpengdb4a58e2017-01-10 17:40:32383#if defined(OS_ANDROID)
sashab97894ce2014-10-22 10:08:33384 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
385#endif
386
estark8d67cd7a2016-10-24 05:06:41387 security_level_ = security_info.security_level;
388
upendrag.gowda60886a6e2015-10-31 05:51:09389 if (url.SchemeIs(url::kAboutScheme)) {
390 // All about: URLs except about:blank are redirected.
391 DCHECK_EQ(url::kAboutBlankURL, url.spec());
392 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
393 site_identity_details_ =
394 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
395 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
396 site_connection_details_ = l10n_util::GetStringFUTF16(
397 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
398 UTF8ToUTF16(url.spec()));
399 return;
400 }
401
402 if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) {
[email protected]03ef4b2a2012-03-06 15:04:20403 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
404 site_identity_details_ =
405 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
406 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
407 return;
408 }
409
[email protected]03ef4b2a2012-03-06 15:04:20410 // Identity section.
jam8ae7cad2016-09-08 23:55:21411 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11412
estarkfcfccdb82016-11-14 02:17:29413 if (security_info.malicious_content_status !=
esecklercac56b62016-11-16 13:49:44414 security_state::MALICIOUS_CONTENT_STATUS_NONE) {
estarkfcfccdb82016-11-14 02:17:29415 // The site has been flagged by Safe Browsing as dangerous.
416 GetSiteIdentityByMaliciousContentStatus(
417 security_info.malicious_content_status, &site_identity_status_,
418 &site_identity_details_);
419 } else if (certificate_ &&
420 (!net::IsCertStatusError(security_info.cert_status) ||
421 net::IsCertStatusMinorError(security_info.cert_status))) {
422 // HTTPS with no or minor errors.
estarka3121f6b2015-09-18 21:15:59423 if (security_info.security_level ==
esecklercac56b62016-11-16 13:49:44424 security_state::SECURE_WITH_POLICY_INSTALLED_CERT) {
[email protected]eaf3f322013-04-25 21:53:59425 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37426 site_identity_details_ = l10n_util::GetStringFUTF16(
427 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59428 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20429 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21430 base::string16 issuer_name(
431 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20432 if (issuer_name.empty()) {
433 issuer_name.assign(l10n_util::GetStringUTF16(
434 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
435 }
[email protected]94c74b42013-12-02 15:19:49436
[email protected]03ef4b2a2012-03-06 15:04:20437 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39438 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20439
440 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59441 if (security_info.cert_status &
442 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20443 site_identity_details_ += l10n_util::GetStringUTF16(
444 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59445 } else if (security_info.cert_status &
446 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20447 site_identity_details_ += l10n_util::GetStringUTF16(
448 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
449 } else {
450 NOTREACHED() << "Need to specify string for this warning";
451 }
[email protected]03ef4b2a2012-03-06 15:04:20452 } else {
estarkcf305562016-11-15 03:45:39453 // No major or minor errors.
estarka3121f6b2015-09-18 21:15:59454 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01455 // EV HTTPS page.
estarkcf305562016-11-15 03:45:39456 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
jam8ae7cad2016-09-08 23:55:21457 DCHECK(!certificate_->subject().organization_names.empty());
458 organization_name_ =
459 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01460 // An EV Cert is required to have a city (localityName) and country but
461 // state is "if any".
jam8ae7cad2016-09-08 23:55:21462 DCHECK(!certificate_->subject().locality_name.empty());
463 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01464 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21465 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01466 locality = l10n_util::GetStringFUTF16(
467 IDS_PAGEINFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21468 UTF8ToUTF16(certificate_->subject().locality_name),
469 UTF8ToUTF16(certificate_->subject().state_or_province_name),
470 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01471 } else {
472 locality = l10n_util::GetStringFUTF16(
473 IDS_PAGEINFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21474 UTF8ToUTF16(certificate_->subject().locality_name),
475 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01476 }
jam8ae7cad2016-09-08 23:55:21477 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01478 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39479 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED,
jam8ae7cad2016-09-08 23:55:21480 UTF8ToUTF16(certificate_->subject().organization_names[0]),
estarkcf305562016-11-15 03:45:39481 locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01482 } else {
483 // Non-EV OK HTTPS page.
estarkcf305562016-11-15 03:45:39484 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
rsleevi4f8012722014-09-30 01:28:01485 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21486 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01487 if (issuer_name.empty()) {
488 issuer_name.assign(l10n_util::GetStringUTF16(
489 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
490 }
[email protected]94c74b42013-12-02 15:19:49491
rsleevi4f8012722014-09-30 01:28:01492 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39493 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
rsleevi4f8012722014-09-30 01:28:01494 }
elawrencebe87bd62017-01-10 16:08:59495 if (security_info.sha1_in_chain) {
496 site_identity_status_ =
497 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM;
498 site_identity_details_ +=
499 UTF8ToUTF16("\n\n") +
500 l10n_util::GetStringUTF16(
501 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM);
rsleevi4f8012722014-09-30 01:28:01502 }
[email protected]03ef4b2a2012-03-06 15:04:20503 }
504 } else {
505 // HTTP or HTTPS with errors (not warnings).
506 site_identity_details_.assign(l10n_util::GetStringUTF16(
507 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
jam8ae7cad2016-09-08 23:55:21508 if (!security_info.scheme_is_cryptographic || !security_info.certificate)
[email protected]03ef4b2a2012-03-06 15:04:20509 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
510 else
511 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
512
[email protected]a04db822013-12-11 19:14:40513 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59514 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59515 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
jam8ae7cad2016-09-08 23:55:21516 certificate_, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20517 for (size_t i = 0; i < errors.size(); ++i) {
518 site_identity_details_ += bullet;
519 site_identity_details_ += errors[i].short_description();
520 }
521
estarka3121f6b2015-09-18 21:15:59522 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20523 site_identity_details_ += ASCIIToUTF16("\n\n");
524 site_identity_details_ += l10n_util::GetStringUTF16(
525 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
526 }
527 }
528
529 // Site Connection
530 // We consider anything less than 80 bits encryption to be weak encryption.
531 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
532 // weakly encrypted connections.
533 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
534
jshin1fb76462016-04-05 22:13:03535 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19536 if (subject_name.empty()) {
537 subject_name.assign(
538 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
539 }
540
jam8ae7cad2016-09-08 23:55:21541 if (!security_info.certificate || !security_info.scheme_is_cryptographic) {
estarka3121f6b2015-09-18 21:15:59542 // Page is still loading (so SSL status is not yet available) or
543 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58544 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
545
546 site_connection_details_.assign(l10n_util::GetStringFUTF16(
547 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
548 subject_name));
estarka3121f6b2015-09-18 21:15:59549 } else if (security_info.security_bits < 0) {
550 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20551 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59552 } else if (security_info.security_bits == 0) {
esecklercac56b62016-11-16 13:49:44553 DCHECK_NE(security_info.security_level, security_state::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20554 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
555 site_connection_details_.assign(l10n_util::GetStringFUTF16(
556 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
557 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20558 } else {
559 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22560
lgarron3e2c33e2016-08-25 06:33:43561 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22562 site_connection_details_.assign(l10n_util::GetStringFUTF16(
563 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
564 subject_name));
565 } else {
566 site_connection_details_.assign(l10n_util::GetStringFUTF16(
567 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
568 subject_name));
569 }
570
estark00e83f12016-08-19 18:24:04571 bool ran_insecure_content = false;
572 bool displayed_insecure_content = false;
573 CheckForInsecureContent(security_info, &displayed_insecure_content,
574 &ran_insecure_content);
575 if (ran_insecure_content || displayed_insecure_content) {
576 site_connection_status_ =
577 ran_insecure_content
578 ? SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE
579 : SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
[email protected]03ef4b2a2012-03-06 15:04:20580 site_connection_details_.assign(l10n_util::GetStringFUTF16(
581 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
582 site_connection_details_,
estark00e83f12016-08-19 18:24:04583 l10n_util::GetStringUTF16(
584 ran_insecure_content
585 ? IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR
586 : IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
[email protected]03ef4b2a2012-03-06 15:04:20587 }
588 }
589
avi655876a2015-12-25 07:18:15590 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59591 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
592 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20593 int ssl_version =
estarka3121f6b2015-09-18 21:15:59594 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20595 const char* ssl_version_str;
596 net::SSLVersionToString(&ssl_version_str, ssl_version);
597 site_connection_details_ += ASCIIToUTF16("\n\n");
598 site_connection_details_ += l10n_util::GetStringFUTF16(
599 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION,
600 ASCIIToUTF16(ssl_version_str));
601
[email protected]03ef4b2a2012-03-06 15:04:20602 const char *key_exchange, *cipher, *mac;
davidben56a8aece2016-10-14 18:20:56603 bool is_aead, is_tls13;
604 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
605 &is_tls13, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20606
607 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57608 if (is_aead) {
davidben56a8aece2016-10-14 18:20:56609 if (is_tls13) {
610 // For TLS 1.3 ciphers, report the group (historically, curve) as the
611 // key exchange.
612 key_exchange = SSL_get_curve_name(security_info.key_exchange_group);
613 if (!key_exchange) {
614 NOTREACHED();
615 key_exchange = "";
616 }
617 }
[email protected]b6c1d9e82013-06-12 17:26:57618 site_connection_details_ += l10n_util::GetStringFUTF16(
619 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
620 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
621 } else {
622 site_connection_details_ += l10n_util::GetStringFUTF16(
623 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS,
624 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
625 }
[email protected]03ef4b2a2012-03-06 15:04:20626
agl078d2102014-10-20 22:03:22627 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 &&
estark00e83f12016-08-19 18:24:04628 site_connection_status_ <
629 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE) {
agl078d2102014-10-20 22:03:22630 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
631 }
[email protected]03ef4b2a2012-03-06 15:04:20632 }
[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]03ef4b2a2012-03-06 15:04:20642}
[email protected]0b9fdd72012-04-04 10:00:33643
[email protected]df818272012-04-20 13:10:50644void WebsiteSettings::PresentSitePermissions() {
645 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38646 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50647
648 WebsiteSettingsUI::PermissionInfo permission_info;
649 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
650 permission_info.type = kPermissionType[i];
651
mgiucaa319f212016-01-14 03:30:11652 if (!ShouldShowPermission(permission_info.type))
653 continue;
654
[email protected]df818272012-04-20 13:10:50655 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32656 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
657 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21658 DCHECK(value.get());
jdoerriedc72ee942016-12-07 15:43:28659 if (value->GetType() == base::Value::Type::INTEGER) {
sashab2b2a314f2015-01-17 06:42:21660 permission_info.setting =
661 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26662 } else {
sashab2b2a314f2015-01-17 06:42:21663 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26664 }
665
[email protected]8bdf45c32012-08-04 00:12:55666 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28667 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50668
[email protected]b1d113d2012-06-27 21:27:34669 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21670 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34671 permission_info.default_setting = permission_info.setting;
672 permission_info.setting = CONTENT_SETTING_DEFAULT;
673 } else {
674 permission_info.default_setting =
675 content_settings_->GetDefaultContentSetting(permission_info.type,
676 NULL);
[email protected]df818272012-04-20 13:10:50677 }
palmer0da10b32015-02-11 00:42:19678
patricialor2a4f41a2017-03-08 02:52:56679 // For permissions that are still prompting the user and haven't been
680 // explicitly set by another source, check its embargo status.
681 if (PermissionUtil::IsPermission(permission_info.type) &&
682 permission_info.setting == CONTENT_SETTING_DEFAULT &&
683 permission_info.source ==
684 content_settings::SettingSource::SETTING_SOURCE_USER) {
685 // TODO(raymes): Use GetPermissionStatus() to retrieve information
686 // about *all* permissions once it has default behaviour implemented for
687 // ContentSettingTypes that aren't permissions.
688 PermissionResult permission_result =
689 PermissionManager::Get(profile_)->GetPermissionStatus(
690 permission_info.type, site_url_, site_url_);
691
692 // If under embargo, update |permission_info| to reflect that.
693 if (permission_result.content_setting == CONTENT_SETTING_BLOCK &&
694 (permission_result.source ==
695 PermissionStatusSource::MULTIPLE_DISMISSALS ||
696 permission_result.source ==
697 PermissionStatusSource::SAFE_BROWSING_BLACKLIST))
698 permission_info.setting = permission_result.content_setting;
699 }
700
palmer64a099982016-03-09 21:26:11701 permission_info_list.push_back(permission_info);
[email protected]df818272012-04-20 13:10:50702 }
703
reillyg85f57db2016-01-12 23:14:38704 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
705 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10706 const GURL origin = site_url_.GetOrigin();
707 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32708 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38709 chosen_object_info_list.push_back(
avi09dd4d02016-10-14 20:40:09710 base::MakeUnique<WebsiteSettingsUI::ChosenObjectInfo>(
711 ui_info, std::move(object)));
reillyg85f57db2016-01-12 23:14:38712 }
713 }
714
avi09dd4d02016-10-14 20:40:09715 ui_->SetPermissionInfo(permission_info_list,
716 std::move(chosen_object_info_list));
[email protected]0b9fdd72012-04-04 10:00:33717}
718
[email protected]df818272012-04-20 13:10:50719void WebsiteSettings::PresentSiteData() {
720 CookieInfoList cookie_info_list;
vabrbab3ffcb2016-10-04 10:08:10721 const LocalSharedObjectsContainer& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34722 tab_specific_content_settings()->allowed_local_shared_objects();
vabrbab3ffcb2016-10-04 10:08:10723 const LocalSharedObjectsContainer& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34724 tab_specific_content_settings()->blocked_local_shared_objects();
725
726 // Add first party cookie and site data counts.
[email protected]df818272012-04-20 13:10:50727 WebsiteSettingsUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34728 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
729 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15730 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34731 cookie_info_list.push_back(cookie_info);
732
733 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34734 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
735 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15736 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50737 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33738
[email protected]df818272012-04-20 13:10:50739 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33740}
[email protected]16de6de2012-04-04 12:24:14741
[email protected]24c8818c2012-04-25 09:57:41742void WebsiteSettings::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04743 // After initialization the status about the site's connection and its
744 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41745 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
746 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
747 WebsiteSettingsUI::IdentityInfo info;
748 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
749 info.site_identity = UTF16ToUTF8(organization_name());
750 else
jshin1fb76462016-04-05 22:13:03751 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41752
753 info.connection_status = site_connection_status_;
754 info.connection_status_description =
755 UTF16ToUTF8(site_connection_details_);
756 info.identity_status = site_identity_status_;
757 info.identity_status_description =
758 UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21759 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04760 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
[email protected]24c8818c2012-04-25 09:57:41761 ui_->SetIdentityInfo(info);
762}