blob: 05f6f8efc74f3a54109306785d1132b217f6ecb2 [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
lgarron617a30f32017-03-24 21:42:075#include "chrome/browser/ui/page_info/page_info.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"
patricialor7131c1fe2017-04-07 01:25:5235#include "chrome/browser/permissions/permission_decision_auto_blocker.h"
patricialor2a4f41a2017-03-08 02:52:5636#include "chrome/browser/permissions/permission_manager.h"
37#include "chrome/browser/permissions/permission_result.h"
tsergeantf1e89352016-01-15 20:34:5438#include "chrome/browser/permissions/permission_uma_util.h"
39#include "chrome/browser/permissions/permission_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2040#include "chrome/browser/profiles/profile.h"
[email protected]71cd5ef2014-08-13 21:22:0441#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
42#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
lgarron617a30f32017-03-24 21:42:0743#include "chrome/browser/ui/page_info/page_info_ui.h"
reillyg85f57db2016-01-12 23:14:3844#include "chrome/browser/usb/usb_chooser_context.h"
45#include "chrome/browser/usb/usb_chooser_context_factory.h"
[email protected]71cd5ef2014-08-13 21:22:0446#include "chrome/common/chrome_switches.h"
jsbellddb849e2015-08-27 00:12:5647#include "chrome/common/url_constants.h"
thestig884a1602014-08-27 01:29:3948#include "chrome/grit/chromium_strings.h"
49#include "chrome/grit/generated_resources.h"
reillyg85f57db2016-01-12 23:14:3850#include "chrome/grit/theme_resources.h"
mukai8eaec822014-10-25 17:53:1651#include "components/content_settings/core/browser/content_settings_utils.h"
52#include "components/content_settings/core/browser/host_content_settings_map.h"
palmer0da10b32015-02-11 00:42:1953#include "components/content_settings/core/common/content_settings.h"
vasiliif62dbf92014-09-05 10:23:1354#include "components/content_settings/core/common/content_settings_pattern.h"
nzolghadrd87a308d2016-12-07 15:45:5655#include "components/rappor/public/rappor_utils.h"
56#include "components/rappor/rappor_service_impl.h"
felt2493b4452015-09-17 20:33:5957#include "components/ssl_errors/error_info.h"
thestig4a2e88e2016-08-27 23:23:5158#include "components/strings/grit/components_chromium_strings.h"
59#include "components/strings/grit/components_strings.h"
melandory7be36d312017-03-29 15:51:1260#include "components/subresource_filter/core/browser/subresource_filter_features.h"
palmer153af982015-09-15 02:04:1961#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3362#include "content/public/browser/browser_thread.h"
[email protected]eb2140c2013-07-29 12:37:3463#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2064#include "content/public/common/url_constants.h"
[email protected]6e7845ae2013-03-29 21:48:1165#include "net/cert/cert_status_flags.h"
66#include "net/cert/x509_certificate.h"
[email protected]536fd0b2013-03-14 17:41:5767#include "net/ssl/ssl_cipher_suite_names.h"
68#include "net/ssl/ssl_connection_status_flags.h"
tfarina29a3a1742016-10-28 18:47:3369#include "third_party/boringssl/src/include/openssl/ssl.h"
[email protected]03ef4b2a2012-03-06 15:04:2070#include "ui/base/l10n/l10n_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2071
[email protected]24a9f1c92013-11-13 12:33:3772#if defined(OS_CHROMEOS)
73#include "chrome/browser/chromeos/policy/policy_cert_service.h"
74#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
75#endif
76
estade3feb83f2015-09-01 23:00:4977#if !defined(OS_ANDROID)
mgiucaa319f212016-01-14 03:30:1178#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
lgarron617a30f32017-03-24 21:42:0779#include "chrome/browser/ui/page_info/page_info_infobar_delegate.h"
estade3feb83f2015-09-01 23:00:4980#endif
81
[email protected]ab6df3b12013-12-24 23:32:2682using base::ASCIIToUTF16;
83using base::UTF8ToUTF16;
[email protected]f729d7a2013-12-26 07:07:5684using base::UTF16ToUTF8;
[email protected]0b9fdd72012-04-04 10:00:3385using content::BrowserThread;
86
87namespace {
88
jww1ed8ea72014-09-02 20:43:2589// Events for UMA. Do not reorder or change!
90enum SSLCertificateDecisionsDidRevoke {
91 USER_CERT_DECISIONS_NOT_REVOKED = 0,
92 USER_CERT_DECISIONS_REVOKED,
93 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM
94};
95
lgarron617a30f32017-03-24 21:42:0796// The list of content settings types to display on the Page Info UI. THE
palmer0da10b32015-02-11 00:42:1997// ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, email
98// [email protected].
[email protected]0b9fdd72012-04-04 10:00:3399ContentSettingsType kPermissionType[] = {
sashab2b2a314f2015-01-17 06:42:21100 CONTENT_SETTINGS_TYPE_GEOLOCATION,
sashab2b2a314f2015-01-17 06:42:21101 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
102 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
palmer0da10b32015-02-11 00:42:19103 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
palmer7715e332016-05-27 00:41:19104 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
lshange085f202016-06-14 01:25:08105#if !defined(OS_ANDROID)
palmer7715e332016-05-27 00:41:19106 CONTENT_SETTINGS_TYPE_PLUGINS,
107 CONTENT_SETTINGS_TYPE_IMAGES,
lshange085f202016-06-14 01:25:08108#endif
palmer7715e332016-05-27 00:41:19109 CONTENT_SETTINGS_TYPE_POPUPS,
nsatragno670fe922016-04-08 14:10:50110 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
palmer7715e332016-05-27 00:41:19111 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,
melandory7be36d312017-03-29 15:51:12114 CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER,
[email protected]0b9fdd72012-04-04 10:00:33115};
116
lgarron617a30f32017-03-24 21:42:07117// Determines whether to show permission |type| in the Page Info UI. Only
mgiucaa319f212016-01-14 03:30:11118// applies to permissions listed in |kPermissionType|.
119bool ShouldShowPermission(ContentSettingsType type) {
mgiucaa319f212016-01-14 03:30:11120#if !defined(OS_ANDROID)
finnur46cafd42016-09-22 10:27:17121 // Autoplay is Android-only at the moment.
mgiuca273b9672016-11-11 02:22:20122 if (type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
mgiuca0f3e1f72016-05-13 01:56:27123 return false;
mgiucaa319f212016-01-14 03:30:11124#endif
125
melandory7be36d312017-03-29 15:51:12126 if (type == CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER) {
127 return base::FeatureList::IsEnabled(
128 subresource_filter::kSafeBrowsingSubresourceFilterExperimentalUI);
129 }
130
mgiucaa319f212016-01-14 03:30:11131 return true;
132}
133
esecklercac56b62016-11-16 13:49:44134void CheckContentStatus(security_state::ContentStatus content_status,
estark00e83f12016-08-19 18:24:04135 bool* displayed,
136 bool* ran) {
137 switch (content_status) {
esecklercac56b62016-11-16 13:49:44138 case security_state::CONTENT_STATUS_DISPLAYED:
estark00e83f12016-08-19 18:24:04139 *displayed = true;
140 break;
esecklercac56b62016-11-16 13:49:44141 case security_state::CONTENT_STATUS_RAN:
estark00e83f12016-08-19 18:24:04142 *ran = true;
143 break;
esecklercac56b62016-11-16 13:49:44144 case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN:
estark00e83f12016-08-19 18:24:04145 *displayed = true;
146 *ran = true;
147 break;
esecklercac56b62016-11-16 13:49:44148 case security_state::CONTENT_STATUS_UNKNOWN:
149 case security_state::CONTENT_STATUS_NONE:
estark00e83f12016-08-19 18:24:04150 break;
151 }
152}
153
elawrenceb2ac2a232017-03-27 21:46:25154// If the |security_info| indicates that mixed content or certificate errors
155// were present, update |connection_status| and |connection_details|.
156void ReportAnyInsecureContent(const security_state::SecurityInfo& security_info,
157 PageInfo::SiteConnectionStatus& connection_status,
158 base::string16& connection_details) {
159 bool displayed_insecure_content = false;
160 bool ran_insecure_content = false;
161 CheckContentStatus(security_info.mixed_content_status,
162 &displayed_insecure_content, &ran_insecure_content);
163 // Only note subresources with certificate errors if the main resource was
164 // loaded without major certificate errors. If the main resource had a
165 // certificate error, then it would not be that useful (and could
166 // potentially be confusing) to warn about subresources that had certificate
167 // errors too.
168 if (!net::IsCertStatusError(security_info.cert_status) ||
169 net::IsCertStatusMinorError(security_info.cert_status)) {
170 CheckContentStatus(security_info.content_with_cert_errors_status,
171 &displayed_insecure_content, &ran_insecure_content);
172 }
173
174 // Only one insecure content warning is displayed; show the most severe.
175 if (ran_insecure_content) {
176 connection_status =
177 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE;
178 connection_details.assign(l10n_util::GetStringFUTF16(
179 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, connection_details,
180 l10n_util::GetStringUTF16(
181 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR)));
estark00e83f12016-08-19 18:24:04182 return;
183 }
elawrenceb2ac2a232017-03-27 21:46:25184 if (security_info.contained_mixed_form) {
185 connection_status = PageInfo::SITE_CONNECTION_STATUS_INSECURE_FORM_ACTION;
186 connection_details.assign(l10n_util::GetStringFUTF16(
187 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, connection_details,
188 l10n_util::GetStringUTF16(
189 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_FORM_WARNING)));
190 return;
191 }
192 if (displayed_insecure_content) {
193 connection_status =
194 PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
195 connection_details.assign(l10n_util::GetStringFUTF16(
196 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, connection_details,
197 l10n_util::GetStringUTF16(
198 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
199 }
estark00e83f12016-08-19 18:24:04200}
201
estarkfcfccdb82016-11-14 02:17:29202void GetSiteIdentityByMaliciousContentStatus(
esecklercac56b62016-11-16 13:49:44203 security_state::MaliciousContentStatus malicious_content_status,
lgarron617a30f32017-03-24 21:42:07204 PageInfo::SiteIdentityStatus* status,
estarkfcfccdb82016-11-14 02:17:29205 base::string16* details) {
206 switch (malicious_content_status) {
esecklercac56b62016-11-16 13:49:44207 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
estarkfcfccdb82016-11-14 02:17:29208 NOTREACHED();
209 break;
esecklercac56b62016-11-16 13:49:44210 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
lgarron617a30f32017-03-24 21:42:07211 *status = PageInfo::SITE_IDENTITY_STATUS_MALWARE;
lgarron1a6300d2017-03-18 03:33:04212 *details = l10n_util::GetStringUTF16(IDS_PAGEINFO_MALWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29213 break;
esecklercac56b62016-11-16 13:49:44214 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
lgarron617a30f32017-03-24 21:42:07215 *status = PageInfo::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
lgarron1a6300d2017-03-18 03:33:04216 *details =
217 l10n_util::GetStringUTF16(IDS_PAGEINFO_SOCIAL_ENGINEERING_DETAILS);
estarkfcfccdb82016-11-14 02:17:29218 break;
esecklercac56b62016-11-16 13:49:44219 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
lgarron617a30f32017-03-24 21:42:07220 *status = PageInfo::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
lgarron1a6300d2017-03-18 03:33:04221 *details =
222 l10n_util::GetStringUTF16(IDS_PAGEINFO_UNWANTED_SOFTWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29223 break;
224 }
225}
226
jshin1fb76462016-04-05 22:13:03227base::string16 GetSimpleSiteName(const GURL& url) {
benwells2337b8102016-04-20 01:53:53228 return url_formatter::FormatUrlForSecurityDisplay(
229 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
palmer153af982015-09-15 02:04:19230}
231
reillyg85f57db2016-01-12 23:14:38232ChooserContextBase* GetUsbChooserContext(Profile* profile) {
233 return UsbChooserContextFactory::GetForProfile(profile);
234}
235
236// The list of chooser types that need to display entries in the Website
237// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
238// email [email protected].
lgarron617a30f32017-03-24 21:42:07239PageInfo::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52240 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
lgarron617a30f32017-03-24 21:42:07241 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_PAGE_INFO_USB_DEVICE_LABEL,
242 IDS_PAGE_INFO_DELETE_USB_DEVICE, "name"},
reillyg85f57db2016-01-12 23:14:38243};
244
[email protected]0b9fdd72012-04-04 10:00:33245} // namespace
246
lgarron617a30f32017-03-24 21:42:07247PageInfo::PageInfo(PageInfoUI* ui,
248 Profile* profile,
249 TabSpecificContentSettings* tab_specific_content_settings,
250 content::WebContents* web_contents,
251 const GURL& url,
252 const security_state::SecurityInfo& security_info)
[email protected]df818272012-04-20 13:10:50253 : TabSpecificContentSettings::SiteDataObserver(
254 tab_specific_content_settings),
dominicknbdd53b5f2016-09-28 01:08:13255 content::WebContentsObserver(web_contents),
[email protected]df818272012-04-20 13:10:50256 ui_(ui),
[email protected]66f157312012-08-01 13:50:26257 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33258 site_url_(url),
259 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]03ef4b2a2012-03-06 15:04:20260 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
alshabalin5e894c12016-10-25 06:47:46261 show_ssl_decision_revoke_button_(false),
peconn5100d432015-09-16 12:03:08262 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04263 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25264 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19265 did_revoke_user_ssl_decisions_(false),
estark8d67cd7a2016-10-24 05:06:41266 profile_(profile),
esecklercac56b62016-11-16 13:49:44267 security_level_(security_state::NONE) {
estarka3121f6b2015-09-18 21:15:59268 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33269
270 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50271 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41272 PresentSiteIdentity();
[email protected]e22d64f2012-09-10 09:03:23273
lgarron617a30f32017-03-24 21:42:07274 // Every time the Page Info UI is opened a |PageInfo| object is
275 // created. So this counts how ofter the Page Info UI is opened.
276 RecordPageInfoAction(PAGE_INFO_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20277}
278
lgarron617a30f32017-03-24 21:42:07279PageInfo::~PageInfo() {}
[email protected]03ef4b2a2012-03-06 15:04:20280
lgarron617a30f32017-03-24 21:42:07281void PageInfo::RecordPageInfoAction(PageInfoAction action) {
282 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04283
estark8d67cd7a2016-10-24 05:06:41284 std::string histogram_name;
palmeree0e5af2015-06-05 03:10:40285
estark8d67cd7a2016-10-24 05:06:41286 if (site_url_.SchemeIsCryptographic()) {
esecklercac56b62016-11-16 13:49:44287 if (security_level_ == security_state::SECURE ||
288 security_level_ == security_state::EV_SECURE) {
estark8d67cd7a2016-10-24 05:06:41289 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Valid",
lgarron617a30f32017-03-24 21:42:07290 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44291 } else if (security_level_ == security_state::NONE) {
estark8d67cd7a2016-10-24 05:06:41292 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded",
lgarron617a30f32017-03-24 21:42:07293 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44294 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41295 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07296 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41297 }
298 return;
299 }
300
esecklercac56b62016-11-16 13:49:44301 if (security_level_ == security_state::HTTP_SHOW_WARNING) {
estark8d67cd7a2016-10-24 05:06:41302 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning",
lgarron617a30f32017-03-24 21:42:07303 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44304 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41305 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07306 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41307 } else {
308 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral",
lgarron617a30f32017-03-24 21:42:07309 action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04310 }
311}
312
lgarron617a30f32017-03-24 21:42:07313void PageInfo::OnSitePermissionChanged(ContentSettingsType type,
314 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23315 // Count how often a permission for a specific content type is changed using
lgarron617a30f32017-03-24 21:42:07316 // the Page Info UI.
raymes4a13d432015-09-08 00:44:07317 size_t num_values;
318 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
dchengf6f4e4942017-03-30 23:55:57319 UMA_HISTOGRAM_EXACT_LINEAR("WebsiteSettings.OriginInfo.PermissionChanged",
320 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56321
322 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
dchengf6f4e4942017-03-30 23:55:57323 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56324 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07325 num_values);
tommycli34cf29bf2016-09-08 05:46:25326
327 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
328 rappor::SampleDomainAndRegistryFromGURL(
329 g_browser_process->rappor_service(),
330 "ContentSettings.Plugins.AddedAllowException", site_url_);
331 }
sashab9debecd2014-12-18 04:15:56332 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
dchengf6f4e4942017-03-30 23:55:57333 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56334 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07335 num_values);
sashab9debecd2014-12-18 04:15:56336 }
[email protected]e22d64f2012-09-10 09:03:23337
lgarron04a93502014-11-04 22:25:04338 // This is technically redundant given the histogram above, but putting the
339 // total count of permission changes in another histogram makes it easier to
lgarron617a30f32017-03-24 21:42:07340 // compare it against other kinds of actions in PageInfo[PopupView].
341 RecordPageInfoAction(PAGE_INFO_CHANGED_PERMISSION);
lgarron04a93502014-11-04 22:25:04342
stefanocs8b3490cc2016-07-28 05:32:52343 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
patricialor7131c1fe2017-04-07 01:25:52344 profile_, site_url_, site_url_, type, PermissionSourceUI::OIB);
stefanocs8b3490cc2016-07-28 05:32:52345
patricialor7131c1fe2017-04-07 01:25:52346 // The permission may have been blocked due to being under embargo, so if it
347 // was changed away from BLOCK, clear embargo status if it exists.
348 if (setting != CONTENT_SETTING_BLOCK) {
349 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveEmbargoByUrl(
350 site_url_, type);
351 }
raymesfbaaaaa2015-11-10 02:20:40352 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
353 setting);
[email protected]df818272012-04-20 13:10:50354
[email protected]66f157312012-08-01 13:50:26355 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24356
357 // Refresh the UI to reflect the new setting.
358 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50359}
360
lgarron617a30f32017-03-24 21:42:07361void PageInfo::OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info,
362 const base::DictionaryValue& object) {
reillyg85f57db2016-01-12 23:14:38363 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
364 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10365 const GURL origin = site_url_.GetOrigin();
366 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38367
368 show_info_bar_ = true;
369
370 // Refresh the UI to reflect the changed settings.
371 PresentSitePermissions();
372}
373
lgarron617a30f32017-03-24 21:42:07374void PageInfo::OnSiteDataAccessed() {
[email protected]df818272012-04-20 13:10:50375 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33376}
377
lgarron617a30f32017-03-24 21:42:07378void PageInfo::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49379#if defined(OS_ANDROID)
380 NOTREACHED();
381#else
dominicknbdd53b5f2016-09-28 01:08:13382 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
palmerf2cba0d2015-08-27 23:15:06383 InfoBarService* infobar_service =
dominicknbdd53b5f2016-09-28 01:08:13384 InfoBarService::FromWebContents(web_contents());
palmerf2cba0d2015-08-27 23:15:06385 if (infobar_service)
lgarron617a30f32017-03-24 21:42:07386 PageInfoInfoBarDelegate::Create(infobar_service);
palmerf2cba0d2015-08-27 23:15:06387 }
jww1ed8ea72014-09-02 20:43:25388
389 SSLCertificateDecisionsDidRevoke user_decision =
390 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
391 : USER_CERT_DECISIONS_NOT_REVOKED;
392
393 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
394 user_decision,
395 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49396#endif
jww1ed8ea72014-09-02 20:43:25397}
398
lgarron617a30f32017-03-24 21:42:07399void PageInfo::OnRevokeSSLErrorBypassButtonPressed() {
jww1ed8ea72014-09-02 20:43:25400 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29401 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
402 site_url().host());
jww1ed8ea72014-09-02 20:43:25403 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26404}
405
lgarron617a30f32017-03-24 21:42:07406void PageInfo::Init(const GURL& url,
407 const security_state::SecurityInfo& security_info) {
meacerde53fcff2016-10-12 19:21:57408#if !defined(OS_ANDROID) && !defined(OS_IOS)
409 // On desktop, internal URLs aren't handled by this class. Instead, a
410 // custom and simpler popup is shown.
411 DCHECK(!url.SchemeIs(content::kChromeUIScheme) &&
412 !url.SchemeIs(content::kChromeDevToolsScheme) &&
413 !url.SchemeIs(content::kViewSourceScheme) &&
414 !url.SchemeIs(content_settings::kExtensionScheme));
415#endif
416
sashab97894ce2014-10-22 10:08:33417 bool isChromeUINativeScheme = false;
zpengdb4a58e2017-01-10 17:40:32418#if defined(OS_ANDROID)
sashab97894ce2014-10-22 10:08:33419 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
420#endif
421
estark8d67cd7a2016-10-24 05:06:41422 security_level_ = security_info.security_level;
423
upendrag.gowda60886a6e2015-10-31 05:51:09424 if (url.SchemeIs(url::kAboutScheme)) {
425 // All about: URLs except about:blank are redirected.
426 DCHECK_EQ(url::kAboutBlankURL, url.spec());
427 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
428 site_identity_details_ =
429 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
430 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
431 site_connection_details_ = l10n_util::GetStringFUTF16(
432 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
433 UTF8ToUTF16(url.spec()));
434 return;
435 }
436
437 if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) {
[email protected]03ef4b2a2012-03-06 15:04:20438 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
439 site_identity_details_ =
440 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
441 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
442 return;
443 }
444
[email protected]03ef4b2a2012-03-06 15:04:20445 // Identity section.
jam8ae7cad2016-09-08 23:55:21446 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11447
estarkfcfccdb82016-11-14 02:17:29448 if (security_info.malicious_content_status !=
esecklercac56b62016-11-16 13:49:44449 security_state::MALICIOUS_CONTENT_STATUS_NONE) {
estarkfcfccdb82016-11-14 02:17:29450 // The site has been flagged by Safe Browsing as dangerous.
451 GetSiteIdentityByMaliciousContentStatus(
452 security_info.malicious_content_status, &site_identity_status_,
453 &site_identity_details_);
454 } else if (certificate_ &&
455 (!net::IsCertStatusError(security_info.cert_status) ||
456 net::IsCertStatusMinorError(security_info.cert_status))) {
457 // HTTPS with no or minor errors.
estarka3121f6b2015-09-18 21:15:59458 if (security_info.security_level ==
esecklercac56b62016-11-16 13:49:44459 security_state::SECURE_WITH_POLICY_INSTALLED_CERT) {
[email protected]eaf3f322013-04-25 21:53:59460 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37461 site_identity_details_ = l10n_util::GetStringFUTF16(
462 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59463 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20464 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21465 base::string16 issuer_name(
466 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20467 if (issuer_name.empty()) {
468 issuer_name.assign(l10n_util::GetStringUTF16(
469 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
470 }
[email protected]94c74b42013-12-02 15:19:49471
[email protected]03ef4b2a2012-03-06 15:04:20472 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39473 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20474
475 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59476 if (security_info.cert_status &
477 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20478 site_identity_details_ += l10n_util::GetStringUTF16(
479 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59480 } else if (security_info.cert_status &
481 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20482 site_identity_details_ += l10n_util::GetStringUTF16(
483 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
484 } else {
485 NOTREACHED() << "Need to specify string for this warning";
486 }
[email protected]03ef4b2a2012-03-06 15:04:20487 } else {
estarkcf305562016-11-15 03:45:39488 // No major or minor errors.
estarka3121f6b2015-09-18 21:15:59489 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01490 // EV HTTPS page.
estarkcf305562016-11-15 03:45:39491 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
jam8ae7cad2016-09-08 23:55:21492 DCHECK(!certificate_->subject().organization_names.empty());
493 organization_name_ =
494 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01495 // An EV Cert is required to have a city (localityName) and country but
496 // state is "if any".
jam8ae7cad2016-09-08 23:55:21497 DCHECK(!certificate_->subject().locality_name.empty());
498 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01499 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21500 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01501 locality = l10n_util::GetStringFUTF16(
502 IDS_PAGEINFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21503 UTF8ToUTF16(certificate_->subject().locality_name),
504 UTF8ToUTF16(certificate_->subject().state_or_province_name),
505 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01506 } else {
507 locality = l10n_util::GetStringFUTF16(
508 IDS_PAGEINFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21509 UTF8ToUTF16(certificate_->subject().locality_name),
510 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01511 }
jam8ae7cad2016-09-08 23:55:21512 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01513 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39514 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED,
jam8ae7cad2016-09-08 23:55:21515 UTF8ToUTF16(certificate_->subject().organization_names[0]),
estarkcf305562016-11-15 03:45:39516 locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01517 } else {
518 // Non-EV OK HTTPS page.
estarkcf305562016-11-15 03:45:39519 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
rsleevi4f8012722014-09-30 01:28:01520 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21521 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01522 if (issuer_name.empty()) {
523 issuer_name.assign(l10n_util::GetStringUTF16(
524 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
525 }
[email protected]94c74b42013-12-02 15:19:49526
rsleevi4f8012722014-09-30 01:28:01527 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39528 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
rsleevi4f8012722014-09-30 01:28:01529 }
elawrencebe87bd62017-01-10 16:08:59530 if (security_info.sha1_in_chain) {
531 site_identity_status_ =
532 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM;
533 site_identity_details_ +=
534 UTF8ToUTF16("\n\n") +
535 l10n_util::GetStringUTF16(
536 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM);
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");
lgarron1a6300d2017-03-18 03:33:04559 site_identity_details_ +=
560 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
[email protected]03ef4b2a2012-03-06 15:04:20561 }
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) {
esecklercac56b62016-11-16 13:49:44588 DCHECK_NE(security_info.security_level, security_state::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(
lgarron1a6300d2017-03-18 03:33:04598 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, subject_name));
Adam Langley71c2b59b2014-11-13 00:34:22599 } else {
600 site_connection_details_.assign(l10n_util::GetStringFUTF16(
601 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
602 subject_name));
603 }
604
elawrenceb2ac2a232017-03-27 21:46:25605 ReportAnyInsecureContent(security_info, site_connection_status_,
606 site_connection_details_);
[email protected]03ef4b2a2012-03-06 15:04:20607 }
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(
lgarron1a6300d2017-03-18 03:33:04618 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, ASCIIToUTF16(ssl_version_str));
[email protected]03ef4b2a2012-03-06 15:04:20619
[email protected]03ef4b2a2012-03-06 15:04:20620 const char *key_exchange, *cipher, *mac;
davidben56a8aece2016-10-14 18:20:56621 bool is_aead, is_tls13;
622 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
623 &is_tls13, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20624
625 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57626 if (is_aead) {
davidben56a8aece2016-10-14 18:20:56627 if (is_tls13) {
628 // For TLS 1.3 ciphers, report the group (historically, curve) as the
629 // key exchange.
630 key_exchange = SSL_get_curve_name(security_info.key_exchange_group);
631 if (!key_exchange) {
632 NOTREACHED();
633 key_exchange = "";
634 }
635 }
[email protected]b6c1d9e82013-06-12 17:26:57636 site_connection_details_ += l10n_util::GetStringFUTF16(
637 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
638 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
639 } else {
640 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04641 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, ASCIIToUTF16(cipher),
642 ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
[email protected]b6c1d9e82013-06-12 17:26:57643 }
[email protected]03ef4b2a2012-03-06 15:04:20644
agl078d2102014-10-20 22:03:22645 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 &&
estark00e83f12016-08-19 18:24:04646 site_connection_status_ <
647 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE) {
agl078d2102014-10-20 22:03:22648 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
649 }
[email protected]03ef4b2a2012-03-06 15:04:20650 }
[email protected]e583f752012-08-30 13:26:21651
[email protected]71cd5ef2014-08-13 21:22:04652 // Check if a user decision has been made to allow or deny certificates with
653 // errors on this site.
654 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50655 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04656 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40657 // Only show an SSL decision revoke button if the user has chosen to bypass
658 // SSL host errors for this host in the past.
659 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]03ef4b2a2012-03-06 15:04:20660}
[email protected]0b9fdd72012-04-04 10:00:33661
lgarron617a30f32017-03-24 21:42:07662void PageInfo::PresentSitePermissions() {
[email protected]df818272012-04-20 13:10:50663 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38664 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50665
lgarron617a30f32017-03-24 21:42:07666 PageInfoUI::PermissionInfo permission_info;
[email protected]df818272012-04-20 13:10:50667 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
668 permission_info.type = kPermissionType[i];
669
mgiucaa319f212016-01-14 03:30:11670 if (!ShouldShowPermission(permission_info.type))
671 continue;
672
[email protected]df818272012-04-20 13:10:50673 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32674 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
675 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21676 DCHECK(value.get());
jdoerriedc72ee942016-12-07 15:43:28677 if (value->GetType() == base::Value::Type::INTEGER) {
sashab2b2a314f2015-01-17 06:42:21678 permission_info.setting =
679 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26680 } else {
sashab2b2a314f2015-01-17 06:42:21681 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26682 }
683
[email protected]8bdf45c32012-08-04 00:12:55684 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28685 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50686
[email protected]b1d113d2012-06-27 21:27:34687 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21688 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34689 permission_info.default_setting = permission_info.setting;
690 permission_info.setting = CONTENT_SETTING_DEFAULT;
691 } else {
692 permission_info.default_setting =
693 content_settings_->GetDefaultContentSetting(permission_info.type,
694 NULL);
[email protected]df818272012-04-20 13:10:50695 }
palmer0da10b32015-02-11 00:42:19696
patricialor2a4f41a2017-03-08 02:52:56697 // For permissions that are still prompting the user and haven't been
698 // explicitly set by another source, check its embargo status.
699 if (PermissionUtil::IsPermission(permission_info.type) &&
700 permission_info.setting == CONTENT_SETTING_DEFAULT &&
701 permission_info.source ==
702 content_settings::SettingSource::SETTING_SOURCE_USER) {
703 // TODO(raymes): Use GetPermissionStatus() to retrieve information
704 // about *all* permissions once it has default behaviour implemented for
705 // ContentSettingTypes that aren't permissions.
706 PermissionResult permission_result =
707 PermissionManager::Get(profile_)->GetPermissionStatus(
708 permission_info.type, site_url_, site_url_);
709
710 // If under embargo, update |permission_info| to reflect that.
711 if (permission_result.content_setting == CONTENT_SETTING_BLOCK &&
712 (permission_result.source ==
713 PermissionStatusSource::MULTIPLE_DISMISSALS ||
714 permission_result.source ==
715 PermissionStatusSource::SAFE_BROWSING_BLACKLIST))
716 permission_info.setting = permission_result.content_setting;
717 }
718
palmer64a099982016-03-09 21:26:11719 permission_info_list.push_back(permission_info);
[email protected]df818272012-04-20 13:10:50720 }
721
reillyg85f57db2016-01-12 23:14:38722 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
723 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10724 const GURL origin = site_url_.GetOrigin();
725 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32726 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38727 chosen_object_info_list.push_back(
lgarron617a30f32017-03-24 21:42:07728 base::MakeUnique<PageInfoUI::ChosenObjectInfo>(ui_info,
729 std::move(object)));
reillyg85f57db2016-01-12 23:14:38730 }
731 }
732
avi09dd4d02016-10-14 20:40:09733 ui_->SetPermissionInfo(permission_info_list,
734 std::move(chosen_object_info_list));
[email protected]0b9fdd72012-04-04 10:00:33735}
736
lgarron617a30f32017-03-24 21:42:07737void PageInfo::PresentSiteData() {
[email protected]df818272012-04-20 13:10:50738 CookieInfoList cookie_info_list;
vabrbab3ffcb2016-10-04 10:08:10739 const LocalSharedObjectsContainer& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34740 tab_specific_content_settings()->allowed_local_shared_objects();
vabrbab3ffcb2016-10-04 10:08:10741 const LocalSharedObjectsContainer& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34742 tab_specific_content_settings()->blocked_local_shared_objects();
743
744 // Add first party cookie and site data counts.
lgarron617a30f32017-03-24 21:42:07745 PageInfoUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34746 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
747 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15748 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34749 cookie_info_list.push_back(cookie_info);
750
751 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34752 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
753 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15754 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50755 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33756
[email protected]df818272012-04-20 13:10:50757 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33758}
[email protected]16de6de2012-04-04 12:24:14759
lgarron617a30f32017-03-24 21:42:07760void PageInfo::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04761 // After initialization the status about the site's connection and its
762 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41763 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
764 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
lgarron617a30f32017-03-24 21:42:07765 PageInfoUI::IdentityInfo info;
[email protected]24c8818c2012-04-25 09:57:41766 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
767 info.site_identity = UTF16ToUTF8(organization_name());
768 else
jshin1fb76462016-04-05 22:13:03769 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41770
771 info.connection_status = site_connection_status_;
lgarron1a6300d2017-03-18 03:33:04772 info.connection_status_description = UTF16ToUTF8(site_connection_details_);
[email protected]24c8818c2012-04-25 09:57:41773 info.identity_status = site_identity_status_;
lgarron1a6300d2017-03-18 03:33:04774 info.identity_status_description = UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21775 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04776 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
[email protected]24c8818c2012-04-25 09:57:41777 ui_->SetIdentityInfo(info);
778}