blob: c15621855cad949db9f30a0a27022f2af93041ec [file] [log] [blame]
[email protected]03ef4b2a2012-03-06 15:04:201// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]4237dd52012-06-05 00:00:325#include "chrome/browser/ui/website_settings/website_settings.h"
[email protected]03ef4b2a2012-03-06 15:04:206
avi655876a2015-12-25 07:18:157#include <stddef.h>
8#include <stdint.h>
9
[email protected]03ef4b2a2012-03-06 15:04:2010#include <string>
11#include <vector>
12
[email protected]eb2140c2013-07-29 12:37:3413#include "base/command_line.h"
[email protected]15b092542012-05-16 13:08:1414#include "base/i18n/time_formatting.h"
avi655876a2015-12-25 07:18:1515#include "base/macros.h"
avi09dd4d02016-10-14 20:40:0916#include "base/memory/ptr_util.h"
[email protected]71cd5ef2014-08-13 21:22:0417#include "base/metrics/field_trial.h"
asvitkine75036032016-09-01 20:49:3418#include "base/metrics/histogram_macros.h"
[email protected]3ea1b182013-02-08 22:38:4119#include "base/strings/string_number_conversions.h"
[email protected]774cc3c2013-06-07 20:26:4520#include "base/strings/utf_string_conversions.h"
[email protected]0b9fdd72012-04-04 10:00:3321#include "base/values.h"
avi655876a2015-12-25 07:18:1522#include "build/build_config.h"
jialiul02aad2d2015-04-01 18:56:0323#include "chrome/browser/browser_process.h"
[email protected]6b8a3c742014-07-25 00:25:3524#include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h"
[email protected]b0cb5e82012-07-19 19:22:4725#include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
26#include "chrome/browser/browsing_data/browsing_data_database_helper.h"
27#include "chrome/browser/browsing_data/browsing_data_file_system_helper.h"
28#include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
29#include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
peconn5100d432015-09-16 12:03:0830#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
vabrbab3ffcb2016-10-04 10:08:1031#include "chrome/browser/content_settings/local_shared_objects_container.h"
[email protected]77a91c72012-08-13 16:19:3432#include "chrome/browser/history/history_service_factory.h"
palmerf2cba0d2015-08-27 23:15:0633#include "chrome/browser/infobars/infobar_service.h"
reillyg85f57db2016-01-12 23:14:3834#include "chrome/browser/permissions/chooser_context_base.h"
tsergeantf1e89352016-01-15 20:34:5435#include "chrome/browser/permissions/permission_uma_util.h"
36#include "chrome/browser/permissions/permission_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2037#include "chrome/browser/profiles/profile.h"
[email protected]71cd5ef2014-08-13 21:22:0438#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
39#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
[email protected]4237dd52012-06-05 00:00:3240#include "chrome/browser/ui/website_settings/website_settings_ui.h"
reillyg85f57db2016-01-12 23:14:3841#include "chrome/browser/usb/usb_chooser_context.h"
42#include "chrome/browser/usb/usb_chooser_context_factory.h"
[email protected]71cd5ef2014-08-13 21:22:0443#include "chrome/common/chrome_switches.h"
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"
nzolghadrd87a308d2016-12-07 15:45:5653#include "components/rappor/public/rappor_utils.h"
54#include "components/rappor/rappor_service_impl.h"
felt2493b4452015-09-17 20:33:5955#include "components/ssl_errors/error_info.h"
thestig4a2e88e2016-08-27 23:23:5156#include "components/strings/grit/components_chromium_strings.h"
57#include "components/strings/grit/components_strings.h"
palmer153af982015-09-15 02:04:1958#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3359#include "content/public/browser/browser_thread.h"
tsergeantf1e89352016-01-15 20:34:5460#include "content/public/browser/permission_type.h"
[email protected]e22d64f2012-09-10 09:03:2361#include "content/public/browser/user_metrics.h"
[email protected]eb2140c2013-07-29 12:37:3462#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2063#include "content/public/common/url_constants.h"
[email protected]6e7845ae2013-03-29 21:48:1164#include "net/cert/cert_status_flags.h"
65#include "net/cert/x509_certificate.h"
[email protected]536fd0b2013-03-14 17:41:5766#include "net/ssl/ssl_cipher_suite_names.h"
67#include "net/ssl/ssl_connection_status_flags.h"
tfarina29a3a1742016-10-28 18:47:3368#include "third_party/boringssl/src/include/openssl/ssl.h"
[email protected]03ef4b2a2012-03-06 15:04:2069#include "ui/base/l10n/l10n_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2070
[email protected]24a9f1c92013-11-13 12:33:3771#if defined(OS_CHROMEOS)
72#include "chrome/browser/chromeos/policy/policy_cert_service.h"
73#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
74#endif
75
estade3feb83f2015-09-01 23:00:4976#if !defined(OS_ANDROID)
mgiucaa319f212016-01-14 03:30:1177#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
estade3feb83f2015-09-01 23:00:4978#include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h"
79#endif
80
[email protected]ab6df3b12013-12-24 23:32:2681using base::ASCIIToUTF16;
82using base::UTF8ToUTF16;
[email protected]f729d7a2013-12-26 07:07:5683using base::UTF16ToUTF8;
[email protected]0b9fdd72012-04-04 10:00:3384using content::BrowserThread;
[email protected]0b9fdd72012-04-04 10:00:3385
86namespace {
87
jww1ed8ea72014-09-02 20:43:2588// Events for UMA. Do not reorder or change!
89enum SSLCertificateDecisionsDidRevoke {
90 USER_CERT_DECISIONS_NOT_REVOKED = 0,
91 USER_CERT_DECISIONS_REVOKED,
92 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM
93};
94
palmer0da10b32015-02-11 00:42:1995// The list of content settings types to display on the Website Settings UI. THE
96// ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, email
97// [email protected].
[email protected]0b9fdd72012-04-04 10:00:3398ContentSettingsType kPermissionType[] = {
sashab2b2a314f2015-01-17 06:42:2199 CONTENT_SETTINGS_TYPE_GEOLOCATION,
sashab2b2a314f2015-01-17 06:42:21100 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
101 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
palmer0da10b32015-02-11 00:42:19102 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
palmer7715e332016-05-27 00:41:19103 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
lshange085f202016-06-14 01:25:08104#if !defined(OS_ANDROID)
palmer7715e332016-05-27 00:41:19105 CONTENT_SETTINGS_TYPE_PLUGINS,
106 CONTENT_SETTINGS_TYPE_IMAGES,
lshange085f202016-06-14 01:25:08107#endif
palmer7715e332016-05-27 00:41:19108 CONTENT_SETTINGS_TYPE_POPUPS,
nsatragno670fe922016-04-08 14:10:50109 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
palmer7715e332016-05-27 00:41:19110 CONTENT_SETTINGS_TYPE_KEYGEN,
111 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
finnur46cafd42016-09-22 10:27:17112 CONTENT_SETTINGS_TYPE_AUTOPLAY,
palmer7715e332016-05-27 00:41:19113 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
[email protected]0b9fdd72012-04-04 10:00:33114};
115
mgiucaa319f212016-01-14 03:30:11116// Determines whether to show permission |type| in the Website Settings UI. Only
117// applies to permissions listed in |kPermissionType|.
118bool ShouldShowPermission(ContentSettingsType type) {
mgiucaa319f212016-01-14 03:30:11119#if !defined(OS_ANDROID)
finnur46cafd42016-09-22 10:27:17120 // Autoplay is Android-only at the moment.
mgiuca273b9672016-11-11 02:22:20121 if (type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
mgiuca0f3e1f72016-05-13 01:56:27122 return false;
mgiucaa319f212016-01-14 03:30:11123#endif
124
125 return true;
126}
127
esecklercac56b62016-11-16 13:49:44128void CheckContentStatus(security_state::ContentStatus content_status,
estark00e83f12016-08-19 18:24:04129 bool* displayed,
130 bool* ran) {
131 switch (content_status) {
esecklercac56b62016-11-16 13:49:44132 case security_state::CONTENT_STATUS_DISPLAYED:
estark00e83f12016-08-19 18:24:04133 *displayed = true;
134 break;
esecklercac56b62016-11-16 13:49:44135 case security_state::CONTENT_STATUS_RAN:
estark00e83f12016-08-19 18:24:04136 *ran = true;
137 break;
esecklercac56b62016-11-16 13:49:44138 case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN:
estark00e83f12016-08-19 18:24:04139 *displayed = true;
140 *ran = true;
141 break;
esecklercac56b62016-11-16 13:49:44142 case security_state::CONTENT_STATUS_UNKNOWN:
143 case security_state::CONTENT_STATUS_NONE:
estark00e83f12016-08-19 18:24:04144 break;
145 }
146}
147
148void CheckForInsecureContent(
esecklercac56b62016-11-16 13:49:44149 const security_state::SecurityInfo& security_info,
estark00e83f12016-08-19 18:24:04150 bool* displayed,
151 bool* ran) {
152 CheckContentStatus(security_info.mixed_content_status, displayed, ran);
153 // Only consider subresources with certificate errors if the main
154 // resource was loaded over HTTPS without major certificate errors. If
155 // the main resource had a certificate error, then it would not be
156 // that useful (and would potentially be confusing) to warn about
157 // subesources that had certificate errors too.
158 if (net::IsCertStatusError(security_info.cert_status) &&
159 !net::IsCertStatusMinorError(security_info.cert_status)) {
160 return;
161 }
162 CheckContentStatus(security_info.content_with_cert_errors_status, displayed,
163 ran);
164}
165
estarkfcfccdb82016-11-14 02:17:29166void GetSiteIdentityByMaliciousContentStatus(
esecklercac56b62016-11-16 13:49:44167 security_state::MaliciousContentStatus malicious_content_status,
estarkfcfccdb82016-11-14 02:17:29168 WebsiteSettings::SiteIdentityStatus* status,
169 base::string16* details) {
170 switch (malicious_content_status) {
esecklercac56b62016-11-16 13:49:44171 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
estarkfcfccdb82016-11-14 02:17:29172 NOTREACHED();
173 break;
esecklercac56b62016-11-16 13:49:44174 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
estarkfcfccdb82016-11-14 02:17:29175 *status = WebsiteSettings::SITE_IDENTITY_STATUS_MALWARE;
176 *details =
177 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_MALWARE_DETAILS);
178 break;
esecklercac56b62016-11-16 13:49:44179 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
estarkfcfccdb82016-11-14 02:17:29180 *status = WebsiteSettings::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
181 *details = l10n_util::GetStringUTF16(
182 IDS_WEBSITE_SETTINGS_SOCIAL_ENGINEERING_DETAILS);
183 break;
esecklercac56b62016-11-16 13:49:44184 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
estarkfcfccdb82016-11-14 02:17:29185 *status = WebsiteSettings::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
186 *details = l10n_util::GetStringUTF16(
187 IDS_WEBSITE_SETTINGS_UNWANTED_SOFTWARE_DETAILS);
188 break;
189 }
190}
191
jshin1fb76462016-04-05 22:13:03192base::string16 GetSimpleSiteName(const GURL& url) {
benwells2337b8102016-04-20 01:53:53193 return url_formatter::FormatUrlForSecurityDisplay(
194 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
palmer153af982015-09-15 02:04:19195}
196
reillyg85f57db2016-01-12 23:14:38197ChooserContextBase* GetUsbChooserContext(Profile* profile) {
198 return UsbChooserContextFactory::GetForProfile(profile);
199}
200
201// The list of chooser types that need to display entries in the Website
202// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
203// email [email protected].
204WebsiteSettings::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52205 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
206 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_WEBSITE_SETTINGS_USB_DEVICE_LABEL,
reillyg85f57db2016-01-12 23:14:38207 IDS_WEBSITE_SETTINGS_DELETE_USB_DEVICE, "name"},
208};
209
[email protected]0b9fdd72012-04-04 10:00:33210} // namespace
211
212WebsiteSettings::WebsiteSettings(
213 WebsiteSettingsUI* ui,
214 Profile* profile,
[email protected]df818272012-04-20 13:10:50215 TabSpecificContentSettings* tab_specific_content_settings,
palmerf2cba0d2015-08-27 23:15:06216 content::WebContents* web_contents,
[email protected]0b9fdd72012-04-04 10:00:33217 const GURL& url,
esecklercac56b62016-11-16 13:49:44218 const security_state::SecurityInfo& security_info)
[email protected]df818272012-04-20 13:10:50219 : TabSpecificContentSettings::SiteDataObserver(
220 tab_specific_content_settings),
dominicknbdd53b5f2016-09-28 01:08:13221 content::WebContentsObserver(web_contents),
[email protected]df818272012-04-20 13:10:50222 ui_(ui),
[email protected]66f157312012-08-01 13:50:26223 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33224 site_url_(url),
225 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]03ef4b2a2012-03-06 15:04:20226 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
alshabalin5e894c12016-10-25 06:47:46227 show_ssl_decision_revoke_button_(false),
peconn5100d432015-09-16 12:03:08228 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04229 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25230 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19231 did_revoke_user_ssl_decisions_(false),
estark8d67cd7a2016-10-24 05:06:41232 profile_(profile),
esecklercac56b62016-11-16 13:49:44233 security_level_(security_state::NONE) {
estarka3121f6b2015-09-18 21:15:59234 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33235
236 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50237 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41238 PresentSiteIdentity();
[email protected]e22d64f2012-09-10 09:03:23239
240 // Every time the Website Settings UI is opened a |WebsiteSettings| object is
241 // created. So this counts how ofter the Website Settings UI is opened.
lgarron04a93502014-11-04 22:25:04242 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20243}
244
[email protected]0b9fdd72012-04-04 10:00:33245WebsiteSettings::~WebsiteSettings() {
[email protected]03ef4b2a2012-03-06 15:04:20246}
247
lgarron04a93502014-11-04 22:25:04248void WebsiteSettings::RecordWebsiteSettingsAction(
249 WebsiteSettingsAction action) {
250 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action",
251 action,
252 WEBSITE_SETTINGS_COUNT);
253
estark8d67cd7a2016-10-24 05:06:41254 std::string histogram_name;
palmeree0e5af2015-06-05 03:10:40255
estark8d67cd7a2016-10-24 05:06:41256 if (site_url_.SchemeIsCryptographic()) {
esecklercac56b62016-11-16 13:49:44257 if (security_level_ == security_state::SECURE ||
258 security_level_ == security_state::EV_SECURE) {
estark8d67cd7a2016-10-24 05:06:41259 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Valid",
260 action, WEBSITE_SETTINGS_COUNT);
esecklercac56b62016-11-16 13:49:44261 } else if (security_level_ == security_state::NONE) {
estark8d67cd7a2016-10-24 05:06:41262 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded",
263 action, WEBSITE_SETTINGS_COUNT);
esecklercac56b62016-11-16 13:49:44264 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41265 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous",
266 action, WEBSITE_SETTINGS_COUNT);
267 }
268 return;
269 }
270
esecklercac56b62016-11-16 13:49:44271 if (security_level_ == security_state::HTTP_SHOW_WARNING) {
estark8d67cd7a2016-10-24 05:06:41272 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning",
273 action, WEBSITE_SETTINGS_COUNT);
esecklercac56b62016-11-16 13:49:44274 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41275 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous",
276 action, WEBSITE_SETTINGS_COUNT);
277 } else {
278 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral",
279 action, WEBSITE_SETTINGS_COUNT);
lgarron04a93502014-11-04 22:25:04280 }
281}
282
[email protected]df818272012-04-20 13:10:50283void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type,
284 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23285 // Count how often a permission for a specific content type is changed using
286 // the Website Settings UI.
raymes4a13d432015-09-08 00:44:07287 size_t num_values;
288 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
sashab9debecd2014-12-18 04:15:56289 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.OriginInfo.PermissionChanged",
raymes4a13d432015-09-08 00:44:07290 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56291
292 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
293 UMA_HISTOGRAM_ENUMERATION(
294 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07295 num_values);
tommycli34cf29bf2016-09-08 05:46:25296
297 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
298 rappor::SampleDomainAndRegistryFromGURL(
299 g_browser_process->rappor_service(),
300 "ContentSettings.Plugins.AddedAllowException", site_url_);
301 }
sashab9debecd2014-12-18 04:15:56302 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
303 UMA_HISTOGRAM_ENUMERATION(
304 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07305 num_values);
sashab9debecd2014-12-18 04:15:56306 }
[email protected]e22d64f2012-09-10 09:03:23307
lgarron04a93502014-11-04 22:25:04308 // This is technically redundant given the histogram above, but putting the
309 // total count of permission changes in another histogram makes it easier to
310 // compare it against other kinds of actions in WebsiteSettings[PopupView].
311 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_CHANGED_PERMISSION);
312
stefanocs8b3490cc2016-07-28 05:32:52313 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
314 this->profile_, this->site_url_, this->site_url_, type,
315 PermissionSourceUI::OIB);
316
raymesfbaaaaa2015-11-10 02:20:40317 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
318 setting);
[email protected]df818272012-04-20 13:10:50319
[email protected]66f157312012-08-01 13:50:26320 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24321
[email protected]2f45d542012-08-22 08:47:24322 // Refresh the UI to reflect the new setting.
323 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50324}
325
reillyg85f57db2016-01-12 23:14:38326void WebsiteSettings::OnSiteChosenObjectDeleted(
327 const ChooserUIInfo& ui_info,
328 const base::DictionaryValue& object) {
329 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
330 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10331 const GURL origin = site_url_.GetOrigin();
332 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38333
334 show_info_bar_ = true;
335
336 // Refresh the UI to reflect the changed settings.
337 PresentSitePermissions();
338}
339
[email protected]df818272012-04-20 13:10:50340void WebsiteSettings::OnSiteDataAccessed() {
341 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33342}
343
[email protected]66f157312012-08-01 13:50:26344void WebsiteSettings::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49345#if defined(OS_ANDROID)
346 NOTREACHED();
347#else
dominicknbdd53b5f2016-09-28 01:08:13348 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
palmerf2cba0d2015-08-27 23:15:06349 InfoBarService* infobar_service =
dominicknbdd53b5f2016-09-28 01:08:13350 InfoBarService::FromWebContents(web_contents());
palmerf2cba0d2015-08-27 23:15:06351 if (infobar_service)
352 WebsiteSettingsInfoBarDelegate::Create(infobar_service);
353 }
jww1ed8ea72014-09-02 20:43:25354
355 SSLCertificateDecisionsDidRevoke user_decision =
356 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
357 : USER_CERT_DECISIONS_NOT_REVOKED;
358
359 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
360 user_decision,
361 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49362#endif
jww1ed8ea72014-09-02 20:43:25363}
364
365void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() {
366 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29367 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
368 site_url().host());
jww1ed8ea72014-09-02 20:43:25369 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26370}
371
esecklercac56b62016-11-16 13:49:44372void WebsiteSettings::Init(const GURL& url,
373 const security_state::SecurityInfo& security_info) {
meacerde53fcff2016-10-12 19:21:57374#if !defined(OS_ANDROID) && !defined(OS_IOS)
375 // On desktop, internal URLs aren't handled by this class. Instead, a
376 // custom and simpler popup is shown.
377 DCHECK(!url.SchemeIs(content::kChromeUIScheme) &&
378 !url.SchemeIs(content::kChromeDevToolsScheme) &&
379 !url.SchemeIs(content::kViewSourceScheme) &&
380 !url.SchemeIs(content_settings::kExtensionScheme));
381#endif
382
sashab97894ce2014-10-22 10:08:33383 bool isChromeUINativeScheme = false;
sievers2f1e8112015-12-04 18:43:56384#if BUILDFLAG(ANDROID_JAVA_UI)
sashab97894ce2014-10-22 10:08:33385 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
386#endif
387
estark8d67cd7a2016-10-24 05:06:41388 security_level_ = security_info.security_level;
389
upendrag.gowda60886a6e2015-10-31 05:51:09390 if (url.SchemeIs(url::kAboutScheme)) {
391 // All about: URLs except about:blank are redirected.
392 DCHECK_EQ(url::kAboutBlankURL, url.spec());
393 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
394 site_identity_details_ =
395 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
396 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
397 site_connection_details_ = l10n_util::GetStringFUTF16(
398 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
399 UTF8ToUTF16(url.spec()));
400 return;
401 }
402
403 if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) {
[email protected]03ef4b2a2012-03-06 15:04:20404 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
405 site_identity_details_ =
406 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
407 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
408 return;
409 }
410
[email protected]03ef4b2a2012-03-06 15:04:20411 // Identity section.
jam8ae7cad2016-09-08 23:55:21412 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11413
estarkfcfccdb82016-11-14 02:17:29414 if (security_info.malicious_content_status !=
esecklercac56b62016-11-16 13:49:44415 security_state::MALICIOUS_CONTENT_STATUS_NONE) {
estarkfcfccdb82016-11-14 02:17:29416 // The site has been flagged by Safe Browsing as dangerous.
417 GetSiteIdentityByMaliciousContentStatus(
418 security_info.malicious_content_status, &site_identity_status_,
419 &site_identity_details_);
420 } else if (certificate_ &&
421 (!net::IsCertStatusError(security_info.cert_status) ||
422 net::IsCertStatusMinorError(security_info.cert_status))) {
423 // HTTPS with no or minor errors.
estarka3121f6b2015-09-18 21:15:59424 if (security_info.security_level ==
esecklercac56b62016-11-16 13:49:44425 security_state::SECURE_WITH_POLICY_INSTALLED_CERT) {
[email protected]eaf3f322013-04-25 21:53:59426 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37427 site_identity_details_ = l10n_util::GetStringFUTF16(
428 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59429 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20430 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21431 base::string16 issuer_name(
432 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20433 if (issuer_name.empty()) {
434 issuer_name.assign(l10n_util::GetStringUTF16(
435 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
436 }
[email protected]94c74b42013-12-02 15:19:49437
[email protected]03ef4b2a2012-03-06 15:04:20438 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39439 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20440
441 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59442 if (security_info.cert_status &
443 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20444 site_identity_details_ += l10n_util::GetStringUTF16(
445 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59446 } else if (security_info.cert_status &
447 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20448 site_identity_details_ += l10n_util::GetStringUTF16(
449 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
450 } else {
451 NOTREACHED() << "Need to specify string for this warning";
452 }
[email protected]03ef4b2a2012-03-06 15:04:20453 } else {
estarkcf305562016-11-15 03:45:39454 // No major or minor errors.
estarka3121f6b2015-09-18 21:15:59455 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01456 // EV HTTPS page.
estarkcf305562016-11-15 03:45:39457 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
jam8ae7cad2016-09-08 23:55:21458 DCHECK(!certificate_->subject().organization_names.empty());
459 organization_name_ =
460 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01461 // An EV Cert is required to have a city (localityName) and country but
462 // state is "if any".
jam8ae7cad2016-09-08 23:55:21463 DCHECK(!certificate_->subject().locality_name.empty());
464 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01465 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21466 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01467 locality = l10n_util::GetStringFUTF16(
468 IDS_PAGEINFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21469 UTF8ToUTF16(certificate_->subject().locality_name),
470 UTF8ToUTF16(certificate_->subject().state_or_province_name),
471 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01472 } else {
473 locality = l10n_util::GetStringFUTF16(
474 IDS_PAGEINFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21475 UTF8ToUTF16(certificate_->subject().locality_name),
476 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01477 }
jam8ae7cad2016-09-08 23:55:21478 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01479 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39480 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED,
jam8ae7cad2016-09-08 23:55:21481 UTF8ToUTF16(certificate_->subject().organization_names[0]),
estarkcf305562016-11-15 03:45:39482 locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01483 } else {
484 // Non-EV OK HTTPS page.
estarkcf305562016-11-15 03:45:39485 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
rsleevi4f8012722014-09-30 01:28:01486 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21487 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01488 if (issuer_name.empty()) {
489 issuer_name.assign(l10n_util::GetStringUTF16(
490 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
491 }
[email protected]94c74b42013-12-02 15:19:49492
rsleevi4f8012722014-09-30 01:28:01493 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39494 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
rsleevi4f8012722014-09-30 01:28:01495 }
lgarroncc53de22015-10-05 23:03:17496 switch (security_info.sha1_deprecation_status) {
esecklercac56b62016-11-16 13:49:44497 case security_state::DEPRECATED_SHA1_MINOR:
lgarroncc53de22015-10-05 23:03:17498 site_identity_status_ =
499 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR;
500 site_identity_details_ +=
501 UTF8ToUTF16("\n\n") +
502 l10n_util::GetStringUTF16(
503 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MINOR);
504 break;
esecklercac56b62016-11-16 13:49:44505 case security_state::DEPRECATED_SHA1_MAJOR:
lgarroncc53de22015-10-05 23:03:17506 site_identity_status_ =
507 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR;
508 site_identity_details_ +=
509 UTF8ToUTF16("\n\n") +
510 l10n_util::GetStringUTF16(
511 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR);
512 break;
esecklercac56b62016-11-16 13:49:44513 case security_state::NO_DEPRECATED_SHA1:
lgarroncc53de22015-10-05 23:03:17514 // Nothing to do.
515 break;
esecklercac56b62016-11-16 13:49:44516 case security_state::UNKNOWN_SHA1:
felt61638452016-08-09 22:21:55517 // UNKNOWN_SHA1 should only appear when certificate info has not been
518 // initialized, in which case this if-statement should not be running
519 // because there is no other cert info.
520 NOTREACHED();
rsleevi4f8012722014-09-30 01:28:01521 }
[email protected]03ef4b2a2012-03-06 15:04:20522 }
523 } else {
524 // HTTP or HTTPS with errors (not warnings).
525 site_identity_details_.assign(l10n_util::GetStringUTF16(
526 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
jam8ae7cad2016-09-08 23:55:21527 if (!security_info.scheme_is_cryptographic || !security_info.certificate)
[email protected]03ef4b2a2012-03-06 15:04:20528 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
529 else
530 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
531
[email protected]a04db822013-12-11 19:14:40532 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59533 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59534 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
jam8ae7cad2016-09-08 23:55:21535 certificate_, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20536 for (size_t i = 0; i < errors.size(); ++i) {
537 site_identity_details_ += bullet;
538 site_identity_details_ += errors[i].short_description();
539 }
540
estarka3121f6b2015-09-18 21:15:59541 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20542 site_identity_details_ += ASCIIToUTF16("\n\n");
543 site_identity_details_ += l10n_util::GetStringUTF16(
544 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
545 }
546 }
547
548 // Site Connection
549 // We consider anything less than 80 bits encryption to be weak encryption.
550 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
551 // weakly encrypted connections.
552 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
553
jshin1fb76462016-04-05 22:13:03554 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19555 if (subject_name.empty()) {
556 subject_name.assign(
557 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
558 }
559
jam8ae7cad2016-09-08 23:55:21560 if (!security_info.certificate || !security_info.scheme_is_cryptographic) {
estarka3121f6b2015-09-18 21:15:59561 // Page is still loading (so SSL status is not yet available) or
562 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58563 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
564
565 site_connection_details_.assign(l10n_util::GetStringFUTF16(
566 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
567 subject_name));
estarka3121f6b2015-09-18 21:15:59568 } else if (security_info.security_bits < 0) {
569 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20570 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59571 } else if (security_info.security_bits == 0) {
esecklercac56b62016-11-16 13:49:44572 DCHECK_NE(security_info.security_level, security_state::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20573 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
574 site_connection_details_.assign(l10n_util::GetStringFUTF16(
575 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
576 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20577 } else {
578 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22579
lgarron3e2c33e2016-08-25 06:33:43580 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22581 site_connection_details_.assign(l10n_util::GetStringFUTF16(
582 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
583 subject_name));
584 } else {
585 site_connection_details_.assign(l10n_util::GetStringFUTF16(
586 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
587 subject_name));
588 }
589
estark00e83f12016-08-19 18:24:04590 bool ran_insecure_content = false;
591 bool displayed_insecure_content = false;
592 CheckForInsecureContent(security_info, &displayed_insecure_content,
593 &ran_insecure_content);
594 if (ran_insecure_content || displayed_insecure_content) {
595 site_connection_status_ =
596 ran_insecure_content
597 ? SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE
598 : SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
[email protected]03ef4b2a2012-03-06 15:04:20599 site_connection_details_.assign(l10n_util::GetStringFUTF16(
600 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
601 site_connection_details_,
estark00e83f12016-08-19 18:24:04602 l10n_util::GetStringUTF16(
603 ran_insecure_content
604 ? IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR
605 : IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
[email protected]03ef4b2a2012-03-06 15:04:20606 }
607 }
608
avi655876a2015-12-25 07:18:15609 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59610 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
611 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20612 int ssl_version =
estarka3121f6b2015-09-18 21:15:59613 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20614 const char* ssl_version_str;
615 net::SSLVersionToString(&ssl_version_str, ssl_version);
616 site_connection_details_ += ASCIIToUTF16("\n\n");
617 site_connection_details_ += l10n_util::GetStringFUTF16(
618 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION,
619 ASCIIToUTF16(ssl_version_str));
620
[email protected]03ef4b2a2012-03-06 15:04:20621 bool no_renegotiation =
estarka3121f6b2015-09-18 21:15:59622 (security_info.connection_status &
623 net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0;
[email protected]03ef4b2a2012-03-06 15:04:20624 const char *key_exchange, *cipher, *mac;
davidben56a8aece2016-10-14 18:20:56625 bool is_aead, is_tls13;
626 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
627 &is_tls13, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20628
629 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57630 if (is_aead) {
davidben56a8aece2016-10-14 18:20:56631 if (is_tls13) {
632 // For TLS 1.3 ciphers, report the group (historically, curve) as the
633 // key exchange.
634 key_exchange = SSL_get_curve_name(security_info.key_exchange_group);
635 if (!key_exchange) {
636 NOTREACHED();
637 key_exchange = "";
638 }
639 }
[email protected]b6c1d9e82013-06-12 17:26:57640 site_connection_details_ += l10n_util::GetStringFUTF16(
641 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
642 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
643 } else {
644 site_connection_details_ += l10n_util::GetStringFUTF16(
645 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS,
646 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
647 }
[email protected]03ef4b2a2012-03-06 15:04:20648
agl078d2102014-10-20 22:03:22649 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 &&
estark00e83f12016-08-19 18:24:04650 site_connection_status_ <
651 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE) {
agl078d2102014-10-20 22:03:22652 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
653 }
654
[email protected]03ef4b2a2012-03-06 15:04:20655 if (no_renegotiation) {
656 site_connection_details_ += ASCIIToUTF16("\n\n");
657 site_connection_details_ += l10n_util::GetStringUTF16(
658 IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE);
659 }
660 }
[email protected]e583f752012-08-30 13:26:21661
[email protected]71cd5ef2014-08-13 21:22:04662 // Check if a user decision has been made to allow or deny certificates with
663 // errors on this site.
664 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50665 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04666 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40667 // Only show an SSL decision revoke button if the user has chosen to bypass
668 // SSL host errors for this host in the past.
669 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]71cd5ef2014-08-13 21:22:04670
palmer82b1f7b2015-09-17 19:20:41671 // By default select the Permissions Tab that displays all the site
672 // permissions. In case of a connection error or an issue with the certificate
673 // presented by the website, select the Connection Tab to draw the user's
674 // attention to the issue. If the site does not provide a certificate because
675 // it was loaded over an unencrypted connection, don't select the Connection
676 // Tab.
[email protected]e583f752012-08-30 13:26:21677 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS;
678 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR ||
estark00e83f12016-08-19 18:24:04679 site_connection_status_ ==
680 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE ||
681 site_connection_status_ ==
682 SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE ||
[email protected]e583f752012-08-30 13:26:21683 site_identity_status_ == SITE_IDENTITY_STATUS_ERROR ||
[email protected]eaf3f322013-04-25 21:53:59684 site_identity_status_ == SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN ||
rsleevi4f8012722014-09-30 01:28:01685 site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT ||
686 site_identity_status_ ==
lgarroncc53de22015-10-05 23:03:17687 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR ||
688 site_identity_status_ ==
689 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR) {
[email protected]e583f752012-08-30 13:26:21690 tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION;
lgarron04a93502014-11-04 22:25:04691 RecordWebsiteSettingsAction(
692 WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY);
693 }
palmer82b1f7b2015-09-17 19:20:41694
[email protected]e583f752012-08-30 13:26:21695 ui_->SetSelectedTab(tab_id);
[email protected]03ef4b2a2012-03-06 15:04:20696}
[email protected]0b9fdd72012-04-04 10:00:33697
[email protected]df818272012-04-20 13:10:50698void WebsiteSettings::PresentSitePermissions() {
699 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38700 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50701
702 WebsiteSettingsUI::PermissionInfo permission_info;
703 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
704 permission_info.type = kPermissionType[i];
705
mgiucaa319f212016-01-14 03:30:11706 if (!ShouldShowPermission(permission_info.type))
707 continue;
708
[email protected]df818272012-04-20 13:10:50709 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32710 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
711 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21712 DCHECK(value.get());
jdoerriedc72ee942016-12-07 15:43:28713 if (value->GetType() == base::Value::Type::INTEGER) {
sashab2b2a314f2015-01-17 06:42:21714 permission_info.setting =
715 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26716 } else {
sashab2b2a314f2015-01-17 06:42:21717 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26718 }
719
[email protected]8bdf45c32012-08-04 00:12:55720 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28721 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50722
[email protected]b1d113d2012-06-27 21:27:34723 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21724 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34725 permission_info.default_setting = permission_info.setting;
726 permission_info.setting = CONTENT_SETTING_DEFAULT;
727 } else {
728 permission_info.default_setting =
729 content_settings_->GetDefaultContentSetting(permission_info.type,
730 NULL);
[email protected]df818272012-04-20 13:10:50731 }
palmer0da10b32015-02-11 00:42:19732
palmer64a099982016-03-09 21:26:11733 if (permission_info.type == CONTENT_SETTINGS_TYPE_KEYGEN &&
734 (permission_info.setting == CONTENT_SETTING_DEFAULT ||
735 permission_info.setting == permission_info.default_setting) &&
736 !tab_specific_content_settings()->IsContentBlocked(
737 permission_info.type)) {
738 continue;
palmer0da10b32015-02-11 00:42:19739 }
palmer64a099982016-03-09 21:26:11740 permission_info_list.push_back(permission_info);
[email protected]df818272012-04-20 13:10:50741 }
742
reillyg85f57db2016-01-12 23:14:38743 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
744 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10745 const GURL origin = site_url_.GetOrigin();
746 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32747 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38748 chosen_object_info_list.push_back(
avi09dd4d02016-10-14 20:40:09749 base::MakeUnique<WebsiteSettingsUI::ChosenObjectInfo>(
750 ui_info, std::move(object)));
reillyg85f57db2016-01-12 23:14:38751 }
752 }
753
avi09dd4d02016-10-14 20:40:09754 ui_->SetPermissionInfo(permission_info_list,
755 std::move(chosen_object_info_list));
[email protected]0b9fdd72012-04-04 10:00:33756}
757
[email protected]df818272012-04-20 13:10:50758void WebsiteSettings::PresentSiteData() {
759 CookieInfoList cookie_info_list;
vabrbab3ffcb2016-10-04 10:08:10760 const LocalSharedObjectsContainer& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34761 tab_specific_content_settings()->allowed_local_shared_objects();
vabrbab3ffcb2016-10-04 10:08:10762 const LocalSharedObjectsContainer& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34763 tab_specific_content_settings()->blocked_local_shared_objects();
764
765 // Add first party cookie and site data counts.
[email protected]df818272012-04-20 13:10:50766 WebsiteSettingsUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34767 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
768 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15769 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34770 cookie_info_list.push_back(cookie_info);
771
772 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34773 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
774 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15775 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50776 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33777
[email protected]df818272012-04-20 13:10:50778 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33779}
[email protected]16de6de2012-04-04 12:24:14780
[email protected]24c8818c2012-04-25 09:57:41781void WebsiteSettings::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04782 // After initialization the status about the site's connection and its
783 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41784 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
785 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
786 WebsiteSettingsUI::IdentityInfo info;
787 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
788 info.site_identity = UTF16ToUTF8(organization_name());
789 else
jshin1fb76462016-04-05 22:13:03790 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41791
792 info.connection_status = site_connection_status_;
793 info.connection_status_description =
794 UTF16ToUTF8(site_connection_details_);
795 info.identity_status = site_identity_status_;
796 info.identity_status_description =
797 UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21798 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04799 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
[email protected]24c8818c2012-04-25 09:57:41800 ui_->SetIdentityInfo(info);
801}