blob: 931eb50df16de12064fb874c99d7b5bcf453b776 [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,
115 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
[email protected]0b9fdd72012-04-04 10:00:33116};
117
mgiucaa319f212016-01-14 03:30:11118// Determines whether to show permission |type| in the Website Settings UI. Only
119// applies to permissions listed in |kPermissionType|.
120bool ShouldShowPermission(ContentSettingsType type) {
mgiuca0f3e1f72016-05-13 01:56:27121 // TODO(mgiuca): When simplified-fullscreen-ui is enabled permanently on
122 // Android, remove these from kPermissionType, rather than having this check
mgiucaa319f212016-01-14 03:30:11123 // (http://crbug.com/577396).
124#if !defined(OS_ANDROID)
mgiuca0f3e1f72016-05-13 01:56:27125 // Fullscreen and mouselock settings are no longer shown (always allow).
mgiucaa319f212016-01-14 03:30:11126 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN ||
127 type == CONTENT_SETTINGS_TYPE_MOUSELOCK) {
mgiuca0f3e1f72016-05-13 01:56:27128 return false;
mgiucaa319f212016-01-14 03:30:11129 }
130#endif
131
132 return true;
133}
134
estark00e83f12016-08-19 18:24:04135void CheckContentStatus(SecurityStateModel::ContentStatus content_status,
136 bool* displayed,
137 bool* ran) {
138 switch (content_status) {
139 case SecurityStateModel::CONTENT_STATUS_DISPLAYED:
140 *displayed = true;
141 break;
142 case SecurityStateModel::CONTENT_STATUS_RAN:
143 *ran = true;
144 break;
145 case SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN:
146 *displayed = true;
147 *ran = true;
148 break;
149 case SecurityStateModel::CONTENT_STATUS_UNKNOWN:
150 case SecurityStateModel::CONTENT_STATUS_NONE:
151 break;
152 }
153}
154
155void CheckForInsecureContent(
156 const SecurityStateModel::SecurityInfo& security_info,
157 bool* displayed,
158 bool* ran) {
159 CheckContentStatus(security_info.mixed_content_status, displayed, ran);
160 // Only consider subresources with certificate errors if the main
161 // resource was loaded over HTTPS without major certificate errors. If
162 // the main resource had a certificate error, then it would not be
163 // that useful (and would potentially be confusing) to warn about
164 // subesources that had certificate errors too.
165 if (net::IsCertStatusError(security_info.cert_status) &&
166 !net::IsCertStatusMinorError(security_info.cert_status)) {
167 return;
168 }
169 CheckContentStatus(security_info.content_with_cert_errors_status, displayed,
170 ran);
171}
172
estark134a9822015-10-29 04:35:18173// Returns true if any of the given statuses match |status|.
174bool CertificateTransparencyStatusMatchAny(
estarka3121f6b2015-09-18 21:15:59175 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49176 net::ct::SCTVerifyStatus status) {
estarka3121f6b2015-09-18 21:15:59177 for (const auto& verify_status : sct_verify_statuses) {
178 if (verify_status == status)
[email protected]94c74b42013-12-02 15:19:49179 return true;
180 }
[email protected]94c74b42013-12-02 15:19:49181 return false;
182}
183
184int GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59185 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49186 bool is_ev) {
187 // No SCTs - no CT information.
estarka3121f6b2015-09-18 21:15:59188 if (sct_verify_statuses.empty())
[email protected]94c74b42013-12-02 15:19:49189 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_NO_CT
190 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_NO_CT);
191
estark134a9822015-10-29 04:35:18192 // Any valid SCT.
193 if (CertificateTransparencyStatusMatchAny(sct_verify_statuses,
194 net::ct::SCT_STATUS_OK))
[email protected]94c74b42013-12-02 15:19:49195 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_VERIFIED
196 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_VERIFIED);
197
estark134a9822015-10-29 04:35:18198 // Any invalid SCT.
estark321ed2a52016-08-25 02:58:04199 if (CertificateTransparencyStatusMatchAny(sct_verify_statuses,
200 net::ct::SCT_STATUS_INVALID) ||
201 CertificateTransparencyStatusMatchAny(
eranm194b45d2016-08-18 10:00:33202 sct_verify_statuses, net::ct::SCT_STATUS_INVALID_TIMESTAMP) ||
203 CertificateTransparencyStatusMatchAny(
204 sct_verify_statuses, net::ct::SCT_STATUS_INVALID_SIGNATURE))
[email protected]94c74b42013-12-02 15:19:49205 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_INVALID
206 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_INVALID);
207
estark134a9822015-10-29 04:35:18208 // All SCTs are from unknown logs.
[email protected]94c74b42013-12-02 15:19:49209 return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_UNVERIFIED
210 : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_UNVERIFIED);
211}
212
213// This function will return SITE_IDENTITY_STATUS_CERT or
estark134a9822015-10-29 04:35:18214// SITE_IDENTITY_STATUS_EV_CERT depending on |is_ev| unless all SCTs
215// failed verification, in which case it will return
[email protected]94c74b42013-12-02 15:19:49216// SITE_IDENTITY_STATUS_ERROR.
217WebsiteSettings::SiteIdentityStatus GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59218 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses,
[email protected]94c74b42013-12-02 15:19:49219 bool is_ev) {
estark134a9822015-10-29 04:35:18220 if (sct_verify_statuses.empty() ||
221 CertificateTransparencyStatusMatchAny(sct_verify_statuses,
222 net::ct::SCT_STATUS_OK))
223 return is_ev ? WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT
224 : WebsiteSettings::SITE_IDENTITY_STATUS_CERT;
[email protected]94c74b42013-12-02 15:19:49225
estark134a9822015-10-29 04:35:18226 return WebsiteSettings::SITE_IDENTITY_STATUS_CT_ERROR;
[email protected]94c74b42013-12-02 15:19:49227}
228
jshin1fb76462016-04-05 22:13:03229base::string16 GetSimpleSiteName(const GURL& url) {
benwells2337b8102016-04-20 01:53:53230 return url_formatter::FormatUrlForSecurityDisplay(
231 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
palmer153af982015-09-15 02:04:19232}
233
reillyg85f57db2016-01-12 23:14:38234ChooserContextBase* GetUsbChooserContext(Profile* profile) {
235 return UsbChooserContextFactory::GetForProfile(profile);
236}
237
238// The list of chooser types that need to display entries in the Website
239// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
240// email [email protected].
241WebsiteSettings::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52242 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
243 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_WEBSITE_SETTINGS_USB_DEVICE_LABEL,
reillyg85f57db2016-01-12 23:14:38244 IDS_WEBSITE_SETTINGS_DELETE_USB_DEVICE, "name"},
245};
246
[email protected]0b9fdd72012-04-04 10:00:33247} // namespace
248
249WebsiteSettings::WebsiteSettings(
250 WebsiteSettingsUI* ui,
251 Profile* profile,
[email protected]df818272012-04-20 13:10:50252 TabSpecificContentSettings* tab_specific_content_settings,
palmerf2cba0d2015-08-27 23:15:06253 content::WebContents* web_contents,
[email protected]0b9fdd72012-04-04 10:00:33254 const GURL& url,
jam8ae7cad2016-09-08 23:55:21255 const SecurityStateModel::SecurityInfo& security_info)
[email protected]df818272012-04-20 13:10:50256 : TabSpecificContentSettings::SiteDataObserver(
257 tab_specific_content_settings),
258 ui_(ui),
pkastingacd1e122016-05-19 23:55:10259#if !defined(OS_ANDROID)
palmerf2cba0d2015-08-27 23:15:06260 web_contents_(web_contents),
pkastingacd1e122016-05-19 23:55:10261#endif
[email protected]66f157312012-08-01 13:50:26262 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33263 site_url_(url),
264 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]03ef4b2a2012-03-06 15:04:20265 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
peconn5100d432015-09-16 12:03:08266 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04267 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25268 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19269 did_revoke_user_ssl_decisions_(false),
270 profile_(profile) {
estarka3121f6b2015-09-18 21:15:59271 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33272
273 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50274 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41275 PresentSiteIdentity();
[email protected]e22d64f2012-09-10 09:03:23276
277 // Every time the Website Settings UI is opened a |WebsiteSettings| object is
278 // created. So this counts how ofter the Website Settings UI is opened.
lgarron04a93502014-11-04 22:25:04279 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20280}
281
[email protected]0b9fdd72012-04-04 10:00:33282WebsiteSettings::~WebsiteSettings() {
[email protected]03ef4b2a2012-03-06 15:04:20283}
284
lgarron04a93502014-11-04 22:25:04285void WebsiteSettings::RecordWebsiteSettingsAction(
286 WebsiteSettingsAction action) {
287 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action",
288 action,
289 WEBSITE_SETTINGS_COUNT);
290
291 // Use a separate histogram to record actions if they are done on a page with
292 // an HTTPS URL. Note that this *disregards* security status.
palmeree0e5af2015-06-05 03:10:40293 //
294
295 // TODO(palmer): Consider adding a new histogram for
296 // GURL::SchemeIsCryptographic. (We don't want to replace this call with a
297 // call to that function because we don't want to change the meanings of
298 // existing metrics.) This would inform the decision to mark non-secure
299 // origins as Dubious or Non-Secure; the overall bug for that is
300 // crbug.com/454579.
lgarron04a93502014-11-04 22:25:04301 if (site_url_.SchemeIs(url::kHttpsScheme)) {
302 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action.HttpsUrl",
303 action,
304 WEBSITE_SETTINGS_COUNT);
305 }
306}
307
[email protected]df818272012-04-20 13:10:50308void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type,
309 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23310 // Count how often a permission for a specific content type is changed using
311 // the Website Settings UI.
raymes4a13d432015-09-08 00:44:07312 size_t num_values;
313 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
sashab9debecd2014-12-18 04:15:56314 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.OriginInfo.PermissionChanged",
raymes4a13d432015-09-08 00:44:07315 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56316
317 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
318 UMA_HISTOGRAM_ENUMERATION(
319 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07320 num_values);
tommycli34cf29bf2016-09-08 05:46:25321
322 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
323 rappor::SampleDomainAndRegistryFromGURL(
324 g_browser_process->rappor_service(),
325 "ContentSettings.Plugins.AddedAllowException", site_url_);
326 }
sashab9debecd2014-12-18 04:15:56327 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
328 UMA_HISTOGRAM_ENUMERATION(
329 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07330 num_values);
sashab9debecd2014-12-18 04:15:56331 }
[email protected]e22d64f2012-09-10 09:03:23332
lgarron04a93502014-11-04 22:25:04333 // This is technically redundant given the histogram above, but putting the
334 // total count of permission changes in another histogram makes it easier to
335 // compare it against other kinds of actions in WebsiteSettings[PopupView].
336 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_CHANGED_PERMISSION);
337
stefanocs8b3490cc2016-07-28 05:32:52338 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
339 this->profile_, this->site_url_, this->site_url_, type,
340 PermissionSourceUI::OIB);
341
raymesfbaaaaa2015-11-10 02:20:40342 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
343 setting);
[email protected]df818272012-04-20 13:10:50344
[email protected]66f157312012-08-01 13:50:26345 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24346
[email protected]2f45d542012-08-22 08:47:24347 // Refresh the UI to reflect the new setting.
348 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50349}
350
reillyg85f57db2016-01-12 23:14:38351void WebsiteSettings::OnSiteChosenObjectDeleted(
352 const ChooserUIInfo& ui_info,
353 const base::DictionaryValue& object) {
354 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
355 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10356 const GURL origin = site_url_.GetOrigin();
357 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38358
359 show_info_bar_ = true;
360
361 // Refresh the UI to reflect the changed settings.
362 PresentSitePermissions();
363}
364
[email protected]df818272012-04-20 13:10:50365void WebsiteSettings::OnSiteDataAccessed() {
366 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33367}
368
[email protected]66f157312012-08-01 13:50:26369void WebsiteSettings::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49370#if defined(OS_ANDROID)
371 NOTREACHED();
372#else
palmerf2cba0d2015-08-27 23:15:06373 if (show_info_bar_ && web_contents_) {
374 InfoBarService* infobar_service =
375 InfoBarService::FromWebContents(web_contents_);
376 if (infobar_service)
377 WebsiteSettingsInfoBarDelegate::Create(infobar_service);
378 }
jww1ed8ea72014-09-02 20:43:25379
380 SSLCertificateDecisionsDidRevoke user_decision =
381 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
382 : USER_CERT_DECISIONS_NOT_REVOKED;
383
384 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
385 user_decision,
386 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49387#endif
jww1ed8ea72014-09-02 20:43:25388}
389
390void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() {
391 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29392 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
393 site_url().host());
jww1ed8ea72014-09-02 20:43:25394 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26395}
396
estarka3121f6b2015-09-18 21:15:59397void WebsiteSettings::Init(
398 const GURL& url,
399 const SecurityStateModel::SecurityInfo& security_info) {
sashab97894ce2014-10-22 10:08:33400 bool isChromeUINativeScheme = false;
sievers2f1e8112015-12-04 18:43:56401#if BUILDFLAG(ANDROID_JAVA_UI)
sashab97894ce2014-10-22 10:08:33402 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
403#endif
404
upendrag.gowda60886a6e2015-10-31 05:51:09405 if (url.SchemeIs(url::kAboutScheme)) {
406 // All about: URLs except about:blank are redirected.
407 DCHECK_EQ(url::kAboutBlankURL, url.spec());
408 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
409 site_identity_details_ =
410 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
411 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
412 site_connection_details_ = l10n_util::GetStringFUTF16(
413 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
414 UTF8ToUTF16(url.spec()));
415 return;
416 }
417
418 if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) {
[email protected]03ef4b2a2012-03-06 15:04:20419 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
420 site_identity_details_ =
421 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
422 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
423 return;
424 }
425
[email protected]03ef4b2a2012-03-06 15:04:20426 // Identity section.
jam8ae7cad2016-09-08 23:55:21427 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11428
estarka3121f6b2015-09-18 21:15:59429 // HTTPS with no or minor errors.
jam8ae7cad2016-09-08 23:55:21430 if (certificate_ &&
estarka3121f6b2015-09-18 21:15:59431 (!net::IsCertStatusError(security_info.cert_status) ||
432 net::IsCertStatusMinorError(security_info.cert_status))) {
[email protected]03ef4b2a2012-03-06 15:04:20433 // There are no major errors. Check for minor errors.
estarka3121f6b2015-09-18 21:15:59434 if (security_info.security_level ==
435 SecurityStateModel::SECURITY_POLICY_WARNING) {
[email protected]eaf3f322013-04-25 21:53:59436 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37437 site_identity_details_ = l10n_util::GetStringFUTF16(
438 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59439 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20440 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21441 base::string16 issuer_name(
442 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20443 if (issuer_name.empty()) {
444 issuer_name.assign(l10n_util::GetStringUTF16(
445 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
446 }
[email protected]94c74b42013-12-02 15:19:49447
[email protected]03ef4b2a2012-03-06 15:04:20448 site_identity_details_.assign(l10n_util::GetStringFUTF16(
[email protected]94c74b42013-12-02 15:19:49449 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59450 security_info.sct_verify_statuses, false /* not EV */),
[email protected]94c74b42013-12-02 15:19:49451 issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20452
453 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59454 if (security_info.cert_status &
455 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20456 site_identity_details_ += l10n_util::GetStringUTF16(
457 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59458 } else if (security_info.cert_status &
459 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20460 site_identity_details_ += l10n_util::GetStringUTF16(
461 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
462 } else {
463 NOTREACHED() << "Need to specify string for this warning";
464 }
[email protected]03ef4b2a2012-03-06 15:04:20465 } else {
estarka3121f6b2015-09-18 21:15:59466 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01467 // EV HTTPS page.
468 site_identity_status_ = GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59469 security_info.sct_verify_statuses, true);
jam8ae7cad2016-09-08 23:55:21470 DCHECK(!certificate_->subject().organization_names.empty());
471 organization_name_ =
472 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01473 // An EV Cert is required to have a city (localityName) and country but
474 // state is "if any".
jam8ae7cad2016-09-08 23:55:21475 DCHECK(!certificate_->subject().locality_name.empty());
476 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01477 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21478 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01479 locality = l10n_util::GetStringFUTF16(
480 IDS_PAGEINFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21481 UTF8ToUTF16(certificate_->subject().locality_name),
482 UTF8ToUTF16(certificate_->subject().state_or_province_name),
483 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01484 } else {
485 locality = l10n_util::GetStringFUTF16(
486 IDS_PAGEINFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21487 UTF8ToUTF16(certificate_->subject().locality_name),
488 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01489 }
jam8ae7cad2016-09-08 23:55:21490 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01491 site_identity_details_.assign(l10n_util::GetStringFUTF16(
492 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59493 security_info.sct_verify_statuses, true /* is EV */),
jam8ae7cad2016-09-08 23:55:21494 UTF8ToUTF16(certificate_->subject().organization_names[0]),
495 locality,
496 UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01497 } else {
498 // Non-EV OK HTTPS page.
499 site_identity_status_ = GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59500 security_info.sct_verify_statuses, false);
rsleevi4f8012722014-09-30 01:28:01501 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21502 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01503 if (issuer_name.empty()) {
504 issuer_name.assign(l10n_util::GetStringUTF16(
505 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
506 }
[email protected]94c74b42013-12-02 15:19:49507
rsleevi4f8012722014-09-30 01:28:01508 site_identity_details_.assign(l10n_util::GetStringFUTF16(
509 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59510 security_info.sct_verify_statuses, false /* not EV */),
rsleevi4f8012722014-09-30 01:28:01511 issuer_name));
512 }
lgarroncc53de22015-10-05 23:03:17513 switch (security_info.sha1_deprecation_status) {
514 case SecurityStateModel::DEPRECATED_SHA1_MINOR:
515 site_identity_status_ =
516 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR;
517 site_identity_details_ +=
518 UTF8ToUTF16("\n\n") +
519 l10n_util::GetStringUTF16(
520 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MINOR);
521 break;
522 case SecurityStateModel::DEPRECATED_SHA1_MAJOR:
523 site_identity_status_ =
524 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR;
525 site_identity_details_ +=
526 UTF8ToUTF16("\n\n") +
527 l10n_util::GetStringUTF16(
528 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR);
529 break;
530 case SecurityStateModel::NO_DEPRECATED_SHA1:
531 // Nothing to do.
532 break;
felt61638452016-08-09 22:21:55533 case SecurityStateModel::UNKNOWN_SHA1:
534 // UNKNOWN_SHA1 should only appear when certificate info has not been
535 // initialized, in which case this if-statement should not be running
536 // because there is no other cert info.
537 NOTREACHED();
rsleevi4f8012722014-09-30 01:28:01538 }
[email protected]03ef4b2a2012-03-06 15:04:20539 }
540 } else {
541 // HTTP or HTTPS with errors (not warnings).
542 site_identity_details_.assign(l10n_util::GetStringUTF16(
543 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
jam8ae7cad2016-09-08 23:55:21544 if (!security_info.scheme_is_cryptographic || !security_info.certificate)
[email protected]03ef4b2a2012-03-06 15:04:20545 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
546 else
547 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
548
[email protected]a04db822013-12-11 19:14:40549 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59550 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59551 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
jam8ae7cad2016-09-08 23:55:21552 certificate_, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20553 for (size_t i = 0; i < errors.size(); ++i) {
554 site_identity_details_ += bullet;
555 site_identity_details_ += errors[i].short_description();
556 }
557
estarka3121f6b2015-09-18 21:15:59558 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20559 site_identity_details_ += ASCIIToUTF16("\n\n");
560 site_identity_details_ += l10n_util::GetStringUTF16(
561 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
562 }
563 }
564
565 // Site Connection
566 // We consider anything less than 80 bits encryption to be weak encryption.
567 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
568 // weakly encrypted connections.
569 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
570
jshin1fb76462016-04-05 22:13:03571 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19572 if (subject_name.empty()) {
573 subject_name.assign(
574 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
575 }
576
jam8ae7cad2016-09-08 23:55:21577 if (!security_info.certificate || !security_info.scheme_is_cryptographic) {
estarka3121f6b2015-09-18 21:15:59578 // Page is still loading (so SSL status is not yet available) or
579 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58580 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
581
582 site_connection_details_.assign(l10n_util::GetStringFUTF16(
583 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
584 subject_name));
estarka3121f6b2015-09-18 21:15:59585 } else if (security_info.security_bits < 0) {
586 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20587 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59588 } else if (security_info.security_bits == 0) {
589 DCHECK_NE(security_info.security_level, SecurityStateModel::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20590 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
591 site_connection_details_.assign(l10n_util::GetStringFUTF16(
592 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
593 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20594 } else {
595 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22596
lgarron3e2c33e2016-08-25 06:33:43597 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22598 site_connection_details_.assign(l10n_util::GetStringFUTF16(
599 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
600 subject_name));
601 } else {
602 site_connection_details_.assign(l10n_util::GetStringFUTF16(
603 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
604 subject_name));
605 }
606
estark00e83f12016-08-19 18:24:04607 bool ran_insecure_content = false;
608 bool displayed_insecure_content = false;
609 CheckForInsecureContent(security_info, &displayed_insecure_content,
610 &ran_insecure_content);
611 if (ran_insecure_content || displayed_insecure_content) {
612 site_connection_status_ =
613 ran_insecure_content
614 ? SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE
615 : SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
[email protected]03ef4b2a2012-03-06 15:04:20616 site_connection_details_.assign(l10n_util::GetStringFUTF16(
617 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
618 site_connection_details_,
estark00e83f12016-08-19 18:24:04619 l10n_util::GetStringUTF16(
620 ran_insecure_content
621 ? IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR
622 : IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
[email protected]03ef4b2a2012-03-06 15:04:20623 }
624 }
625
avi655876a2015-12-25 07:18:15626 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59627 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
628 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20629 int ssl_version =
estarka3121f6b2015-09-18 21:15:59630 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20631 const char* ssl_version_str;
632 net::SSLVersionToString(&ssl_version_str, ssl_version);
633 site_connection_details_ += ASCIIToUTF16("\n\n");
634 site_connection_details_ += l10n_util::GetStringFUTF16(
635 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION,
636 ASCIIToUTF16(ssl_version_str));
637
[email protected]03ef4b2a2012-03-06 15:04:20638 bool no_renegotiation =
estarka3121f6b2015-09-18 21:15:59639 (security_info.connection_status &
640 net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20641 const char *key_exchange, *cipher, *mac;
[email protected]b6c1d9e82013-06-12 17:26:57642 bool is_aead;
643 net::SSLCipherSuiteToStrings(
644 &key_exchange, &cipher, &mac, &is_aead, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20645
646 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57647 if (is_aead) {
648 site_connection_details_ += l10n_util::GetStringFUTF16(
649 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
650 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
651 } else {
652 site_connection_details_ += l10n_util::GetStringFUTF16(
653 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS,
654 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
655 }
[email protected]03ef4b2a2012-03-06 15:04:20656
agl078d2102014-10-20 22:03:22657 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 &&
estark00e83f12016-08-19 18:24:04658 site_connection_status_ <
659 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE) {
agl078d2102014-10-20 22:03:22660 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
661 }
662
estarka3121f6b2015-09-18 21:15:59663 const bool did_fallback = (security_info.connection_status &
664 net::SSL_CONNECTION_VERSION_FALLBACK) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20665 if (did_fallback) {
[email protected]03ef4b2a2012-03-06 15:04:20666 site_connection_details_ += ASCIIToUTF16("\n\n");
667 site_connection_details_ += l10n_util::GetStringUTF16(
668 IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE);
669 }
agl078d2102014-10-20 22:03:22670
[email protected]03ef4b2a2012-03-06 15:04:20671 if (no_renegotiation) {
672 site_connection_details_ += ASCIIToUTF16("\n\n");
673 site_connection_details_ += l10n_util::GetStringUTF16(
674 IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE);
675 }
676 }
[email protected]e583f752012-08-30 13:26:21677
[email protected]71cd5ef2014-08-13 21:22:04678 // Check if a user decision has been made to allow or deny certificates with
679 // errors on this site.
680 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50681 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04682 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40683 // Only show an SSL decision revoke button if the user has chosen to bypass
684 // SSL host errors for this host in the past.
685 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]71cd5ef2014-08-13 21:22:04686
palmer82b1f7b2015-09-17 19:20:41687 // By default select the Permissions Tab that displays all the site
688 // permissions. In case of a connection error or an issue with the certificate
689 // presented by the website, select the Connection Tab to draw the user's
690 // attention to the issue. If the site does not provide a certificate because
691 // it was loaded over an unencrypted connection, don't select the Connection
692 // Tab.
[email protected]e583f752012-08-30 13:26:21693 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS;
694 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR ||
estark00e83f12016-08-19 18:24:04695 site_connection_status_ ==
696 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE ||
697 site_connection_status_ ==
698 SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE ||
[email protected]e583f752012-08-30 13:26:21699 site_identity_status_ == SITE_IDENTITY_STATUS_ERROR ||
estark134a9822015-10-29 04:35:18700 site_identity_status_ == SITE_IDENTITY_STATUS_CT_ERROR ||
[email protected]eaf3f322013-04-25 21:53:59701 site_identity_status_ == SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN ||
rsleevi4f8012722014-09-30 01:28:01702 site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT ||
703 site_identity_status_ ==
lgarroncc53de22015-10-05 23:03:17704 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR ||
705 site_identity_status_ ==
706 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR) {
[email protected]e583f752012-08-30 13:26:21707 tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION;
lgarron04a93502014-11-04 22:25:04708 RecordWebsiteSettingsAction(
709 WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY);
710 }
palmer82b1f7b2015-09-17 19:20:41711
[email protected]e583f752012-08-30 13:26:21712 ui_->SetSelectedTab(tab_id);
[email protected]03ef4b2a2012-03-06 15:04:20713}
[email protected]0b9fdd72012-04-04 10:00:33714
[email protected]df818272012-04-20 13:10:50715void WebsiteSettings::PresentSitePermissions() {
716 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38717 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50718
719 WebsiteSettingsUI::PermissionInfo permission_info;
720 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
721 permission_info.type = kPermissionType[i];
722
mgiucaa319f212016-01-14 03:30:11723 if (!ShouldShowPermission(permission_info.type))
724 continue;
725
[email protected]df818272012-04-20 13:10:50726 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32727 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
728 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21729 DCHECK(value.get());
730 if (value->GetType() == base::Value::TYPE_INTEGER) {
731 permission_info.setting =
732 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26733 } else {
sashab2b2a314f2015-01-17 06:42:21734 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26735 }
736
[email protected]8bdf45c32012-08-04 00:12:55737 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28738 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50739
[email protected]b1d113d2012-06-27 21:27:34740 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21741 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34742 permission_info.default_setting = permission_info.setting;
743 permission_info.setting = CONTENT_SETTING_DEFAULT;
744 } else {
745 permission_info.default_setting =
746 content_settings_->GetDefaultContentSetting(permission_info.type,
747 NULL);
[email protected]df818272012-04-20 13:10:50748 }
palmer0da10b32015-02-11 00:42:19749
palmer64a099982016-03-09 21:26:11750 if (permission_info.type == CONTENT_SETTINGS_TYPE_KEYGEN &&
751 (permission_info.setting == CONTENT_SETTING_DEFAULT ||
752 permission_info.setting == permission_info.default_setting) &&
753 !tab_specific_content_settings()->IsContentBlocked(
754 permission_info.type)) {
755 continue;
palmer0da10b32015-02-11 00:42:19756 }
palmer64a099982016-03-09 21:26:11757 permission_info_list.push_back(permission_info);
[email protected]df818272012-04-20 13:10:50758 }
759
reillyg85f57db2016-01-12 23:14:38760 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
761 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10762 const GURL origin = site_url_.GetOrigin();
763 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32764 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38765 chosen_object_info_list.push_back(
766 new WebsiteSettingsUI::ChosenObjectInfo(ui_info, std::move(object)));
767 }
768 }
769
770 ui_->SetPermissionInfo(permission_info_list, chosen_object_info_list);
[email protected]0b9fdd72012-04-04 10:00:33771}
772
[email protected]df818272012-04-20 13:10:50773void WebsiteSettings::PresentSiteData() {
774 CookieInfoList cookie_info_list;
vabrd5e30cd2014-10-02 11:06:03775 const LocalSharedObjectsCounter& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34776 tab_specific_content_settings()->allowed_local_shared_objects();
vabrd5e30cd2014-10-02 11:06:03777 const LocalSharedObjectsCounter& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34778 tab_specific_content_settings()->blocked_local_shared_objects();
779
780 // Add first party cookie and site data counts.
[email protected]df818272012-04-20 13:10:50781 WebsiteSettingsUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34782 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
783 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15784 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34785 cookie_info_list.push_back(cookie_info);
786
787 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34788 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
789 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15790 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50791 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33792
[email protected]df818272012-04-20 13:10:50793 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33794}
[email protected]16de6de2012-04-04 12:24:14795
[email protected]24c8818c2012-04-25 09:57:41796void WebsiteSettings::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04797 // After initialization the status about the site's connection and its
798 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41799 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
800 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
801 WebsiteSettingsUI::IdentityInfo info;
802 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
803 info.site_identity = UTF16ToUTF8(organization_name());
804 else
jshin1fb76462016-04-05 22:13:03805 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41806
807 info.connection_status = site_connection_status_;
808 info.connection_status_description =
809 UTF16ToUTF8(site_connection_details_);
810 info.identity_status = site_identity_status_;
811 info.identity_status_description =
812 UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21813 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04814 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
[email protected]24c8818c2012-04-25 09:57:41815 ui_->SetIdentityInfo(info);
816}