blob: 482ad08165ba204832d6a2737c5bd8c10063ca40 [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"
vabrbab3ffcb2016-10-04 10:08:1031#include "chrome/browser/content_settings/local_shared_objects_container.h"
[email protected]77a91c72012-08-13 16:19:3432#include "chrome/browser/history/history_service_factory.h"
palmerf2cba0d2015-08-27 23:15:0633#include "chrome/browser/infobars/infobar_service.h"
reillyg85f57db2016-01-12 23:14:3834#include "chrome/browser/permissions/chooser_context_base.h"
tsergeantf1e89352016-01-15 20:34:5435#include "chrome/browser/permissions/permission_uma_util.h"
36#include "chrome/browser/permissions/permission_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2037#include "chrome/browser/profiles/profile.h"
[email protected]71cd5ef2014-08-13 21:22:0438#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
39#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
[email protected]4237dd52012-06-05 00:00:3240#include "chrome/browser/ui/website_settings/website_settings_ui.h"
reillyg85f57db2016-01-12 23:14:3841#include "chrome/browser/usb/usb_chooser_context.h"
42#include "chrome/browser/usb/usb_chooser_context_factory.h"
[email protected]71cd5ef2014-08-13 21:22:0443#include "chrome/common/chrome_switches.h"
sievers2f1e8112015-12-04 18:43:5644#include "chrome/common/features.h"
jsbellddb849e2015-08-27 00:12:5645#include "chrome/common/url_constants.h"
thestig884a1602014-08-27 01:29:3946#include "chrome/grit/chromium_strings.h"
47#include "chrome/grit/generated_resources.h"
reillyg85f57db2016-01-12 23:14:3848#include "chrome/grit/theme_resources.h"
mukai8eaec822014-10-25 17:53:1649#include "components/content_settings/core/browser/content_settings_utils.h"
50#include "components/content_settings/core/browser/host_content_settings_map.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),
dominicknbdd53b5f2016-09-28 01:08:13259 content::WebContentsObserver(web_contents),
[email protected]df818272012-04-20 13:10:50260 ui_(ui),
[email protected]66f157312012-08-01 13:50:26261 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33262 site_url_(url),
263 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]03ef4b2a2012-03-06 15:04:20264 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
peconn5100d432015-09-16 12:03:08265 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04266 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25267 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19268 did_revoke_user_ssl_decisions_(false),
269 profile_(profile) {
estarka3121f6b2015-09-18 21:15:59270 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33271
272 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50273 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41274 PresentSiteIdentity();
[email protected]e22d64f2012-09-10 09:03:23275
276 // Every time the Website Settings UI is opened a |WebsiteSettings| object is
277 // created. So this counts how ofter the Website Settings UI is opened.
lgarron04a93502014-11-04 22:25:04278 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20279}
280
[email protected]0b9fdd72012-04-04 10:00:33281WebsiteSettings::~WebsiteSettings() {
[email protected]03ef4b2a2012-03-06 15:04:20282}
283
lgarron04a93502014-11-04 22:25:04284void WebsiteSettings::RecordWebsiteSettingsAction(
285 WebsiteSettingsAction action) {
286 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action",
287 action,
288 WEBSITE_SETTINGS_COUNT);
289
290 // Use a separate histogram to record actions if they are done on a page with
291 // an HTTPS URL. Note that this *disregards* security status.
palmeree0e5af2015-06-05 03:10:40292 //
293
294 // TODO(palmer): Consider adding a new histogram for
295 // GURL::SchemeIsCryptographic. (We don't want to replace this call with a
296 // call to that function because we don't want to change the meanings of
297 // existing metrics.) This would inform the decision to mark non-secure
298 // origins as Dubious or Non-Secure; the overall bug for that is
299 // crbug.com/454579.
lgarron04a93502014-11-04 22:25:04300 if (site_url_.SchemeIs(url::kHttpsScheme)) {
301 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action.HttpsUrl",
302 action,
303 WEBSITE_SETTINGS_COUNT);
304 }
305}
306
[email protected]df818272012-04-20 13:10:50307void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type,
308 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23309 // Count how often a permission for a specific content type is changed using
310 // the Website Settings UI.
raymes4a13d432015-09-08 00:44:07311 size_t num_values;
312 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
sashab9debecd2014-12-18 04:15:56313 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.OriginInfo.PermissionChanged",
raymes4a13d432015-09-08 00:44:07314 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56315
316 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
317 UMA_HISTOGRAM_ENUMERATION(
318 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07319 num_values);
tommycli34cf29bf2016-09-08 05:46:25320
321 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
322 rappor::SampleDomainAndRegistryFromGURL(
323 g_browser_process->rappor_service(),
324 "ContentSettings.Plugins.AddedAllowException", site_url_);
325 }
sashab9debecd2014-12-18 04:15:56326 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
327 UMA_HISTOGRAM_ENUMERATION(
328 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07329 num_values);
sashab9debecd2014-12-18 04:15:56330 }
[email protected]e22d64f2012-09-10 09:03:23331
lgarron04a93502014-11-04 22:25:04332 // This is technically redundant given the histogram above, but putting the
333 // total count of permission changes in another histogram makes it easier to
334 // compare it against other kinds of actions in WebsiteSettings[PopupView].
335 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_CHANGED_PERMISSION);
336
stefanocs8b3490cc2016-07-28 05:32:52337 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
338 this->profile_, this->site_url_, this->site_url_, type,
339 PermissionSourceUI::OIB);
340
raymesfbaaaaa2015-11-10 02:20:40341 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
342 setting);
[email protected]df818272012-04-20 13:10:50343
[email protected]66f157312012-08-01 13:50:26344 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24345
[email protected]2f45d542012-08-22 08:47:24346 // Refresh the UI to reflect the new setting.
347 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50348}
349
reillyg85f57db2016-01-12 23:14:38350void WebsiteSettings::OnSiteChosenObjectDeleted(
351 const ChooserUIInfo& ui_info,
352 const base::DictionaryValue& object) {
353 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
354 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10355 const GURL origin = site_url_.GetOrigin();
356 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38357
358 show_info_bar_ = true;
359
360 // Refresh the UI to reflect the changed settings.
361 PresentSitePermissions();
362}
363
[email protected]df818272012-04-20 13:10:50364void WebsiteSettings::OnSiteDataAccessed() {
365 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33366}
367
[email protected]66f157312012-08-01 13:50:26368void WebsiteSettings::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49369#if defined(OS_ANDROID)
370 NOTREACHED();
371#else
dominicknbdd53b5f2016-09-28 01:08:13372 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
palmerf2cba0d2015-08-27 23:15:06373 InfoBarService* infobar_service =
dominicknbdd53b5f2016-09-28 01:08:13374 InfoBarService::FromWebContents(web_contents());
palmerf2cba0d2015-08-27 23:15:06375 if (infobar_service)
376 WebsiteSettingsInfoBarDelegate::Create(infobar_service);
377 }
jww1ed8ea72014-09-02 20:43:25378
379 SSLCertificateDecisionsDidRevoke user_decision =
380 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
381 : USER_CERT_DECISIONS_NOT_REVOKED;
382
383 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
384 user_decision,
385 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49386#endif
jww1ed8ea72014-09-02 20:43:25387}
388
389void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() {
390 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29391 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
392 site_url().host());
jww1ed8ea72014-09-02 20:43:25393 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26394}
395
estarka3121f6b2015-09-18 21:15:59396void WebsiteSettings::Init(
397 const GURL& url,
398 const SecurityStateModel::SecurityInfo& security_info) {
sashab97894ce2014-10-22 10:08:33399 bool isChromeUINativeScheme = false;
sievers2f1e8112015-12-04 18:43:56400#if BUILDFLAG(ANDROID_JAVA_UI)
sashab97894ce2014-10-22 10:08:33401 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
402#endif
403
upendrag.gowda60886a6e2015-10-31 05:51:09404 if (url.SchemeIs(url::kAboutScheme)) {
405 // All about: URLs except about:blank are redirected.
406 DCHECK_EQ(url::kAboutBlankURL, url.spec());
407 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
408 site_identity_details_ =
409 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
410 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
411 site_connection_details_ = l10n_util::GetStringFUTF16(
412 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
413 UTF8ToUTF16(url.spec()));
414 return;
415 }
416
417 if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) {
[email protected]03ef4b2a2012-03-06 15:04:20418 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
419 site_identity_details_ =
420 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
421 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
422 return;
423 }
424
[email protected]03ef4b2a2012-03-06 15:04:20425 // Identity section.
jam8ae7cad2016-09-08 23:55:21426 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11427
estarka3121f6b2015-09-18 21:15:59428 // HTTPS with no or minor errors.
jam8ae7cad2016-09-08 23:55:21429 if (certificate_ &&
estarka3121f6b2015-09-18 21:15:59430 (!net::IsCertStatusError(security_info.cert_status) ||
431 net::IsCertStatusMinorError(security_info.cert_status))) {
[email protected]03ef4b2a2012-03-06 15:04:20432 // There are no major errors. Check for minor errors.
estarka3121f6b2015-09-18 21:15:59433 if (security_info.security_level ==
felt89f3f212016-09-27 00:20:30434 SecurityStateModel::SECURE_WITH_POLICY_INSTALLED_CERT) {
[email protected]eaf3f322013-04-25 21:53:59435 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37436 site_identity_details_ = l10n_util::GetStringFUTF16(
437 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59438 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20439 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21440 base::string16 issuer_name(
441 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20442 if (issuer_name.empty()) {
443 issuer_name.assign(l10n_util::GetStringUTF16(
444 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
445 }
[email protected]94c74b42013-12-02 15:19:49446
[email protected]03ef4b2a2012-03-06 15:04:20447 site_identity_details_.assign(l10n_util::GetStringFUTF16(
[email protected]94c74b42013-12-02 15:19:49448 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59449 security_info.sct_verify_statuses, false /* not EV */),
[email protected]94c74b42013-12-02 15:19:49450 issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20451
452 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59453 if (security_info.cert_status &
454 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20455 site_identity_details_ += l10n_util::GetStringUTF16(
456 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59457 } else if (security_info.cert_status &
458 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20459 site_identity_details_ += l10n_util::GetStringUTF16(
460 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
461 } else {
462 NOTREACHED() << "Need to specify string for this warning";
463 }
[email protected]03ef4b2a2012-03-06 15:04:20464 } else {
estarka3121f6b2015-09-18 21:15:59465 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01466 // EV HTTPS page.
467 site_identity_status_ = GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59468 security_info.sct_verify_statuses, true);
jam8ae7cad2016-09-08 23:55:21469 DCHECK(!certificate_->subject().organization_names.empty());
470 organization_name_ =
471 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01472 // An EV Cert is required to have a city (localityName) and country but
473 // state is "if any".
jam8ae7cad2016-09-08 23:55:21474 DCHECK(!certificate_->subject().locality_name.empty());
475 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01476 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21477 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01478 locality = l10n_util::GetStringFUTF16(
479 IDS_PAGEINFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21480 UTF8ToUTF16(certificate_->subject().locality_name),
481 UTF8ToUTF16(certificate_->subject().state_or_province_name),
482 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01483 } else {
484 locality = l10n_util::GetStringFUTF16(
485 IDS_PAGEINFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21486 UTF8ToUTF16(certificate_->subject().locality_name),
487 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01488 }
jam8ae7cad2016-09-08 23:55:21489 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01490 site_identity_details_.assign(l10n_util::GetStringFUTF16(
491 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59492 security_info.sct_verify_statuses, true /* is EV */),
jam8ae7cad2016-09-08 23:55:21493 UTF8ToUTF16(certificate_->subject().organization_names[0]),
494 locality,
495 UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01496 } else {
497 // Non-EV OK HTTPS page.
498 site_identity_status_ = GetSiteIdentityStatusByCTInfo(
estarka3121f6b2015-09-18 21:15:59499 security_info.sct_verify_statuses, false);
rsleevi4f8012722014-09-30 01:28:01500 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21501 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01502 if (issuer_name.empty()) {
503 issuer_name.assign(l10n_util::GetStringUTF16(
504 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
505 }
[email protected]94c74b42013-12-02 15:19:49506
rsleevi4f8012722014-09-30 01:28:01507 site_identity_details_.assign(l10n_util::GetStringFUTF16(
508 GetSiteIdentityDetailsMessageByCTInfo(
estarka3121f6b2015-09-18 21:15:59509 security_info.sct_verify_statuses, false /* not EV */),
rsleevi4f8012722014-09-30 01:28:01510 issuer_name));
511 }
lgarroncc53de22015-10-05 23:03:17512 switch (security_info.sha1_deprecation_status) {
513 case SecurityStateModel::DEPRECATED_SHA1_MINOR:
514 site_identity_status_ =
515 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR;
516 site_identity_details_ +=
517 UTF8ToUTF16("\n\n") +
518 l10n_util::GetStringUTF16(
519 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MINOR);
520 break;
521 case SecurityStateModel::DEPRECATED_SHA1_MAJOR:
522 site_identity_status_ =
523 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR;
524 site_identity_details_ +=
525 UTF8ToUTF16("\n\n") +
526 l10n_util::GetStringUTF16(
527 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR);
528 break;
529 case SecurityStateModel::NO_DEPRECATED_SHA1:
530 // Nothing to do.
531 break;
felt61638452016-08-09 22:21:55532 case SecurityStateModel::UNKNOWN_SHA1:
533 // UNKNOWN_SHA1 should only appear when certificate info has not been
534 // initialized, in which case this if-statement should not be running
535 // because there is no other cert info.
536 NOTREACHED();
rsleevi4f8012722014-09-30 01:28:01537 }
[email protected]03ef4b2a2012-03-06 15:04:20538 }
539 } else {
540 // HTTP or HTTPS with errors (not warnings).
541 site_identity_details_.assign(l10n_util::GetStringUTF16(
542 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
jam8ae7cad2016-09-08 23:55:21543 if (!security_info.scheme_is_cryptographic || !security_info.certificate)
[email protected]03ef4b2a2012-03-06 15:04:20544 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
545 else
546 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
547
[email protected]a04db822013-12-11 19:14:40548 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59549 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59550 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
jam8ae7cad2016-09-08 23:55:21551 certificate_, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20552 for (size_t i = 0; i < errors.size(); ++i) {
553 site_identity_details_ += bullet;
554 site_identity_details_ += errors[i].short_description();
555 }
556
estarka3121f6b2015-09-18 21:15:59557 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20558 site_identity_details_ += ASCIIToUTF16("\n\n");
559 site_identity_details_ += l10n_util::GetStringUTF16(
560 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
561 }
562 }
563
564 // Site Connection
565 // We consider anything less than 80 bits encryption to be weak encryption.
566 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
567 // weakly encrypted connections.
568 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
569
jshin1fb76462016-04-05 22:13:03570 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19571 if (subject_name.empty()) {
572 subject_name.assign(
573 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
574 }
575
jam8ae7cad2016-09-08 23:55:21576 if (!security_info.certificate || !security_info.scheme_is_cryptographic) {
estarka3121f6b2015-09-18 21:15:59577 // Page is still loading (so SSL status is not yet available) or
578 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58579 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
580
581 site_connection_details_.assign(l10n_util::GetStringFUTF16(
582 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
583 subject_name));
estarka3121f6b2015-09-18 21:15:59584 } else if (security_info.security_bits < 0) {
585 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20586 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59587 } else if (security_info.security_bits == 0) {
588 DCHECK_NE(security_info.security_level, SecurityStateModel::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20589 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
590 site_connection_details_.assign(l10n_util::GetStringFUTF16(
591 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
592 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20593 } else {
594 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22595
lgarron3e2c33e2016-08-25 06:33:43596 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22597 site_connection_details_.assign(l10n_util::GetStringFUTF16(
598 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
599 subject_name));
600 } else {
601 site_connection_details_.assign(l10n_util::GetStringFUTF16(
602 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
603 subject_name));
604 }
605
estark00e83f12016-08-19 18:24:04606 bool ran_insecure_content = false;
607 bool displayed_insecure_content = false;
608 CheckForInsecureContent(security_info, &displayed_insecure_content,
609 &ran_insecure_content);
610 if (ran_insecure_content || displayed_insecure_content) {
611 site_connection_status_ =
612 ran_insecure_content
613 ? SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE
614 : SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
[email protected]03ef4b2a2012-03-06 15:04:20615 site_connection_details_.assign(l10n_util::GetStringFUTF16(
616 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
617 site_connection_details_,
estark00e83f12016-08-19 18:24:04618 l10n_util::GetStringUTF16(
619 ran_insecure_content
620 ? IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR
621 : IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
[email protected]03ef4b2a2012-03-06 15:04:20622 }
623 }
624
avi655876a2015-12-25 07:18:15625 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59626 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
627 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20628 int ssl_version =
estarka3121f6b2015-09-18 21:15:59629 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20630 const char* ssl_version_str;
631 net::SSLVersionToString(&ssl_version_str, ssl_version);
632 site_connection_details_ += ASCIIToUTF16("\n\n");
633 site_connection_details_ += l10n_util::GetStringFUTF16(
634 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION,
635 ASCIIToUTF16(ssl_version_str));
636
[email protected]03ef4b2a2012-03-06 15:04:20637 bool no_renegotiation =
estarka3121f6b2015-09-18 21:15:59638 (security_info.connection_status &
639 net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20640 const char *key_exchange, *cipher, *mac;
[email protected]b6c1d9e82013-06-12 17:26:57641 bool is_aead;
642 net::SSLCipherSuiteToStrings(
643 &key_exchange, &cipher, &mac, &is_aead, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20644
645 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57646 if (is_aead) {
647 site_connection_details_ += l10n_util::GetStringFUTF16(
648 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
649 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
650 } else {
651 site_connection_details_ += l10n_util::GetStringFUTF16(
652 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS,
653 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
654 }
[email protected]03ef4b2a2012-03-06 15:04:20655
agl078d2102014-10-20 22:03:22656 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 &&
estark00e83f12016-08-19 18:24:04657 site_connection_status_ <
658 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE) {
agl078d2102014-10-20 22:03:22659 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
660 }
661
estarka3121f6b2015-09-18 21:15:59662 const bool did_fallback = (security_info.connection_status &
663 net::SSL_CONNECTION_VERSION_FALLBACK) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20664 if (did_fallback) {
[email protected]03ef4b2a2012-03-06 15:04:20665 site_connection_details_ += ASCIIToUTF16("\n\n");
666 site_connection_details_ += l10n_util::GetStringUTF16(
667 IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE);
668 }
agl078d2102014-10-20 22:03:22669
[email protected]03ef4b2a2012-03-06 15:04:20670 if (no_renegotiation) {
671 site_connection_details_ += ASCIIToUTF16("\n\n");
672 site_connection_details_ += l10n_util::GetStringUTF16(
673 IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE);
674 }
675 }
[email protected]e583f752012-08-30 13:26:21676
[email protected]71cd5ef2014-08-13 21:22:04677 // Check if a user decision has been made to allow or deny certificates with
678 // errors on this site.
679 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50680 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04681 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40682 // Only show an SSL decision revoke button if the user has chosen to bypass
683 // SSL host errors for this host in the past.
684 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]71cd5ef2014-08-13 21:22:04685
palmer82b1f7b2015-09-17 19:20:41686 // By default select the Permissions Tab that displays all the site
687 // permissions. In case of a connection error or an issue with the certificate
688 // presented by the website, select the Connection Tab to draw the user's
689 // attention to the issue. If the site does not provide a certificate because
690 // it was loaded over an unencrypted connection, don't select the Connection
691 // Tab.
[email protected]e583f752012-08-30 13:26:21692 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS;
693 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR ||
estark00e83f12016-08-19 18:24:04694 site_connection_status_ ==
695 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE ||
696 site_connection_status_ ==
697 SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE ||
[email protected]e583f752012-08-30 13:26:21698 site_identity_status_ == SITE_IDENTITY_STATUS_ERROR ||
estark134a9822015-10-29 04:35:18699 site_identity_status_ == SITE_IDENTITY_STATUS_CT_ERROR ||
[email protected]eaf3f322013-04-25 21:53:59700 site_identity_status_ == SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN ||
rsleevi4f8012722014-09-30 01:28:01701 site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT ||
702 site_identity_status_ ==
lgarroncc53de22015-10-05 23:03:17703 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR ||
704 site_identity_status_ ==
705 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR) {
[email protected]e583f752012-08-30 13:26:21706 tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION;
lgarron04a93502014-11-04 22:25:04707 RecordWebsiteSettingsAction(
708 WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY);
709 }
palmer82b1f7b2015-09-17 19:20:41710
[email protected]e583f752012-08-30 13:26:21711 ui_->SetSelectedTab(tab_id);
[email protected]03ef4b2a2012-03-06 15:04:20712}
[email protected]0b9fdd72012-04-04 10:00:33713
[email protected]df818272012-04-20 13:10:50714void WebsiteSettings::PresentSitePermissions() {
715 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38716 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50717
718 WebsiteSettingsUI::PermissionInfo permission_info;
719 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
720 permission_info.type = kPermissionType[i];
721
mgiucaa319f212016-01-14 03:30:11722 if (!ShouldShowPermission(permission_info.type))
723 continue;
724
[email protected]df818272012-04-20 13:10:50725 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32726 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
727 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21728 DCHECK(value.get());
729 if (value->GetType() == base::Value::TYPE_INTEGER) {
730 permission_info.setting =
731 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26732 } else {
sashab2b2a314f2015-01-17 06:42:21733 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26734 }
735
[email protected]8bdf45c32012-08-04 00:12:55736 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28737 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50738
[email protected]b1d113d2012-06-27 21:27:34739 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21740 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34741 permission_info.default_setting = permission_info.setting;
742 permission_info.setting = CONTENT_SETTING_DEFAULT;
743 } else {
744 permission_info.default_setting =
745 content_settings_->GetDefaultContentSetting(permission_info.type,
746 NULL);
[email protected]df818272012-04-20 13:10:50747 }
palmer0da10b32015-02-11 00:42:19748
palmer64a099982016-03-09 21:26:11749 if (permission_info.type == CONTENT_SETTINGS_TYPE_KEYGEN &&
750 (permission_info.setting == CONTENT_SETTING_DEFAULT ||
751 permission_info.setting == permission_info.default_setting) &&
752 !tab_specific_content_settings()->IsContentBlocked(
753 permission_info.type)) {
754 continue;
palmer0da10b32015-02-11 00:42:19755 }
palmer64a099982016-03-09 21:26:11756 permission_info_list.push_back(permission_info);
[email protected]df818272012-04-20 13:10:50757 }
758
reillyg85f57db2016-01-12 23:14:38759 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
760 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10761 const GURL origin = site_url_.GetOrigin();
762 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32763 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38764 chosen_object_info_list.push_back(
765 new WebsiteSettingsUI::ChosenObjectInfo(ui_info, std::move(object)));
766 }
767 }
768
769 ui_->SetPermissionInfo(permission_info_list, chosen_object_info_list);
[email protected]0b9fdd72012-04-04 10:00:33770}
771
[email protected]df818272012-04-20 13:10:50772void WebsiteSettings::PresentSiteData() {
773 CookieInfoList cookie_info_list;
vabrbab3ffcb2016-10-04 10:08:10774 const LocalSharedObjectsContainer& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34775 tab_specific_content_settings()->allowed_local_shared_objects();
vabrbab3ffcb2016-10-04 10:08:10776 const LocalSharedObjectsContainer& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34777 tab_specific_content_settings()->blocked_local_shared_objects();
778
779 // Add first party cookie and site data counts.
[email protected]df818272012-04-20 13:10:50780 WebsiteSettingsUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34781 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
782 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15783 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34784 cookie_info_list.push_back(cookie_info);
785
786 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34787 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
788 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15789 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50790 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33791
[email protected]df818272012-04-20 13:10:50792 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33793}
[email protected]16de6de2012-04-04 12:24:14794
[email protected]24c8818c2012-04-25 09:57:41795void WebsiteSettings::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04796 // After initialization the status about the site's connection and its
797 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41798 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
799 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
800 WebsiteSettingsUI::IdentityInfo info;
801 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
802 info.site_identity = UTF16ToUTF8(organization_name());
803 else
jshin1fb76462016-04-05 22:13:03804 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41805
806 info.connection_status = site_connection_status_;
807 info.connection_status_description =
808 UTF16ToUTF8(site_connection_details_);
809 info.identity_status = site_identity_status_;
810 info.identity_status_description =
811 UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21812 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04813 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
[email protected]24c8818c2012-04-25 09:57:41814 ui_->SetIdentityInfo(info);
815}