blob: f451949a5a67e216e57bcc906735ee17dbce9b48 [file] [log] [blame]
[email protected]03ef4b2a2012-03-06 15:04:201// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]4237dd52012-06-05 00:00:325#include "chrome/browser/ui/website_settings/website_settings.h"
[email protected]03ef4b2a2012-03-06 15:04:206
avi655876a2015-12-25 07:18:157#include <stddef.h>
8#include <stdint.h>
9
[email protected]03ef4b2a2012-03-06 15:04:2010#include <string>
11#include <vector>
12
[email protected]eb2140c2013-07-29 12:37:3413#include "base/command_line.h"
[email protected]15b092542012-05-16 13:08:1414#include "base/i18n/time_formatting.h"
avi655876a2015-12-25 07:18:1515#include "base/macros.h"
[email protected]71cd5ef2014-08-13 21:22:0416#include "base/metrics/field_trial.h"
asvitkine75036032016-09-01 20:49:3417#include "base/metrics/histogram_macros.h"
[email protected]3ea1b182013-02-08 22:38:4118#include "base/strings/string_number_conversions.h"
jialiul02aad2d2015-04-01 18:56:0319#include "base/strings/stringprintf.h"
[email protected]774cc3c2013-06-07 20:26:4520#include "base/strings/utf_string_conversions.h"
[email protected]0b9fdd72012-04-04 10:00:3321#include "base/values.h"
avi655876a2015-12-25 07:18:1522#include "build/build_config.h"
jialiul02aad2d2015-04-01 18:56:0323#include "chrome/browser/browser_process.h"
[email protected]6b8a3c742014-07-25 00:25:3524#include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h"
[email protected]b0cb5e82012-07-19 19:22:4725#include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
26#include "chrome/browser/browsing_data/browsing_data_database_helper.h"
27#include "chrome/browser/browsing_data/browsing_data_file_system_helper.h"
28#include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
29#include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
peconn5100d432015-09-16 12:03:0830#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
[email protected]77a91c72012-08-13 16:19:3431#include "chrome/browser/history/history_service_factory.h"
palmerf2cba0d2015-08-27 23:15:0632#include "chrome/browser/infobars/infobar_service.h"
reillyg85f57db2016-01-12 23:14:3833#include "chrome/browser/permissions/chooser_context_base.h"
tsergeantf1e89352016-01-15 20:34:5434#include "chrome/browser/permissions/permission_uma_util.h"
35#include "chrome/browser/permissions/permission_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2036#include "chrome/browser/profiles/profile.h"
[email protected]71cd5ef2014-08-13 21:22:0437#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
38#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
[email protected]4237dd52012-06-05 00:00:3239#include "chrome/browser/ui/website_settings/website_settings_ui.h"
reillyg85f57db2016-01-12 23:14:3840#include "chrome/browser/usb/usb_chooser_context.h"
41#include "chrome/browser/usb/usb_chooser_context_factory.h"
[email protected]71cd5ef2014-08-13 21:22:0442#include "chrome/common/chrome_switches.h"
sievers2f1e8112015-12-04 18:43:5643#include "chrome/common/features.h"
jsbellddb849e2015-08-27 00:12:5644#include "chrome/common/url_constants.h"
thestig884a1602014-08-27 01:29:3945#include "chrome/grit/chromium_strings.h"
46#include "chrome/grit/generated_resources.h"
reillyg85f57db2016-01-12 23:14:3847#include "chrome/grit/theme_resources.h"
mukai8eaec822014-10-25 17:53:1648#include "components/content_settings/core/browser/content_settings_utils.h"
49#include "components/content_settings/core/browser/host_content_settings_map.h"
vabr48565592014-10-08 15:06:0250#include "components/content_settings/core/browser/local_shared_objects_counter.h"
palmer0da10b32015-02-11 00:42:1951#include "components/content_settings/core/common/content_settings.h"
vasiliif62dbf92014-09-05 10:23:1352#include "components/content_settings/core/common/content_settings_pattern.h"
jialiul02aad2d2015-04-01 18:56:0353#include "components/rappor/rappor_utils.h"
felt2493b4452015-09-17 20:33:5954#include "components/ssl_errors/error_info.h"
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"
[email protected]03ef4b2a2012-03-06 15:04:2067#include "ui/base/l10n/l10n_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2068
[email protected]24a9f1c92013-11-13 12:33:3769#if defined(OS_CHROMEOS)
70#include "chrome/browser/chromeos/policy/policy_cert_service.h"
71#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
72#endif
73
estade3feb83f2015-09-01 23:00:4974#if !defined(OS_ANDROID)
mgiucaa319f212016-01-14 03:30:1175#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
estade3feb83f2015-09-01 23:00:4976#include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h"
77#endif
78
[email protected]ab6df3b12013-12-24 23:32:2679using base::ASCIIToUTF16;
80using base::UTF8ToUTF16;
[email protected]f729d7a2013-12-26 07:07:5681using base::UTF16ToUTF8;
[email protected]0b9fdd72012-04-04 10:00:3382using content::BrowserThread;
estarkd9e54fb2016-01-11 19:37:1283using security_state::SecurityStateModel;
[email protected]0b9fdd72012-04-04 10:00:3384
85namespace {
86
jww1ed8ea72014-09-02 20:43:2587// Events for UMA. Do not reorder or change!
88enum SSLCertificateDecisionsDidRevoke {
89 USER_CERT_DECISIONS_NOT_REVOKED = 0,
90 USER_CERT_DECISIONS_REVOKED,
91 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM
92};
93
palmer0da10b32015-02-11 00:42:1994// The list of content settings types to display on the Website Settings UI. THE
95// ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, email
96// [email protected].
[email protected]0b9fdd72012-04-04 10:00:3397ContentSettingsType kPermissionType[] = {
sashab2b2a314f2015-01-17 06:42:2198 CONTENT_SETTINGS_TYPE_GEOLOCATION,
sashab2b2a314f2015-01-17 06:42:2199 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
100 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
palmer0da10b32015-02-11 00:42:19101 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
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_KEYGEN,
110 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
lshange085f202016-06-14 01:25:08111#if !defined(OS_ANDROID)
palmer7715e332016-05-27 00:41:19112 CONTENT_SETTINGS_TYPE_MOUSELOCK,
lshange085f202016-06-14 01:25:08113#endif
palmer7715e332016-05-27 00:41:19114 CONTENT_SETTINGS_TYPE_FULLSCREEN,
finnur46cafd42016-09-22 10:27:17115 CONTENT_SETTINGS_TYPE_AUTOPLAY,
palmer7715e332016-05-27 00:41:19116 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
[email protected]0b9fdd72012-04-04 10:00:33117};
118
mgiucaa319f212016-01-14 03:30:11119// Determines whether to show permission |type| in the Website Settings UI. Only
120// applies to permissions listed in |kPermissionType|.
121bool ShouldShowPermission(ContentSettingsType type) {
mgiuca0f3e1f72016-05-13 01:56:27122 // TODO(mgiuca): When simplified-fullscreen-ui is enabled permanently on
123 // Android, remove these from kPermissionType, rather than having this check
mgiucaa319f212016-01-14 03:30:11124 // (http://crbug.com/577396).
125#if !defined(OS_ANDROID)
mgiuca0f3e1f72016-05-13 01:56:27126 // Fullscreen and mouselock settings are no longer shown (always allow).
finnur46cafd42016-09-22 10:27:17127 // Autoplay is Android-only at the moment.
128 if (type == CONTENT_SETTINGS_TYPE_AUTOPLAY ||
129 type == CONTENT_SETTINGS_TYPE_FULLSCREEN ||
mgiucaa319f212016-01-14 03:30:11130 type == CONTENT_SETTINGS_TYPE_MOUSELOCK) {
mgiuca0f3e1f72016-05-13 01:56:27131 return false;
mgiucaa319f212016-01-14 03:30:11132 }
133#endif
134
135 return true;
136}
137
estark00e83f12016-08-19 18:24:04138void CheckContentStatus(SecurityStateModel::ContentStatus content_status,
139 bool* displayed,
140 bool* ran) {
141 switch (content_status) {
142 case SecurityStateModel::CONTENT_STATUS_DISPLAYED:
143 *displayed = true;
144 break;
145 case SecurityStateModel::CONTENT_STATUS_RAN:
146 *ran = true;
147 break;
148 case SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN:
149 *displayed = true;
150 *ran = true;
151 break;
152 case SecurityStateModel::CONTENT_STATUS_UNKNOWN:
153 case SecurityStateModel::CONTENT_STATUS_NONE:
154 break;
155 }
156}
157
158void CheckForInsecureContent(
159 const SecurityStateModel::SecurityInfo& security_info,
160 bool* displayed,
161 bool* ran) {
162 CheckContentStatus(security_info.mixed_content_status, displayed, ran);
163 // Only consider subresources with certificate errors if the main
164 // resource was loaded over HTTPS without major certificate errors. If
165 // the main resource had a certificate error, then it would not be
166 // that useful (and would potentially be confusing) to warn about
167 // subesources that had certificate errors too.
168 if (net::IsCertStatusError(security_info.cert_status) &&
169 !net::IsCertStatusMinorError(security_info.cert_status)) {
170 return;
171 }
172 CheckContentStatus(security_info.content_with_cert_errors_status, displayed,
173 ran);
174}
175
estark134a9822015-10-29 04:35:18176// Returns true if any of the given statuses match |status|.
177bool CertificateTransparencyStatusMatchAny(
estarka3121f6b2015-09-18 21:15:59178 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49179 net::ct::SCTVerifyStatus status) {
estarka3121f6b2015-09-18 21:15:59180 for (const auto& verify_status : sct_verify_statuses) {
181 if (verify_status == status)
[email protected]94c74b42013-12-02 15:19:49182 return true;
183 }
[email protected]94c74b42013-12-02 15:19:49184 return false;
185}
186
187int GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59188 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49189 bool is_ev) {
190 // No SCTs - no CT information.
estarka3121f6b2015-09-18 21:15:59191 if (sct_verify_statuses.empty())
[email protected]94c74b42013-12-02 15:19:49192 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_NO_CT
193 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_NO_CT);
194
estark134a9822015-10-29 04:35:18195 // Any valid SCT.
196 if (CertificateTransparencyStatusMatchAny(sct_verify_statuses,
197 net::ct::SCT_STATUS_OK))
[email protected]94c74b42013-12-02 15:19:49198 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_VERIFIED
199 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_VERIFIED);
200
estark134a9822015-10-29 04:35:18201 // Any invalid SCT.
eranmb082a9ff2016-09-13 21:03:26202 if (CertificateTransparencyStatusMatchAny(
eranm194b45d2016-08-18 10:00:33203 sct_verify_statuses, net::ct::SCT_STATUS_INVALID_TIMESTAMP) ||
204 CertificateTransparencyStatusMatchAny(
205 sct_verify_statuses, net::ct::SCT_STATUS_INVALID_SIGNATURE))
[email protected]94c74b42013-12-02 15:19:49206 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_INVALID
207 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_INVALID);
208
estark134a9822015-10-29 04:35:18209 // All SCTs are from unknown logs.
[email protected]94c74b42013-12-02 15:19:49210 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_UNVERIFIED
211 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_UNVERIFIED);
212}
213
214// This function will return SITE_IDENTITY_STATUS_CERT or
estark134a9822015-10-29 04:35:18215// SITE_IDENTITY_STATUS_EV_CERT depending on |is_ev| unless all SCTs
216// failed verification, in which case it will return
[email protected]94c74b42013-12-02 15:19:49217// SITE_IDENTITY_STATUS_ERROR.
218WebsiteSettings::SiteIdentityStatus GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59219 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49220 bool is_ev) {
estark134a9822015-10-29 04:35:18221 if (sct_verify_statuses.empty() ||
222 CertificateTransparencyStatusMatchAny(sct_verify_statuses,
223 net::ct::SCT_STATUS_OK))
224 return is_ev ? WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT
225 : WebsiteSettings::SITE_IDENTITY_STATUS_CERT;
[email protected]94c74b42013-12-02 15:19:49226
estark134a9822015-10-29 04:35:18227 return WebsiteSettings::SITE_IDENTITY_STATUS_CT_ERROR;
[email protected]94c74b42013-12-02 15:19:49228}
229
jshin1fb76462016-04-05 22:13:03230base::string16 GetSimpleSiteName(const GURL& url) {
benwells2337b8102016-04-20 01:53:53231 return url_formatter::FormatUrlForSecurityDisplay(
232 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
palmer153af982015-09-15 02:04:19233}
234
reillyg85f57db2016-01-12 23:14:38235ChooserContextBase* GetUsbChooserContext(Profile* profile) {
236 return UsbChooserContextFactory::GetForProfile(profile);
237}
238
239// The list of chooser types that need to display entries in the Website
240// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
241// email [email protected].
242WebsiteSettings::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52243 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
244 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_WEBSITE_SETTINGS_USB_DEVICE_LABEL,
reillyg85f57db2016-01-12 23:14:38245 IDS_WEBSITE_SETTINGS_DELETE_USB_DEVICE, "name"},
246};
247
[email protected]0b9fdd72012-04-04 10:00:33248} // namespace
249
250WebsiteSettings::WebsiteSettings(
251 WebsiteSettingsUI* ui,
252 Profile* profile,
[email protected]df818272012-04-20 13:10:50253 TabSpecificContentSettings* tab_specific_content_settings,
palmerf2cba0d2015-08-27 23:15:06254 content::WebContents* web_contents,
[email protected]0b9fdd72012-04-04 10:00:33255 const GURL& url,
jam8ae7cad2016-09-08 23:55:21256 const SecurityStateModel::SecurityInfo& security_info)
[email protected]df818272012-04-20 13:10:50257 : TabSpecificContentSettings::SiteDataObserver(
258 tab_specific_content_settings),
259 ui_(ui),
pkastingacd1e122016-05-19 23:55:10260#if !defined(OS_ANDROID)
palmerf2cba0d2015-08-27 23:15:06261 web_contents_(web_contents),
pkastingacd1e122016-05-19 23:55:10262#endif
[email protected]66f157312012-08-01 13:50:26263 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33264 site_url_(url),
265 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]03ef4b2a2012-03-06 15:04:20266 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
peconn5100d432015-09-16 12:03:08267 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04268 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25269 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19270 did_revoke_user_ssl_decisions_(false),
271 profile_(profile) {
estarka3121f6b2015-09-18 21:15:59272 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33273
274 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50275 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41276 PresentSiteIdentity();
[email protected]e22d64f2012-09-10 09:03:23277
278 // Every time the Website Settings UI is opened a |WebsiteSettings| object is
279 // created. So this counts how ofter the Website Settings UI is opened.
lgarron04a93502014-11-04 22:25:04280 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20281}
282
[email protected]0b9fdd72012-04-04 10:00:33283WebsiteSettings::~WebsiteSettings() {
[email protected]03ef4b2a2012-03-06 15:04:20284}
285
lgarron04a93502014-11-04 22:25:04286void WebsiteSettings::RecordWebsiteSettingsAction(
287 WebsiteSettingsAction action) {
288 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action",
289 action,
290 WEBSITE_SETTINGS_COUNT);
291
292 // Use a separate histogram to record actions if they are done on a page with
293 // an HTTPS URL. Note that this *disregards* security status.
palmeree0e5af2015-06-05 03:10:40294 //
295
296 // TODO(palmer): Consider adding a new histogram for
297 // GURL::SchemeIsCryptographic. (We don't want to replace this call with a
298 // call to that function because we don't want to change the meanings of
299 // existing metrics.) This would inform the decision to mark non-secure
300 // origins as Dubious or Non-Secure; the overall bug for that is
301 // crbug.com/454579.
lgarron04a93502014-11-04 22:25:04302 if (site_url_.SchemeIs(url::kHttpsScheme)) {
303 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action.HttpsUrl",
304 action,
305 WEBSITE_SETTINGS_COUNT);
306 }
307}
308
[email protected]df818272012-04-20 13:10:50309void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type,
310 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23311 // Count how often a permission for a specific content type is changed using
312 // the Website Settings UI.
raymes4a13d432015-09-08 00:44:07313 size_t num_values;
314 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
sashab9debecd2014-12-18 04:15:56315 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.OriginInfo.PermissionChanged",
raymes4a13d432015-09-08 00:44:07316 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56317
318 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
319 UMA_HISTOGRAM_ENUMERATION(
320 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07321 num_values);
tommycli34cf29bf2016-09-08 05:46:25322
323 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
324 rappor::SampleDomainAndRegistryFromGURL(
325 g_browser_process->rappor_service(),
326 "ContentSettings.Plugins.AddedAllowException", site_url_);
327 }
sashab9debecd2014-12-18 04:15:56328 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
329 UMA_HISTOGRAM_ENUMERATION(
330 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07331 num_values);
sashab9debecd2014-12-18 04:15:56332 }
[email protected]e22d64f2012-09-10 09:03:23333
lgarron04a93502014-11-04 22:25:04334 // This is technically redundant given the histogram above, but putting the
335 // total count of permission changes in another histogram makes it easier to
336 // compare it against other kinds of actions in WebsiteSettings[PopupView].
337 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_CHANGED_PERMISSION);
338
stefanocs8b3490cc2016-07-28 05:32:52339 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
340 this->profile_, this->site_url_, this->site_url_, type,
341 PermissionSourceUI::OIB);
342
raymesfbaaaaa2015-11-10 02:20:40343 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
344 setting);
[email protected]df818272012-04-20 13:10:50345
[email protected]66f157312012-08-01 13:50:26346 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24347
[email protected]2f45d542012-08-22 08:47:24348 // Refresh the UI to reflect the new setting.
349 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50350}
351
reillyg85f57db2016-01-12 23:14:38352void WebsiteSettings::OnSiteChosenObjectDeleted(
353 const ChooserUIInfo& ui_info,
354 const base::DictionaryValue& object) {
355 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
356 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10357 const GURL origin = site_url_.GetOrigin();
358 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38359
360 show_info_bar_ = true;
361
362 // Refresh the UI to reflect the changed settings.
363 PresentSitePermissions();
364}
365
[email protected]df818272012-04-20 13:10:50366void WebsiteSettings::OnSiteDataAccessed() {
367 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33368}
369
[email protected]66f157312012-08-01 13:50:26370void WebsiteSettings::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49371#if defined(OS_ANDROID)
372 NOTREACHED();
373#else
palmerf2cba0d2015-08-27 23:15:06374 if (show_info_bar_ && web_contents_) {
375 InfoBarService* infobar_service =
376 InfoBarService::FromWebContents(web_contents_);
377 if (infobar_service)
378 WebsiteSettingsInfoBarDelegate::Create(infobar_service);
379 }
jww1ed8ea72014-09-02 20:43:25380
381 SSLCertificateDecisionsDidRevoke user_decision =
382 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
383 : USER_CERT_DECISIONS_NOT_REVOKED;
384
385 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
386 user_decision,
387 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49388#endif
jww1ed8ea72014-09-02 20:43:25389}
390
391void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() {
392 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29393 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
394 site_url().host());
jww1ed8ea72014-09-02 20:43:25395 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26396}
397
estarka3121f6b2015-09-18 21:15:59398void WebsiteSettings::Init(
399 const GURL& url,
400 const SecurityStateModel::SecurityInfo& security_info) {
sashab97894ce2014-10-22 10:08:33401 bool isChromeUINativeScheme = false;
sievers2f1e8112015-12-04 18:43:56402#if BUILDFLAG(ANDROID_JAVA_UI)
sashab97894ce2014-10-22 10:08:33403 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
404#endif
405
upendrag.gowda60886a6e2015-10-31 05:51:09406 if (url.SchemeIs(url::kAboutScheme)) {
407 // All about: URLs except about:blank are redirected.
408 DCHECK_EQ(url::kAboutBlankURL, url.spec());
409 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
410 site_identity_details_ =
411 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
412 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
413 site_connection_details_ = l10n_util::GetStringFUTF16(
414 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
415 UTF8ToUTF16(url.spec()));
416 return;
417 }
418
419 if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) {
[email protected]03ef4b2a2012-03-06 15:04:20420 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
421 site_identity_details_ =
422 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
423 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
424 return;
425 }
426
[email protected]03ef4b2a2012-03-06 15:04:20427 // Identity section.
jam8ae7cad2016-09-08 23:55:21428 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11429
estarka3121f6b2015-09-18 21:15:59430 // HTTPS with no or minor errors.
jam8ae7cad2016-09-08 23:55:21431 if (certificate_ &&
estarka3121f6b2015-09-18 21:15:59432 (!net::IsCertStatusError(security_info.cert_status) ||
433 net::IsCertStatusMinorError(security_info.cert_status))) {
[email protected]03ef4b2a2012-03-06 15:04:20434 // There are no major errors. Check for minor errors.
estarka3121f6b2015-09-18 21:15:59435 if (security_info.security_level ==
felt89f3f212016-09-27 00:20:30436 SecurityStateModel::SECURE_WITH_POLICY_INSTALLED_CERT) {
[email protected]eaf3f322013-04-25 21:53:59437 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37438 site_identity_details_ = l10n_util::GetStringFUTF16(
439 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59440 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20441 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21442 base::string16 issuer_name(
443 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20444 if (issuer_name.empty()) {
445 issuer_name.assign(l10n_util::GetStringUTF16(
446 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
447 }
[email protected]94c74b42013-12-02 15:19:49448
[email protected]03ef4b2a2012-03-06 15:04:20449 site_identity_details_.assign(l10n_util::GetStringFUTF16(
[email protected]94c74b42013-12-02 15:19:49450 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59451 security_info.sct_verify_statuses, false /* not EV */),
[email protected]94c74b42013-12-02 15:19:49452 issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20453
454 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59455 if (security_info.cert_status &
456 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20457 site_identity_details_ += l10n_util::GetStringUTF16(
458 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59459 } else if (security_info.cert_status &
460 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20461 site_identity_details_ += l10n_util::GetStringUTF16(
462 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
463 } else {
464 NOTREACHED() << "Need to specify string for this warning";
465 }
[email protected]03ef4b2a2012-03-06 15:04:20466 } else {
estarka3121f6b2015-09-18 21:15:59467 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01468 // EV HTTPS page.
469 site_identity_status_ = GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59470 security_info.sct_verify_statuses, true);
jam8ae7cad2016-09-08 23:55:21471 DCHECK(!certificate_->subject().organization_names.empty());
472 organization_name_ =
473 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01474 // An EV Cert is required to have a city (localityName) and country but
475 // state is "if any".
jam8ae7cad2016-09-08 23:55:21476 DCHECK(!certificate_->subject().locality_name.empty());
477 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01478 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21479 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01480 locality = l10n_util::GetStringFUTF16(
481 IDS_PAGEINFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21482 UTF8ToUTF16(certificate_->subject().locality_name),
483 UTF8ToUTF16(certificate_->subject().state_or_province_name),
484 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01485 } else {
486 locality = l10n_util::GetStringFUTF16(
487 IDS_PAGEINFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21488 UTF8ToUTF16(certificate_->subject().locality_name),
489 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01490 }
jam8ae7cad2016-09-08 23:55:21491 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01492 site_identity_details_.assign(l10n_util::GetStringFUTF16(
493 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59494 security_info.sct_verify_statuses, true /* is EV */),
jam8ae7cad2016-09-08 23:55:21495 UTF8ToUTF16(certificate_->subject().organization_names[0]),
496 locality,
497 UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01498 } else {
499 // Non-EV OK HTTPS page.
500 site_identity_status_ = GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59501 security_info.sct_verify_statuses, false);
rsleevi4f8012722014-09-30 01:28:01502 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21503 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01504 if (issuer_name.empty()) {
505 issuer_name.assign(l10n_util::GetStringUTF16(
506 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
507 }
[email protected]94c74b42013-12-02 15:19:49508
rsleevi4f8012722014-09-30 01:28:01509 site_identity_details_.assign(l10n_util::GetStringFUTF16(
510 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59511 security_info.sct_verify_statuses, false /* not EV */),
rsleevi4f8012722014-09-30 01:28:01512 issuer_name));
513 }
lgarroncc53de22015-10-05 23:03:17514 switch (security_info.sha1_deprecation_status) {
515 case SecurityStateModel::DEPRECATED_SHA1_MINOR:
516 site_identity_status_ =
517 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR;
518 site_identity_details_ +=
519 UTF8ToUTF16("\n\n") +
520 l10n_util::GetStringUTF16(
521 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MINOR);
522 break;
523 case SecurityStateModel::DEPRECATED_SHA1_MAJOR:
524 site_identity_status_ =
525 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR;
526 site_identity_details_ +=
527 UTF8ToUTF16("\n\n") +
528 l10n_util::GetStringUTF16(
529 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR);
530 break;
531 case SecurityStateModel::NO_DEPRECATED_SHA1:
532 // Nothing to do.
533 break;
felt61638452016-08-09 22:21:55534 case SecurityStateModel::UNKNOWN_SHA1:
535 // UNKNOWN_SHA1 should only appear when certificate info has not been
536 // initialized, in which case this if-statement should not be running
537 // because there is no other cert info.
538 NOTREACHED();
rsleevi4f8012722014-09-30 01:28:01539 }
[email protected]03ef4b2a2012-03-06 15:04:20540 }
541 } else {
542 // HTTP or HTTPS with errors (not warnings).
543 site_identity_details_.assign(l10n_util::GetStringUTF16(
544 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
jam8ae7cad2016-09-08 23:55:21545 if (!security_info.scheme_is_cryptographic || !security_info.certificate)
[email protected]03ef4b2a2012-03-06 15:04:20546 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
547 else
548 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
549
[email protected]a04db822013-12-11 19:14:40550 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59551 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59552 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
jam8ae7cad2016-09-08 23:55:21553 certificate_, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20554 for (size_t i = 0; i < errors.size(); ++i) {
555 site_identity_details_ += bullet;
556 site_identity_details_ += errors[i].short_description();
557 }
558
estarka3121f6b2015-09-18 21:15:59559 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20560 site_identity_details_ += ASCIIToUTF16("\n\n");
561 site_identity_details_ += l10n_util::GetStringUTF16(
562 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
563 }
564 }
565
566 // Site Connection
567 // We consider anything less than 80 bits encryption to be weak encryption.
568 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
569 // weakly encrypted connections.
570 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
571
jshin1fb76462016-04-05 22:13:03572 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19573 if (subject_name.empty()) {
574 subject_name.assign(
575 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
576 }
577
jam8ae7cad2016-09-08 23:55:21578 if (!security_info.certificate || !security_info.scheme_is_cryptographic) {
estarka3121f6b2015-09-18 21:15:59579 // Page is still loading (so SSL status is not yet available) or
580 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58581 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
582
583 site_connection_details_.assign(l10n_util::GetStringFUTF16(
584 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
585 subject_name));
estarka3121f6b2015-09-18 21:15:59586 } else if (security_info.security_bits < 0) {
587 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20588 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59589 } else if (security_info.security_bits == 0) {
590 DCHECK_NE(security_info.security_level, SecurityStateModel::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20591 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
592 site_connection_details_.assign(l10n_util::GetStringFUTF16(
593 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
594 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20595 } else {
596 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22597
lgarron3e2c33e2016-08-25 06:33:43598 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22599 site_connection_details_.assign(l10n_util::GetStringFUTF16(
600 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
601 subject_name));
602 } else {
603 site_connection_details_.assign(l10n_util::GetStringFUTF16(
604 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
605 subject_name));
606 }
607
estark00e83f12016-08-19 18:24:04608 bool ran_insecure_content = false;
609 bool displayed_insecure_content = false;
610 CheckForInsecureContent(security_info, &displayed_insecure_content,
611 &ran_insecure_content);
612 if (ran_insecure_content || displayed_insecure_content) {
613 site_connection_status_ =
614 ran_insecure_content
615 ? SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE
616 : SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
[email protected]03ef4b2a2012-03-06 15:04:20617 site_connection_details_.assign(l10n_util::GetStringFUTF16(
618 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
619 site_connection_details_,
estark00e83f12016-08-19 18:24:04620 l10n_util::GetStringUTF16(
621 ran_insecure_content
622 ? IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR
623 : IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
[email protected]03ef4b2a2012-03-06 15:04:20624 }
625 }
626
avi655876a2015-12-25 07:18:15627 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59628 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
629 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20630 int ssl_version =
estarka3121f6b2015-09-18 21:15:59631 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20632 const char* ssl_version_str;
633 net::SSLVersionToString(&ssl_version_str, ssl_version);
634 site_connection_details_ += ASCIIToUTF16("\n\n");
635 site_connection_details_ += l10n_util::GetStringFUTF16(
636 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION,
637 ASCIIToUTF16(ssl_version_str));
638
[email protected]03ef4b2a2012-03-06 15:04:20639 bool no_renegotiation =
estarka3121f6b2015-09-18 21:15:59640 (security_info.connection_status &
641 net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20642 const char *key_exchange, *cipher, *mac;
[email protected]b6c1d9e82013-06-12 17:26:57643 bool is_aead;
644 net::SSLCipherSuiteToStrings(
645 &key_exchange, &cipher, &mac, &is_aead, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20646
647 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57648 if (is_aead) {
649 site_connection_details_ += l10n_util::GetStringFUTF16(
650 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
651 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
652 } else {
653 site_connection_details_ += l10n_util::GetStringFUTF16(
654 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS,
655 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
656 }
[email protected]03ef4b2a2012-03-06 15:04:20657
agl078d2102014-10-20 22:03:22658 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 &&
estark00e83f12016-08-19 18:24:04659 site_connection_status_ <
660 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE) {
agl078d2102014-10-20 22:03:22661 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
662 }
663
estarka3121f6b2015-09-18 21:15:59664 const bool did_fallback = (security_info.connection_status &
665 net::SSL_CONNECTION_VERSION_FALLBACK) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20666 if (did_fallback) {
[email protected]03ef4b2a2012-03-06 15:04:20667 site_connection_details_ += ASCIIToUTF16("\n\n");
668 site_connection_details_ += l10n_util::GetStringUTF16(
669 IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE);
670 }
agl078d2102014-10-20 22:03:22671
[email protected]03ef4b2a2012-03-06 15:04:20672 if (no_renegotiation) {
673 site_connection_details_ += ASCIIToUTF16("\n\n");
674 site_connection_details_ += l10n_util::GetStringUTF16(
675 IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE);
676 }
677 }
[email protected]e583f752012-08-30 13:26:21678
[email protected]71cd5ef2014-08-13 21:22:04679 // Check if a user decision has been made to allow or deny certificates with
680 // errors on this site.
681 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50682 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04683 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40684 // Only show an SSL decision revoke button if the user has chosen to bypass
685 // SSL host errors for this host in the past.
686 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]71cd5ef2014-08-13 21:22:04687
palmer82b1f7b2015-09-17 19:20:41688 // By default select the Permissions Tab that displays all the site
689 // permissions. In case of a connection error or an issue with the certificate
690 // presented by the website, select the Connection Tab to draw the user's
691 // attention to the issue. If the site does not provide a certificate because
692 // it was loaded over an unencrypted connection, don't select the Connection
693 // Tab.
[email protected]e583f752012-08-30 13:26:21694 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS;
695 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR ||
estark00e83f12016-08-19 18:24:04696 site_connection_status_ ==
697 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE ||
698 site_connection_status_ ==
699 SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE ||
[email protected]e583f752012-08-30 13:26:21700 site_identity_status_ == SITE_IDENTITY_STATUS_ERROR ||
estark134a9822015-10-29 04:35:18701 site_identity_status_ == SITE_IDENTITY_STATUS_CT_ERROR ||
[email protected]eaf3f322013-04-25 21:53:59702 site_identity_status_ == SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN ||
rsleevi4f8012722014-09-30 01:28:01703 site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT ||
704 site_identity_status_ ==
lgarroncc53de22015-10-05 23:03:17705 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR ||
706 site_identity_status_ ==
707 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR) {
[email protected]e583f752012-08-30 13:26:21708 tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION;
lgarron04a93502014-11-04 22:25:04709 RecordWebsiteSettingsAction(
710 WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY);
711 }
palmer82b1f7b2015-09-17 19:20:41712
[email protected]e583f752012-08-30 13:26:21713 ui_->SetSelectedTab(tab_id);
[email protected]03ef4b2a2012-03-06 15:04:20714}
[email protected]0b9fdd72012-04-04 10:00:33715
[email protected]df818272012-04-20 13:10:50716void WebsiteSettings::PresentSitePermissions() {
717 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38718 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50719
720 WebsiteSettingsUI::PermissionInfo permission_info;
721 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
722 permission_info.type = kPermissionType[i];
723
mgiucaa319f212016-01-14 03:30:11724 if (!ShouldShowPermission(permission_info.type))
725 continue;
726
[email protected]df818272012-04-20 13:10:50727 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32728 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
729 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21730 DCHECK(value.get());
731 if (value->GetType() == base::Value::TYPE_INTEGER) {
732 permission_info.setting =
733 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26734 } else {
sashab2b2a314f2015-01-17 06:42:21735 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26736 }
737
[email protected]8bdf45c32012-08-04 00:12:55738 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28739 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50740
[email protected]b1d113d2012-06-27 21:27:34741 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21742 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34743 permission_info.default_setting = permission_info.setting;
744 permission_info.setting = CONTENT_SETTING_DEFAULT;
745 } else {
746 permission_info.default_setting =
747 content_settings_->GetDefaultContentSetting(permission_info.type,
748 NULL);
[email protected]df818272012-04-20 13:10:50749 }
palmer0da10b32015-02-11 00:42:19750
palmer64a099982016-03-09 21:26:11751 if (permission_info.type == CONTENT_SETTINGS_TYPE_KEYGEN &&
752 (permission_info.setting == CONTENT_SETTING_DEFAULT ||
753 permission_info.setting == permission_info.default_setting) &&
754 !tab_specific_content_settings()->IsContentBlocked(
755 permission_info.type)) {
756 continue;
palmer0da10b32015-02-11 00:42:19757 }
palmer64a099982016-03-09 21:26:11758 permission_info_list.push_back(permission_info);
[email protected]df818272012-04-20 13:10:50759 }
760
reillyg85f57db2016-01-12 23:14:38761 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
762 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10763 const GURL origin = site_url_.GetOrigin();
764 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32765 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38766 chosen_object_info_list.push_back(
767 new WebsiteSettingsUI::ChosenObjectInfo(ui_info, std::move(object)));
768 }
769 }
770
771 ui_->SetPermissionInfo(permission_info_list, chosen_object_info_list);
[email protected]0b9fdd72012-04-04 10:00:33772}
773
[email protected]df818272012-04-20 13:10:50774void WebsiteSettings::PresentSiteData() {
775 CookieInfoList cookie_info_list;
vabrd5e30cd2014-10-02 11:06:03776 const LocalSharedObjectsCounter& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34777 tab_specific_content_settings()->allowed_local_shared_objects();
vabrd5e30cd2014-10-02 11:06:03778 const LocalSharedObjectsCounter& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34779 tab_specific_content_settings()->blocked_local_shared_objects();
780
781 // Add first party cookie and site data counts.
[email protected]df818272012-04-20 13:10:50782 WebsiteSettingsUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34783 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
784 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15785 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34786 cookie_info_list.push_back(cookie_info);
787
788 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34789 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
790 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15791 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50792 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33793
[email protected]df818272012-04-20 13:10:50794 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33795}
[email protected]16de6de2012-04-04 12:24:14796
[email protected]24c8818c2012-04-25 09:57:41797void WebsiteSettings::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04798 // After initialization the status about the site's connection and its
799 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41800 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
801 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
802 WebsiteSettingsUI::IdentityInfo info;
803 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
804 info.site_identity = UTF16ToUTF8(organization_name());
805 else
jshin1fb76462016-04-05 22:13:03806 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41807
808 info.connection_status = site_connection_status_;
809 info.connection_status_description =
810 UTF16ToUTF8(site_connection_details_);
811 info.identity_status = site_identity_status_;
812 info.identity_status_description =
813 UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21814 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04815 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
[email protected]24c8818c2012-04-25 09:57:41816 ui_->SetIdentityInfo(info);
817}