blob: a8549dddb7e8f68511f29b23c857127dbecb6272 [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"
[email protected]e22d64f2012-09-10 09:03:2359#include "content/public/browser/user_metrics.h"
[email protected]eb2140c2013-07-29 12:37:3460#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2061#include "content/public/common/url_constants.h"
[email protected]6e7845ae2013-03-29 21:48:1162#include "net/cert/cert_status_flags.h"
63#include "net/cert/x509_certificate.h"
[email protected]536fd0b2013-03-14 17:41:5764#include "net/ssl/ssl_cipher_suite_names.h"
65#include "net/ssl/ssl_connection_status_flags.h"
tfarina29a3a1742016-10-28 18:47:3366#include "third_party/boringssl/src/include/openssl/ssl.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;
83
84namespace {
85
jww1ed8ea72014-09-02 20:43:2586// Events for UMA. Do not reorder or change!
87enum SSLCertificateDecisionsDidRevoke {
88 USER_CERT_DECISIONS_NOT_REVOKED = 0,
89 USER_CERT_DECISIONS_REVOKED,
90 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM
91};
92
palmer0da10b32015-02-11 00:42:1993// The list of content settings types to display on the Website Settings UI. THE
94// ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, email
95// [email protected].
[email protected]0b9fdd72012-04-04 10:00:3396ContentSettingsType kPermissionType[] = {
sashab2b2a314f2015-01-17 06:42:2197 CONTENT_SETTINGS_TYPE_GEOLOCATION,
sashab2b2a314f2015-01-17 06:42:2198 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
99 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
palmer0da10b32015-02-11 00:42:19100 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
palmer7715e332016-05-27 00:41:19101 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
lshange085f202016-06-14 01:25:08102#if !defined(OS_ANDROID)
palmer7715e332016-05-27 00:41:19103 CONTENT_SETTINGS_TYPE_PLUGINS,
104 CONTENT_SETTINGS_TYPE_IMAGES,
lshange085f202016-06-14 01:25:08105#endif
palmer7715e332016-05-27 00:41:19106 CONTENT_SETTINGS_TYPE_POPUPS,
nsatragno670fe922016-04-08 14:10:50107 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
palmer7715e332016-05-27 00:41:19108 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
finnur46cafd42016-09-22 10:27:17109 CONTENT_SETTINGS_TYPE_AUTOPLAY,
palmer7715e332016-05-27 00:41:19110 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
[email protected]0b9fdd72012-04-04 10:00:33111};
112
mgiucaa319f212016-01-14 03:30:11113// Determines whether to show permission |type| in the Website Settings UI. Only
114// applies to permissions listed in |kPermissionType|.
115bool ShouldShowPermission(ContentSettingsType type) {
mgiucaa319f212016-01-14 03:30:11116#if !defined(OS_ANDROID)
finnur46cafd42016-09-22 10:27:17117 // Autoplay is Android-only at the moment.
mgiuca273b9672016-11-11 02:22:20118 if (type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
mgiuca0f3e1f72016-05-13 01:56:27119 return false;
mgiucaa319f212016-01-14 03:30:11120#endif
121
122 return true;
123}
124
esecklercac56b62016-11-16 13:49:44125void CheckContentStatus(security_state::ContentStatus content_status,
estark00e83f12016-08-19 18:24:04126 bool* displayed,
127 bool* ran) {
128 switch (content_status) {
esecklercac56b62016-11-16 13:49:44129 case security_state::CONTENT_STATUS_DISPLAYED:
estark00e83f12016-08-19 18:24:04130 *displayed = true;
131 break;
esecklercac56b62016-11-16 13:49:44132 case security_state::CONTENT_STATUS_RAN:
estark00e83f12016-08-19 18:24:04133 *ran = true;
134 break;
esecklercac56b62016-11-16 13:49:44135 case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN:
estark00e83f12016-08-19 18:24:04136 *displayed = true;
137 *ran = true;
138 break;
esecklercac56b62016-11-16 13:49:44139 case security_state::CONTENT_STATUS_UNKNOWN:
140 case security_state::CONTENT_STATUS_NONE:
estark00e83f12016-08-19 18:24:04141 break;
142 }
143}
144
145void CheckForInsecureContent(
esecklercac56b62016-11-16 13:49:44146 const security_state::SecurityInfo& security_info,
estark00e83f12016-08-19 18:24:04147 bool* displayed,
148 bool* ran) {
149 CheckContentStatus(security_info.mixed_content_status, displayed, ran);
150 // Only consider subresources with certificate errors if the main
151 // resource was loaded over HTTPS without major certificate errors. If
152 // the main resource had a certificate error, then it would not be
153 // that useful (and would potentially be confusing) to warn about
154 // subesources that had certificate errors too.
155 if (net::IsCertStatusError(security_info.cert_status) &&
156 !net::IsCertStatusMinorError(security_info.cert_status)) {
157 return;
158 }
159 CheckContentStatus(security_info.content_with_cert_errors_status, displayed,
160 ran);
161}
162
estarkfcfccdb82016-11-14 02:17:29163void GetSiteIdentityByMaliciousContentStatus(
esecklercac56b62016-11-16 13:49:44164 security_state::MaliciousContentStatus malicious_content_status,
estarkfcfccdb82016-11-14 02:17:29165 WebsiteSettings::SiteIdentityStatus* status,
166 base::string16* details) {
167 switch (malicious_content_status) {
esecklercac56b62016-11-16 13:49:44168 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
estarkfcfccdb82016-11-14 02:17:29169 NOTREACHED();
170 break;
esecklercac56b62016-11-16 13:49:44171 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
estarkfcfccdb82016-11-14 02:17:29172 *status = WebsiteSettings::SITE_IDENTITY_STATUS_MALWARE;
173 *details =
lgarrona0a14a482017-01-12 03:04:10174 l10n_util::GetStringUTF16(IDS_PAGEINFO_MALWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29175 break;
esecklercac56b62016-11-16 13:49:44176 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
estarkfcfccdb82016-11-14 02:17:29177 *status = WebsiteSettings::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
178 *details = l10n_util::GetStringUTF16(
lgarrona0a14a482017-01-12 03:04:10179 IDS_PAGEINFO_SOCIAL_ENGINEERING_DETAILS);
estarkfcfccdb82016-11-14 02:17:29180 break;
esecklercac56b62016-11-16 13:49:44181 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
estarkfcfccdb82016-11-14 02:17:29182 *status = WebsiteSettings::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
183 *details = l10n_util::GetStringUTF16(
lgarrona0a14a482017-01-12 03:04:10184 IDS_PAGEINFO_UNWANTED_SOFTWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29185 break;
186 }
187}
188
jshin1fb76462016-04-05 22:13:03189base::string16 GetSimpleSiteName(const GURL& url) {
benwells2337b8102016-04-20 01:53:53190 return url_formatter::FormatUrlForSecurityDisplay(
191 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
palmer153af982015-09-15 02:04:19192}
193
reillyg85f57db2016-01-12 23:14:38194ChooserContextBase* GetUsbChooserContext(Profile* profile) {
195 return UsbChooserContextFactory::GetForProfile(profile);
196}
197
198// The list of chooser types that need to display entries in the Website
199// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
200// email [email protected].
201WebsiteSettings::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52202 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
203 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_WEBSITE_SETTINGS_USB_DEVICE_LABEL,
reillyg85f57db2016-01-12 23:14:38204 IDS_WEBSITE_SETTINGS_DELETE_USB_DEVICE, "name"},
205};
206
[email protected]0b9fdd72012-04-04 10:00:33207} // namespace
208
209WebsiteSettings::WebsiteSettings(
210 WebsiteSettingsUI* ui,
211 Profile* profile,
[email protected]df818272012-04-20 13:10:50212 TabSpecificContentSettings* tab_specific_content_settings,
palmerf2cba0d2015-08-27 23:15:06213 content::WebContents* web_contents,
[email protected]0b9fdd72012-04-04 10:00:33214 const GURL& url,
esecklercac56b62016-11-16 13:49:44215 const security_state::SecurityInfo& security_info)
[email protected]df818272012-04-20 13:10:50216 : TabSpecificContentSettings::SiteDataObserver(
217 tab_specific_content_settings),
dominicknbdd53b5f2016-09-28 01:08:13218 content::WebContentsObserver(web_contents),
[email protected]df818272012-04-20 13:10:50219 ui_(ui),
[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]03ef4b2a2012-03-06 15:04:20223 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
alshabalin5e894c12016-10-25 06:47:46224 show_ssl_decision_revoke_button_(false),
peconn5100d432015-09-16 12:03:08225 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04226 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25227 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19228 did_revoke_user_ssl_decisions_(false),
estark8d67cd7a2016-10-24 05:06:41229 profile_(profile),
esecklercac56b62016-11-16 13:49:44230 security_level_(security_state::NONE) {
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
estark8d67cd7a2016-10-24 05:06:41251 std::string histogram_name;
palmeree0e5af2015-06-05 03:10:40252
estark8d67cd7a2016-10-24 05:06:41253 if (site_url_.SchemeIsCryptographic()) {
esecklercac56b62016-11-16 13:49:44254 if (security_level_ == security_state::SECURE ||
255 security_level_ == security_state::EV_SECURE) {
estark8d67cd7a2016-10-24 05:06:41256 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Valid",
257 action, WEBSITE_SETTINGS_COUNT);
esecklercac56b62016-11-16 13:49:44258 } else if (security_level_ == security_state::NONE) {
estark8d67cd7a2016-10-24 05:06:41259 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded",
260 action, WEBSITE_SETTINGS_COUNT);
esecklercac56b62016-11-16 13:49:44261 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41262 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous",
263 action, WEBSITE_SETTINGS_COUNT);
264 }
265 return;
266 }
267
esecklercac56b62016-11-16 13:49:44268 if (security_level_ == security_state::HTTP_SHOW_WARNING) {
estark8d67cd7a2016-10-24 05:06:41269 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning",
270 action, WEBSITE_SETTINGS_COUNT);
esecklercac56b62016-11-16 13:49:44271 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41272 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous",
273 action, WEBSITE_SETTINGS_COUNT);
274 } else {
275 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral",
276 action, WEBSITE_SETTINGS_COUNT);
lgarron04a93502014-11-04 22:25:04277 }
278}
279
[email protected]df818272012-04-20 13:10:50280void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type,
281 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23282 // Count how often a permission for a specific content type is changed using
283 // the Website Settings UI.
raymes4a13d432015-09-08 00:44:07284 size_t num_values;
285 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
sashab9debecd2014-12-18 04:15:56286 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.OriginInfo.PermissionChanged",
raymes4a13d432015-09-08 00:44:07287 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56288
289 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
290 UMA_HISTOGRAM_ENUMERATION(
291 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07292 num_values);
tommycli34cf29bf2016-09-08 05:46:25293
294 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
295 rappor::SampleDomainAndRegistryFromGURL(
296 g_browser_process->rappor_service(),
297 "ContentSettings.Plugins.AddedAllowException", site_url_);
298 }
sashab9debecd2014-12-18 04:15:56299 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
300 UMA_HISTOGRAM_ENUMERATION(
301 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07302 num_values);
sashab9debecd2014-12-18 04:15:56303 }
[email protected]e22d64f2012-09-10 09:03:23304
lgarron04a93502014-11-04 22:25:04305 // This is technically redundant given the histogram above, but putting the
306 // total count of permission changes in another histogram makes it easier to
307 // compare it against other kinds of actions in WebsiteSettings[PopupView].
308 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_CHANGED_PERMISSION);
309
stefanocs8b3490cc2016-07-28 05:32:52310 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
311 this->profile_, this->site_url_, this->site_url_, type,
312 PermissionSourceUI::OIB);
313
raymesfbaaaaa2015-11-10 02:20:40314 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
315 setting);
[email protected]df818272012-04-20 13:10:50316
[email protected]66f157312012-08-01 13:50:26317 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24318
319 // Refresh the UI to reflect the new setting.
320 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50321}
322
reillyg85f57db2016-01-12 23:14:38323void WebsiteSettings::OnSiteChosenObjectDeleted(
324 const ChooserUIInfo& ui_info,
325 const base::DictionaryValue& object) {
326 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
327 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10328 const GURL origin = site_url_.GetOrigin();
329 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38330
331 show_info_bar_ = true;
332
333 // Refresh the UI to reflect the changed settings.
334 PresentSitePermissions();
335}
336
[email protected]df818272012-04-20 13:10:50337void WebsiteSettings::OnSiteDataAccessed() {
338 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33339}
340
[email protected]66f157312012-08-01 13:50:26341void WebsiteSettings::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49342#if defined(OS_ANDROID)
343 NOTREACHED();
344#else
dominicknbdd53b5f2016-09-28 01:08:13345 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
palmerf2cba0d2015-08-27 23:15:06346 InfoBarService* infobar_service =
dominicknbdd53b5f2016-09-28 01:08:13347 InfoBarService::FromWebContents(web_contents());
palmerf2cba0d2015-08-27 23:15:06348 if (infobar_service)
349 WebsiteSettingsInfoBarDelegate::Create(infobar_service);
350 }
jww1ed8ea72014-09-02 20:43:25351
352 SSLCertificateDecisionsDidRevoke user_decision =
353 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
354 : USER_CERT_DECISIONS_NOT_REVOKED;
355
356 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
357 user_decision,
358 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49359#endif
jww1ed8ea72014-09-02 20:43:25360}
361
362void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() {
363 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29364 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
365 site_url().host());
jww1ed8ea72014-09-02 20:43:25366 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26367}
368
esecklercac56b62016-11-16 13:49:44369void WebsiteSettings::Init(const GURL& url,
370 const security_state::SecurityInfo& security_info) {
meacerde53fcff2016-10-12 19:21:57371#if !defined(OS_ANDROID) && !defined(OS_IOS)
372 // On desktop, internal URLs aren't handled by this class. Instead, a
373 // custom and simpler popup is shown.
374 DCHECK(!url.SchemeIs(content::kChromeUIScheme) &&
375 !url.SchemeIs(content::kChromeDevToolsScheme) &&
376 !url.SchemeIs(content::kViewSourceScheme) &&
377 !url.SchemeIs(content_settings::kExtensionScheme));
378#endif
379
sashab97894ce2014-10-22 10:08:33380 bool isChromeUINativeScheme = false;
zpengdb4a58e2017-01-10 17:40:32381#if defined(OS_ANDROID)
sashab97894ce2014-10-22 10:08:33382 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
383#endif
384
estark8d67cd7a2016-10-24 05:06:41385 security_level_ = security_info.security_level;
386
upendrag.gowda60886a6e2015-10-31 05:51:09387 if (url.SchemeIs(url::kAboutScheme)) {
388 // All about: URLs except about:blank are redirected.
389 DCHECK_EQ(url::kAboutBlankURL, url.spec());
390 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
391 site_identity_details_ =
392 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
393 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
394 site_connection_details_ = l10n_util::GetStringFUTF16(
395 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
396 UTF8ToUTF16(url.spec()));
397 return;
398 }
399
400 if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) {
[email protected]03ef4b2a2012-03-06 15:04:20401 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
402 site_identity_details_ =
403 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
404 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
405 return;
406 }
407
[email protected]03ef4b2a2012-03-06 15:04:20408 // Identity section.
jam8ae7cad2016-09-08 23:55:21409 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11410
estarkfcfccdb82016-11-14 02:17:29411 if (security_info.malicious_content_status !=
esecklercac56b62016-11-16 13:49:44412 security_state::MALICIOUS_CONTENT_STATUS_NONE) {
estarkfcfccdb82016-11-14 02:17:29413 // The site has been flagged by Safe Browsing as dangerous.
414 GetSiteIdentityByMaliciousContentStatus(
415 security_info.malicious_content_status, &site_identity_status_,
416 &site_identity_details_);
417 } else if (certificate_ &&
418 (!net::IsCertStatusError(security_info.cert_status) ||
419 net::IsCertStatusMinorError(security_info.cert_status))) {
420 // HTTPS with no or minor errors.
estarka3121f6b2015-09-18 21:15:59421 if (security_info.security_level ==
esecklercac56b62016-11-16 13:49:44422 security_state::SECURE_WITH_POLICY_INSTALLED_CERT) {
[email protected]eaf3f322013-04-25 21:53:59423 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37424 site_identity_details_ = l10n_util::GetStringFUTF16(
425 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59426 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20427 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21428 base::string16 issuer_name(
429 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20430 if (issuer_name.empty()) {
431 issuer_name.assign(l10n_util::GetStringUTF16(
432 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
433 }
[email protected]94c74b42013-12-02 15:19:49434
[email protected]03ef4b2a2012-03-06 15:04:20435 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39436 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20437
438 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59439 if (security_info.cert_status &
440 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20441 site_identity_details_ += l10n_util::GetStringUTF16(
442 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59443 } else if (security_info.cert_status &
444 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20445 site_identity_details_ += l10n_util::GetStringUTF16(
446 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
447 } else {
448 NOTREACHED() << "Need to specify string for this warning";
449 }
[email protected]03ef4b2a2012-03-06 15:04:20450 } else {
estarkcf305562016-11-15 03:45:39451 // No major or minor errors.
estarka3121f6b2015-09-18 21:15:59452 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01453 // EV HTTPS page.
estarkcf305562016-11-15 03:45:39454 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
jam8ae7cad2016-09-08 23:55:21455 DCHECK(!certificate_->subject().organization_names.empty());
456 organization_name_ =
457 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01458 // An EV Cert is required to have a city (localityName) and country but
459 // state is "if any".
jam8ae7cad2016-09-08 23:55:21460 DCHECK(!certificate_->subject().locality_name.empty());
461 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01462 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21463 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01464 locality = l10n_util::GetStringFUTF16(
465 IDS_PAGEINFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21466 UTF8ToUTF16(certificate_->subject().locality_name),
467 UTF8ToUTF16(certificate_->subject().state_or_province_name),
468 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01469 } else {
470 locality = l10n_util::GetStringFUTF16(
471 IDS_PAGEINFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21472 UTF8ToUTF16(certificate_->subject().locality_name),
473 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01474 }
jam8ae7cad2016-09-08 23:55:21475 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01476 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39477 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED,
jam8ae7cad2016-09-08 23:55:21478 UTF8ToUTF16(certificate_->subject().organization_names[0]),
estarkcf305562016-11-15 03:45:39479 locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01480 } else {
481 // Non-EV OK HTTPS page.
estarkcf305562016-11-15 03:45:39482 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
rsleevi4f8012722014-09-30 01:28:01483 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21484 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01485 if (issuer_name.empty()) {
486 issuer_name.assign(l10n_util::GetStringUTF16(
487 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
488 }
[email protected]94c74b42013-12-02 15:19:49489
rsleevi4f8012722014-09-30 01:28:01490 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39491 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
rsleevi4f8012722014-09-30 01:28:01492 }
elawrencebe87bd62017-01-10 16:08:59493 if (security_info.sha1_in_chain) {
494 site_identity_status_ =
495 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM;
496 site_identity_details_ +=
497 UTF8ToUTF16("\n\n") +
498 l10n_util::GetStringUTF16(
499 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM);
rsleevi4f8012722014-09-30 01:28:01500 }
[email protected]03ef4b2a2012-03-06 15:04:20501 }
502 } else {
503 // HTTP or HTTPS with errors (not warnings).
504 site_identity_details_.assign(l10n_util::GetStringUTF16(
505 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
jam8ae7cad2016-09-08 23:55:21506 if (!security_info.scheme_is_cryptographic || !security_info.certificate)
[email protected]03ef4b2a2012-03-06 15:04:20507 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
508 else
509 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
510
[email protected]a04db822013-12-11 19:14:40511 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59512 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59513 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
jam8ae7cad2016-09-08 23:55:21514 certificate_, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20515 for (size_t i = 0; i < errors.size(); ++i) {
516 site_identity_details_ += bullet;
517 site_identity_details_ += errors[i].short_description();
518 }
519
estarka3121f6b2015-09-18 21:15:59520 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20521 site_identity_details_ += ASCIIToUTF16("\n\n");
522 site_identity_details_ += l10n_util::GetStringUTF16(
523 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
524 }
525 }
526
527 // Site Connection
528 // We consider anything less than 80 bits encryption to be weak encryption.
529 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
530 // weakly encrypted connections.
531 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
532
jshin1fb76462016-04-05 22:13:03533 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19534 if (subject_name.empty()) {
535 subject_name.assign(
536 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
537 }
538
jam8ae7cad2016-09-08 23:55:21539 if (!security_info.certificate || !security_info.scheme_is_cryptographic) {
estarka3121f6b2015-09-18 21:15:59540 // Page is still loading (so SSL status is not yet available) or
541 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58542 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
543
544 site_connection_details_.assign(l10n_util::GetStringFUTF16(
545 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
546 subject_name));
estarka3121f6b2015-09-18 21:15:59547 } else if (security_info.security_bits < 0) {
548 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20549 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59550 } else if (security_info.security_bits == 0) {
esecklercac56b62016-11-16 13:49:44551 DCHECK_NE(security_info.security_level, security_state::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20552 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
553 site_connection_details_.assign(l10n_util::GetStringFUTF16(
554 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
555 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20556 } else {
557 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22558
lgarron3e2c33e2016-08-25 06:33:43559 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22560 site_connection_details_.assign(l10n_util::GetStringFUTF16(
561 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
562 subject_name));
563 } else {
564 site_connection_details_.assign(l10n_util::GetStringFUTF16(
565 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
566 subject_name));
567 }
568
estark00e83f12016-08-19 18:24:04569 bool ran_insecure_content = false;
570 bool displayed_insecure_content = false;
571 CheckForInsecureContent(security_info, &displayed_insecure_content,
572 &ran_insecure_content);
573 if (ran_insecure_content || displayed_insecure_content) {
574 site_connection_status_ =
575 ran_insecure_content
576 ? SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE
577 : SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
[email protected]03ef4b2a2012-03-06 15:04:20578 site_connection_details_.assign(l10n_util::GetStringFUTF16(
579 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
580 site_connection_details_,
estark00e83f12016-08-19 18:24:04581 l10n_util::GetStringUTF16(
582 ran_insecure_content
583 ? IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR
584 : IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
[email protected]03ef4b2a2012-03-06 15:04:20585 }
586 }
587
avi655876a2015-12-25 07:18:15588 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59589 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
590 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20591 int ssl_version =
estarka3121f6b2015-09-18 21:15:59592 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20593 const char* ssl_version_str;
594 net::SSLVersionToString(&ssl_version_str, ssl_version);
595 site_connection_details_ += ASCIIToUTF16("\n\n");
596 site_connection_details_ += l10n_util::GetStringFUTF16(
597 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION,
598 ASCIIToUTF16(ssl_version_str));
599
[email protected]03ef4b2a2012-03-06 15:04:20600 const char *key_exchange, *cipher, *mac;
davidben56a8aece2016-10-14 18:20:56601 bool is_aead, is_tls13;
602 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
603 &is_tls13, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20604
605 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57606 if (is_aead) {
davidben56a8aece2016-10-14 18:20:56607 if (is_tls13) {
608 // For TLS 1.3 ciphers, report the group (historically, curve) as the
609 // key exchange.
610 key_exchange = SSL_get_curve_name(security_info.key_exchange_group);
611 if (!key_exchange) {
612 NOTREACHED();
613 key_exchange = "";
614 }
615 }
[email protected]b6c1d9e82013-06-12 17:26:57616 site_connection_details_ += l10n_util::GetStringFUTF16(
617 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
618 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
619 } else {
620 site_connection_details_ += l10n_util::GetStringFUTF16(
621 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS,
622 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
623 }
[email protected]03ef4b2a2012-03-06 15:04:20624
agl078d2102014-10-20 22:03:22625 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 &&
estark00e83f12016-08-19 18:24:04626 site_connection_status_ <
627 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE) {
agl078d2102014-10-20 22:03:22628 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
629 }
[email protected]03ef4b2a2012-03-06 15:04:20630 }
[email protected]e583f752012-08-30 13:26:21631
[email protected]71cd5ef2014-08-13 21:22:04632 // Check if a user decision has been made to allow or deny certificates with
633 // errors on this site.
634 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50635 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04636 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40637 // Only show an SSL decision revoke button if the user has chosen to bypass
638 // SSL host errors for this host in the past.
639 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]03ef4b2a2012-03-06 15:04:20640}
[email protected]0b9fdd72012-04-04 10:00:33641
[email protected]df818272012-04-20 13:10:50642void WebsiteSettings::PresentSitePermissions() {
643 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38644 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50645
646 WebsiteSettingsUI::PermissionInfo permission_info;
647 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
648 permission_info.type = kPermissionType[i];
649
mgiucaa319f212016-01-14 03:30:11650 if (!ShouldShowPermission(permission_info.type))
651 continue;
652
[email protected]df818272012-04-20 13:10:50653 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32654 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
655 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21656 DCHECK(value.get());
jdoerriedc72ee942016-12-07 15:43:28657 if (value->GetType() == base::Value::Type::INTEGER) {
sashab2b2a314f2015-01-17 06:42:21658 permission_info.setting =
659 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26660 } else {
sashab2b2a314f2015-01-17 06:42:21661 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26662 }
663
[email protected]8bdf45c32012-08-04 00:12:55664 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28665 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50666
[email protected]b1d113d2012-06-27 21:27:34667 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21668 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34669 permission_info.default_setting = permission_info.setting;
670 permission_info.setting = CONTENT_SETTING_DEFAULT;
671 } else {
672 permission_info.default_setting =
673 content_settings_->GetDefaultContentSetting(permission_info.type,
674 NULL);
[email protected]df818272012-04-20 13:10:50675 }
palmer0da10b32015-02-11 00:42:19676
palmer64a099982016-03-09 21:26:11677 permission_info_list.push_back(permission_info);
[email protected]df818272012-04-20 13:10:50678 }
679
reillyg85f57db2016-01-12 23:14:38680 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
681 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10682 const GURL origin = site_url_.GetOrigin();
683 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32684 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38685 chosen_object_info_list.push_back(
avi09dd4d02016-10-14 20:40:09686 base::MakeUnique<WebsiteSettingsUI::ChosenObjectInfo>(
687 ui_info, std::move(object)));
reillyg85f57db2016-01-12 23:14:38688 }
689 }
690
avi09dd4d02016-10-14 20:40:09691 ui_->SetPermissionInfo(permission_info_list,
692 std::move(chosen_object_info_list));
[email protected]0b9fdd72012-04-04 10:00:33693}
694
[email protected]df818272012-04-20 13:10:50695void WebsiteSettings::PresentSiteData() {
696 CookieInfoList cookie_info_list;
vabrbab3ffcb2016-10-04 10:08:10697 const LocalSharedObjectsContainer& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34698 tab_specific_content_settings()->allowed_local_shared_objects();
vabrbab3ffcb2016-10-04 10:08:10699 const LocalSharedObjectsContainer& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34700 tab_specific_content_settings()->blocked_local_shared_objects();
701
702 // Add first party cookie and site data counts.
[email protected]df818272012-04-20 13:10:50703 WebsiteSettingsUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34704 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
705 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15706 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34707 cookie_info_list.push_back(cookie_info);
708
709 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34710 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
711 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15712 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50713 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33714
[email protected]df818272012-04-20 13:10:50715 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33716}
[email protected]16de6de2012-04-04 12:24:14717
[email protected]24c8818c2012-04-25 09:57:41718void WebsiteSettings::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04719 // After initialization the status about the site's connection and its
720 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41721 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
722 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
723 WebsiteSettingsUI::IdentityInfo info;
724 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
725 info.site_identity = UTF16ToUTF8(organization_name());
726 else
jshin1fb76462016-04-05 22:13:03727 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41728
729 info.connection_status = site_connection_status_;
730 info.connection_status_description =
731 UTF16ToUTF8(site_connection_details_);
732 info.identity_status = site_identity_status_;
733 info.identity_status_description =
734 UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21735 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04736 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
[email protected]24c8818c2012-04-25 09:57:41737 ui_->SetIdentityInfo(info);
738}