blob: 63002bac6fb22c26dad497eca9ccf8b68dac2b46 [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"
patricialor2a4f41a2017-03-08 02:52:5635#include "chrome/browser/permissions/permission_manager.h"
36#include "chrome/browser/permissions/permission_result.h"
tsergeantf1e89352016-01-15 20:34:5437#include "chrome/browser/permissions/permission_uma_util.h"
38#include "chrome/browser/permissions/permission_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2039#include "chrome/browser/profiles/profile.h"
[email protected]71cd5ef2014-08-13 21:22:0440#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
41#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
lgarron617a30f32017-03-24 21:42:0742#include "chrome/browser/ui/page_info/page_info_ui.h"
reillyg85f57db2016-01-12 23:14:3843#include "chrome/browser/usb/usb_chooser_context.h"
44#include "chrome/browser/usb/usb_chooser_context_factory.h"
[email protected]71cd5ef2014-08-13 21:22:0445#include "chrome/common/chrome_switches.h"
jsbellddb849e2015-08-27 00:12:5646#include "chrome/common/url_constants.h"
thestig884a1602014-08-27 01:29:3947#include "chrome/grit/chromium_strings.h"
48#include "chrome/grit/generated_resources.h"
reillyg85f57db2016-01-12 23:14:3849#include "chrome/grit/theme_resources.h"
mukai8eaec822014-10-25 17:53:1650#include "components/content_settings/core/browser/content_settings_utils.h"
51#include "components/content_settings/core/browser/host_content_settings_map.h"
palmer0da10b32015-02-11 00:42:1952#include "components/content_settings/core/common/content_settings.h"
vasiliif62dbf92014-09-05 10:23:1353#include "components/content_settings/core/common/content_settings_pattern.h"
nzolghadrd87a308d2016-12-07 15:45:5654#include "components/rappor/public/rappor_utils.h"
55#include "components/rappor/rappor_service_impl.h"
felt2493b4452015-09-17 20:33:5956#include "components/ssl_errors/error_info.h"
thestig4a2e88e2016-08-27 23:23:5157#include "components/strings/grit/components_chromium_strings.h"
58#include "components/strings/grit/components_strings.h"
melandory7be36d312017-03-29 15:51:1259#include "components/subresource_filter/core/browser/subresource_filter_features.h"
palmer153af982015-09-15 02:04:1960#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3361#include "content/public/browser/browser_thread.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"
lgarron617a30f32017-03-24 21:42:0778#include "chrome/browser/ui/page_info/page_info_infobar_delegate.h"
estade3feb83f2015-09-01 23:00:4979#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;
85
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
lgarron617a30f32017-03-24 21:42:0795// The list of content settings types to display on the Page Info UI. THE
palmer0da10b32015-02-11 00:42:1996// 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_AUTOMATIC_DOWNLOADS,
finnur46cafd42016-09-22 10:27:17111 CONTENT_SETTINGS_TYPE_AUTOPLAY,
palmer7715e332016-05-27 00:41:19112 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
melandory7be36d312017-03-29 15:51:12113 CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER,
[email protected]0b9fdd72012-04-04 10:00:33114};
115
lgarron617a30f32017-03-24 21:42:07116// Determines whether to show permission |type| in the Page Info UI. Only
mgiucaa319f212016-01-14 03:30:11117// 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
melandory7be36d312017-03-29 15:51:12125 if (type == CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER) {
126 return base::FeatureList::IsEnabled(
127 subresource_filter::kSafeBrowsingSubresourceFilterExperimentalUI);
128 }
129
mgiucaa319f212016-01-14 03:30:11130 return true;
131}
132
esecklercac56b62016-11-16 13:49:44133void CheckContentStatus(security_state::ContentStatus content_status,
estark00e83f12016-08-19 18:24:04134 bool* displayed,
135 bool* ran) {
136 switch (content_status) {
esecklercac56b62016-11-16 13:49:44137 case security_state::CONTENT_STATUS_DISPLAYED:
estark00e83f12016-08-19 18:24:04138 *displayed = true;
139 break;
esecklercac56b62016-11-16 13:49:44140 case security_state::CONTENT_STATUS_RAN:
estark00e83f12016-08-19 18:24:04141 *ran = true;
142 break;
esecklercac56b62016-11-16 13:49:44143 case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN:
estark00e83f12016-08-19 18:24:04144 *displayed = true;
145 *ran = true;
146 break;
esecklercac56b62016-11-16 13:49:44147 case security_state::CONTENT_STATUS_UNKNOWN:
148 case security_state::CONTENT_STATUS_NONE:
estark00e83f12016-08-19 18:24:04149 break;
150 }
151}
152
elawrenceb2ac2a232017-03-27 21:46:25153// If the |security_info| indicates that mixed content or certificate errors
154// were present, update |connection_status| and |connection_details|.
155void ReportAnyInsecureContent(const security_state::SecurityInfo& security_info,
156 PageInfo::SiteConnectionStatus& connection_status,
157 base::string16& connection_details) {
158 bool displayed_insecure_content = false;
159 bool ran_insecure_content = false;
160 CheckContentStatus(security_info.mixed_content_status,
161 &displayed_insecure_content, &ran_insecure_content);
162 // Only note subresources with certificate errors if the main resource was
163 // loaded without major certificate errors. If the main resource had a
164 // certificate error, then it would not be that useful (and could
165 // potentially be confusing) to warn about subresources that had certificate
166 // errors too.
167 if (!net::IsCertStatusError(security_info.cert_status) ||
168 net::IsCertStatusMinorError(security_info.cert_status)) {
169 CheckContentStatus(security_info.content_with_cert_errors_status,
170 &displayed_insecure_content, &ran_insecure_content);
171 }
172
173 // Only one insecure content warning is displayed; show the most severe.
174 if (ran_insecure_content) {
175 connection_status =
176 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE;
177 connection_details.assign(l10n_util::GetStringFUTF16(
178 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, connection_details,
179 l10n_util::GetStringUTF16(
180 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR)));
estark00e83f12016-08-19 18:24:04181 return;
182 }
elawrenceb2ac2a232017-03-27 21:46:25183 if (security_info.contained_mixed_form) {
184 connection_status = PageInfo::SITE_CONNECTION_STATUS_INSECURE_FORM_ACTION;
185 connection_details.assign(l10n_util::GetStringFUTF16(
186 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, connection_details,
187 l10n_util::GetStringUTF16(
188 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_FORM_WARNING)));
189 return;
190 }
191 if (displayed_insecure_content) {
192 connection_status =
193 PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
194 connection_details.assign(l10n_util::GetStringFUTF16(
195 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, connection_details,
196 l10n_util::GetStringUTF16(
197 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
198 }
estark00e83f12016-08-19 18:24:04199}
200
estarkfcfccdb82016-11-14 02:17:29201void GetSiteIdentityByMaliciousContentStatus(
esecklercac56b62016-11-16 13:49:44202 security_state::MaliciousContentStatus malicious_content_status,
lgarron617a30f32017-03-24 21:42:07203 PageInfo::SiteIdentityStatus* status,
estarkfcfccdb82016-11-14 02:17:29204 base::string16* details) {
205 switch (malicious_content_status) {
esecklercac56b62016-11-16 13:49:44206 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
estarkfcfccdb82016-11-14 02:17:29207 NOTREACHED();
208 break;
esecklercac56b62016-11-16 13:49:44209 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
lgarron617a30f32017-03-24 21:42:07210 *status = PageInfo::SITE_IDENTITY_STATUS_MALWARE;
lgarron1a6300d2017-03-18 03:33:04211 *details = l10n_util::GetStringUTF16(IDS_PAGEINFO_MALWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29212 break;
esecklercac56b62016-11-16 13:49:44213 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
lgarron617a30f32017-03-24 21:42:07214 *status = PageInfo::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
lgarron1a6300d2017-03-18 03:33:04215 *details =
216 l10n_util::GetStringUTF16(IDS_PAGEINFO_SOCIAL_ENGINEERING_DETAILS);
estarkfcfccdb82016-11-14 02:17:29217 break;
esecklercac56b62016-11-16 13:49:44218 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
lgarron617a30f32017-03-24 21:42:07219 *status = PageInfo::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
lgarron1a6300d2017-03-18 03:33:04220 *details =
221 l10n_util::GetStringUTF16(IDS_PAGEINFO_UNWANTED_SOFTWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29222 break;
223 }
224}
225
jshin1fb76462016-04-05 22:13:03226base::string16 GetSimpleSiteName(const GURL& url) {
benwells2337b8102016-04-20 01:53:53227 return url_formatter::FormatUrlForSecurityDisplay(
228 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
palmer153af982015-09-15 02:04:19229}
230
reillyg85f57db2016-01-12 23:14:38231ChooserContextBase* GetUsbChooserContext(Profile* profile) {
232 return UsbChooserContextFactory::GetForProfile(profile);
233}
234
235// The list of chooser types that need to display entries in the Website
236// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
237// email [email protected].
lgarron617a30f32017-03-24 21:42:07238PageInfo::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52239 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
lgarron617a30f32017-03-24 21:42:07240 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_PAGE_INFO_USB_DEVICE_LABEL,
241 IDS_PAGE_INFO_DELETE_USB_DEVICE, "name"},
reillyg85f57db2016-01-12 23:14:38242};
243
[email protected]0b9fdd72012-04-04 10:00:33244} // namespace
245
lgarron617a30f32017-03-24 21:42:07246PageInfo::PageInfo(PageInfoUI* ui,
247 Profile* profile,
248 TabSpecificContentSettings* tab_specific_content_settings,
249 content::WebContents* web_contents,
250 const GURL& url,
251 const security_state::SecurityInfo& security_info)
[email protected]df818272012-04-20 13:10:50252 : TabSpecificContentSettings::SiteDataObserver(
253 tab_specific_content_settings),
dominicknbdd53b5f2016-09-28 01:08:13254 content::WebContentsObserver(web_contents),
[email protected]df818272012-04-20 13:10:50255 ui_(ui),
[email protected]66f157312012-08-01 13:50:26256 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33257 site_url_(url),
258 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]03ef4b2a2012-03-06 15:04:20259 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
alshabalin5e894c12016-10-25 06:47:46260 show_ssl_decision_revoke_button_(false),
peconn5100d432015-09-16 12:03:08261 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04262 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25263 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19264 did_revoke_user_ssl_decisions_(false),
estark8d67cd7a2016-10-24 05:06:41265 profile_(profile),
esecklercac56b62016-11-16 13:49:44266 security_level_(security_state::NONE) {
estarka3121f6b2015-09-18 21:15:59267 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33268
269 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50270 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41271 PresentSiteIdentity();
[email protected]e22d64f2012-09-10 09:03:23272
lgarron617a30f32017-03-24 21:42:07273 // Every time the Page Info UI is opened a |PageInfo| object is
274 // created. So this counts how ofter the Page Info UI is opened.
275 RecordPageInfoAction(PAGE_INFO_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20276}
277
lgarron617a30f32017-03-24 21:42:07278PageInfo::~PageInfo() {}
[email protected]03ef4b2a2012-03-06 15:04:20279
lgarron617a30f32017-03-24 21:42:07280void PageInfo::RecordPageInfoAction(PageInfoAction action) {
281 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04282
estark8d67cd7a2016-10-24 05:06:41283 std::string histogram_name;
palmeree0e5af2015-06-05 03:10:40284
estark8d67cd7a2016-10-24 05:06:41285 if (site_url_.SchemeIsCryptographic()) {
esecklercac56b62016-11-16 13:49:44286 if (security_level_ == security_state::SECURE ||
287 security_level_ == security_state::EV_SECURE) {
estark8d67cd7a2016-10-24 05:06:41288 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Valid",
lgarron617a30f32017-03-24 21:42:07289 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44290 } else if (security_level_ == security_state::NONE) {
estark8d67cd7a2016-10-24 05:06:41291 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded",
lgarron617a30f32017-03-24 21:42:07292 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44293 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41294 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07295 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41296 }
297 return;
298 }
299
esecklercac56b62016-11-16 13:49:44300 if (security_level_ == security_state::HTTP_SHOW_WARNING) {
estark8d67cd7a2016-10-24 05:06:41301 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning",
lgarron617a30f32017-03-24 21:42:07302 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44303 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41304 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07305 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41306 } else {
307 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral",
lgarron617a30f32017-03-24 21:42:07308 action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04309 }
310}
311
lgarron617a30f32017-03-24 21:42:07312void PageInfo::OnSitePermissionChanged(ContentSettingsType type,
313 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23314 // Count how often a permission for a specific content type is changed using
lgarron617a30f32017-03-24 21:42:07315 // the Page Info UI.
raymes4a13d432015-09-08 00:44:07316 size_t num_values;
317 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
dchengf6f4e4942017-03-30 23:55:57318 UMA_HISTOGRAM_EXACT_LINEAR("WebsiteSettings.OriginInfo.PermissionChanged",
319 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56320
321 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
dchengf6f4e4942017-03-30 23:55:57322 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56323 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07324 num_values);
tommycli34cf29bf2016-09-08 05:46:25325
326 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
327 rappor::SampleDomainAndRegistryFromGURL(
328 g_browser_process->rappor_service(),
329 "ContentSettings.Plugins.AddedAllowException", site_url_);
330 }
sashab9debecd2014-12-18 04:15:56331 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
dchengf6f4e4942017-03-30 23:55:57332 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56333 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07334 num_values);
sashab9debecd2014-12-18 04:15:56335 }
[email protected]e22d64f2012-09-10 09:03:23336
lgarron04a93502014-11-04 22:25:04337 // This is technically redundant given the histogram above, but putting the
338 // total count of permission changes in another histogram makes it easier to
lgarron617a30f32017-03-24 21:42:07339 // compare it against other kinds of actions in PageInfo[PopupView].
340 RecordPageInfoAction(PAGE_INFO_CHANGED_PERMISSION);
lgarron04a93502014-11-04 22:25:04341
stefanocs8b3490cc2016-07-28 05:32:52342 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
343 this->profile_, this->site_url_, this->site_url_, type,
344 PermissionSourceUI::OIB);
345
raymesfbaaaaa2015-11-10 02:20:40346 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
347 setting);
[email protected]df818272012-04-20 13:10:50348
[email protected]66f157312012-08-01 13:50:26349 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24350
351 // Refresh the UI to reflect the new setting.
352 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50353}
354
lgarron617a30f32017-03-24 21:42:07355void PageInfo::OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info,
356 const base::DictionaryValue& object) {
reillyg85f57db2016-01-12 23:14:38357 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
358 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10359 const GURL origin = site_url_.GetOrigin();
360 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38361
362 show_info_bar_ = true;
363
364 // Refresh the UI to reflect the changed settings.
365 PresentSitePermissions();
366}
367
lgarron617a30f32017-03-24 21:42:07368void PageInfo::OnSiteDataAccessed() {
[email protected]df818272012-04-20 13:10:50369 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33370}
371
lgarron617a30f32017-03-24 21:42:07372void PageInfo::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49373#if defined(OS_ANDROID)
374 NOTREACHED();
375#else
dominicknbdd53b5f2016-09-28 01:08:13376 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
palmerf2cba0d2015-08-27 23:15:06377 InfoBarService* infobar_service =
dominicknbdd53b5f2016-09-28 01:08:13378 InfoBarService::FromWebContents(web_contents());
palmerf2cba0d2015-08-27 23:15:06379 if (infobar_service)
lgarron617a30f32017-03-24 21:42:07380 PageInfoInfoBarDelegate::Create(infobar_service);
palmerf2cba0d2015-08-27 23:15:06381 }
jww1ed8ea72014-09-02 20:43:25382
383 SSLCertificateDecisionsDidRevoke user_decision =
384 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
385 : USER_CERT_DECISIONS_NOT_REVOKED;
386
387 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
388 user_decision,
389 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49390#endif
jww1ed8ea72014-09-02 20:43:25391}
392
lgarron617a30f32017-03-24 21:42:07393void PageInfo::OnRevokeSSLErrorBypassButtonPressed() {
jww1ed8ea72014-09-02 20:43:25394 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29395 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
396 site_url().host());
jww1ed8ea72014-09-02 20:43:25397 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26398}
399
lgarron617a30f32017-03-24 21:42:07400void PageInfo::Init(const GURL& url,
401 const security_state::SecurityInfo& security_info) {
meacerde53fcff2016-10-12 19:21:57402#if !defined(OS_ANDROID) && !defined(OS_IOS)
403 // On desktop, internal URLs aren't handled by this class. Instead, a
404 // custom and simpler popup is shown.
405 DCHECK(!url.SchemeIs(content::kChromeUIScheme) &&
406 !url.SchemeIs(content::kChromeDevToolsScheme) &&
407 !url.SchemeIs(content::kViewSourceScheme) &&
408 !url.SchemeIs(content_settings::kExtensionScheme));
409#endif
410
sashab97894ce2014-10-22 10:08:33411 bool isChromeUINativeScheme = false;
zpengdb4a58e2017-01-10 17:40:32412#if defined(OS_ANDROID)
sashab97894ce2014-10-22 10:08:33413 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
414#endif
415
estark8d67cd7a2016-10-24 05:06:41416 security_level_ = security_info.security_level;
417
upendrag.gowda60886a6e2015-10-31 05:51:09418 if (url.SchemeIs(url::kAboutScheme)) {
419 // All about: URLs except about:blank are redirected.
420 DCHECK_EQ(url::kAboutBlankURL, url.spec());
421 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
422 site_identity_details_ =
423 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
424 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
425 site_connection_details_ = l10n_util::GetStringFUTF16(
426 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
427 UTF8ToUTF16(url.spec()));
428 return;
429 }
430
431 if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) {
[email protected]03ef4b2a2012-03-06 15:04:20432 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
433 site_identity_details_ =
434 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
435 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
436 return;
437 }
438
[email protected]03ef4b2a2012-03-06 15:04:20439 // Identity section.
jam8ae7cad2016-09-08 23:55:21440 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11441
estarkfcfccdb82016-11-14 02:17:29442 if (security_info.malicious_content_status !=
esecklercac56b62016-11-16 13:49:44443 security_state::MALICIOUS_CONTENT_STATUS_NONE) {
estarkfcfccdb82016-11-14 02:17:29444 // The site has been flagged by Safe Browsing as dangerous.
445 GetSiteIdentityByMaliciousContentStatus(
446 security_info.malicious_content_status, &site_identity_status_,
447 &site_identity_details_);
448 } else if (certificate_ &&
449 (!net::IsCertStatusError(security_info.cert_status) ||
450 net::IsCertStatusMinorError(security_info.cert_status))) {
451 // HTTPS with no or minor errors.
estarka3121f6b2015-09-18 21:15:59452 if (security_info.security_level ==
esecklercac56b62016-11-16 13:49:44453 security_state::SECURE_WITH_POLICY_INSTALLED_CERT) {
[email protected]eaf3f322013-04-25 21:53:59454 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37455 site_identity_details_ = l10n_util::GetStringFUTF16(
456 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59457 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20458 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21459 base::string16 issuer_name(
460 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20461 if (issuer_name.empty()) {
462 issuer_name.assign(l10n_util::GetStringUTF16(
463 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
464 }
[email protected]94c74b42013-12-02 15:19:49465
[email protected]03ef4b2a2012-03-06 15:04:20466 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39467 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20468
469 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59470 if (security_info.cert_status &
471 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20472 site_identity_details_ += l10n_util::GetStringUTF16(
473 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59474 } else if (security_info.cert_status &
475 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20476 site_identity_details_ += l10n_util::GetStringUTF16(
477 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
478 } else {
479 NOTREACHED() << "Need to specify string for this warning";
480 }
[email protected]03ef4b2a2012-03-06 15:04:20481 } else {
estarkcf305562016-11-15 03:45:39482 // No major or minor errors.
estarka3121f6b2015-09-18 21:15:59483 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01484 // EV HTTPS page.
estarkcf305562016-11-15 03:45:39485 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
jam8ae7cad2016-09-08 23:55:21486 DCHECK(!certificate_->subject().organization_names.empty());
487 organization_name_ =
488 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01489 // An EV Cert is required to have a city (localityName) and country but
490 // state is "if any".
jam8ae7cad2016-09-08 23:55:21491 DCHECK(!certificate_->subject().locality_name.empty());
492 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01493 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21494 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01495 locality = l10n_util::GetStringFUTF16(
496 IDS_PAGEINFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21497 UTF8ToUTF16(certificate_->subject().locality_name),
498 UTF8ToUTF16(certificate_->subject().state_or_province_name),
499 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01500 } else {
501 locality = l10n_util::GetStringFUTF16(
502 IDS_PAGEINFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21503 UTF8ToUTF16(certificate_->subject().locality_name),
504 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01505 }
jam8ae7cad2016-09-08 23:55:21506 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01507 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39508 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED,
jam8ae7cad2016-09-08 23:55:21509 UTF8ToUTF16(certificate_->subject().organization_names[0]),
estarkcf305562016-11-15 03:45:39510 locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01511 } else {
512 // Non-EV OK HTTPS page.
estarkcf305562016-11-15 03:45:39513 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
rsleevi4f8012722014-09-30 01:28:01514 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21515 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01516 if (issuer_name.empty()) {
517 issuer_name.assign(l10n_util::GetStringUTF16(
518 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
519 }
[email protected]94c74b42013-12-02 15:19:49520
rsleevi4f8012722014-09-30 01:28:01521 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39522 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
rsleevi4f8012722014-09-30 01:28:01523 }
elawrencebe87bd62017-01-10 16:08:59524 if (security_info.sha1_in_chain) {
525 site_identity_status_ =
526 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM;
527 site_identity_details_ +=
528 UTF8ToUTF16("\n\n") +
529 l10n_util::GetStringUTF16(
530 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM);
rsleevi4f8012722014-09-30 01:28:01531 }
[email protected]03ef4b2a2012-03-06 15:04:20532 }
533 } else {
534 // HTTP or HTTPS with errors (not warnings).
535 site_identity_details_.assign(l10n_util::GetStringUTF16(
536 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
jam8ae7cad2016-09-08 23:55:21537 if (!security_info.scheme_is_cryptographic || !security_info.certificate)
[email protected]03ef4b2a2012-03-06 15:04:20538 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
539 else
540 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
541
[email protected]a04db822013-12-11 19:14:40542 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59543 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59544 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
jam8ae7cad2016-09-08 23:55:21545 certificate_, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20546 for (size_t i = 0; i < errors.size(); ++i) {
547 site_identity_details_ += bullet;
548 site_identity_details_ += errors[i].short_description();
549 }
550
estarka3121f6b2015-09-18 21:15:59551 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20552 site_identity_details_ += ASCIIToUTF16("\n\n");
lgarron1a6300d2017-03-18 03:33:04553 site_identity_details_ +=
554 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
[email protected]03ef4b2a2012-03-06 15:04:20555 }
556 }
557
558 // Site Connection
559 // We consider anything less than 80 bits encryption to be weak encryption.
560 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
561 // weakly encrypted connections.
562 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
563
jshin1fb76462016-04-05 22:13:03564 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19565 if (subject_name.empty()) {
566 subject_name.assign(
567 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
568 }
569
jam8ae7cad2016-09-08 23:55:21570 if (!security_info.certificate || !security_info.scheme_is_cryptographic) {
estarka3121f6b2015-09-18 21:15:59571 // Page is still loading (so SSL status is not yet available) or
572 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58573 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
574
575 site_connection_details_.assign(l10n_util::GetStringFUTF16(
576 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
577 subject_name));
estarka3121f6b2015-09-18 21:15:59578 } else if (security_info.security_bits < 0) {
579 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20580 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59581 } else if (security_info.security_bits == 0) {
esecklercac56b62016-11-16 13:49:44582 DCHECK_NE(security_info.security_level, security_state::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20583 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
584 site_connection_details_.assign(l10n_util::GetStringFUTF16(
585 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
586 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20587 } else {
588 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22589
lgarron3e2c33e2016-08-25 06:33:43590 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22591 site_connection_details_.assign(l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04592 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, subject_name));
Adam Langley71c2b59b2014-11-13 00:34:22593 } else {
594 site_connection_details_.assign(l10n_util::GetStringFUTF16(
595 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
596 subject_name));
597 }
598
elawrenceb2ac2a232017-03-27 21:46:25599 ReportAnyInsecureContent(security_info, site_connection_status_,
600 site_connection_details_);
[email protected]03ef4b2a2012-03-06 15:04:20601 }
602
avi655876a2015-12-25 07:18:15603 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59604 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
605 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20606 int ssl_version =
estarka3121f6b2015-09-18 21:15:59607 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20608 const char* ssl_version_str;
609 net::SSLVersionToString(&ssl_version_str, ssl_version);
610 site_connection_details_ += ASCIIToUTF16("\n\n");
611 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04612 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, ASCIIToUTF16(ssl_version_str));
[email protected]03ef4b2a2012-03-06 15:04:20613
[email protected]03ef4b2a2012-03-06 15:04:20614 const char *key_exchange, *cipher, *mac;
davidben56a8aece2016-10-14 18:20:56615 bool is_aead, is_tls13;
616 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
617 &is_tls13, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20618
619 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57620 if (is_aead) {
davidben56a8aece2016-10-14 18:20:56621 if (is_tls13) {
622 // For TLS 1.3 ciphers, report the group (historically, curve) as the
623 // key exchange.
624 key_exchange = SSL_get_curve_name(security_info.key_exchange_group);
625 if (!key_exchange) {
626 NOTREACHED();
627 key_exchange = "";
628 }
629 }
[email protected]b6c1d9e82013-06-12 17:26:57630 site_connection_details_ += l10n_util::GetStringFUTF16(
631 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
632 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
633 } else {
634 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04635 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, ASCIIToUTF16(cipher),
636 ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
[email protected]b6c1d9e82013-06-12 17:26:57637 }
[email protected]03ef4b2a2012-03-06 15:04:20638
agl078d2102014-10-20 22:03:22639 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 &&
estark00e83f12016-08-19 18:24:04640 site_connection_status_ <
641 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE) {
agl078d2102014-10-20 22:03:22642 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
643 }
[email protected]03ef4b2a2012-03-06 15:04:20644 }
[email protected]e583f752012-08-30 13:26:21645
[email protected]71cd5ef2014-08-13 21:22:04646 // Check if a user decision has been made to allow or deny certificates with
647 // errors on this site.
648 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50649 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04650 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40651 // Only show an SSL decision revoke button if the user has chosen to bypass
652 // SSL host errors for this host in the past.
653 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]03ef4b2a2012-03-06 15:04:20654}
[email protected]0b9fdd72012-04-04 10:00:33655
lgarron617a30f32017-03-24 21:42:07656void PageInfo::PresentSitePermissions() {
[email protected]df818272012-04-20 13:10:50657 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38658 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50659
lgarron617a30f32017-03-24 21:42:07660 PageInfoUI::PermissionInfo permission_info;
[email protected]df818272012-04-20 13:10:50661 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
662 permission_info.type = kPermissionType[i];
663
mgiucaa319f212016-01-14 03:30:11664 if (!ShouldShowPermission(permission_info.type))
665 continue;
666
[email protected]df818272012-04-20 13:10:50667 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32668 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
669 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21670 DCHECK(value.get());
jdoerriedc72ee942016-12-07 15:43:28671 if (value->GetType() == base::Value::Type::INTEGER) {
sashab2b2a314f2015-01-17 06:42:21672 permission_info.setting =
673 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26674 } else {
sashab2b2a314f2015-01-17 06:42:21675 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26676 }
677
[email protected]8bdf45c32012-08-04 00:12:55678 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28679 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50680
[email protected]b1d113d2012-06-27 21:27:34681 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21682 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34683 permission_info.default_setting = permission_info.setting;
684 permission_info.setting = CONTENT_SETTING_DEFAULT;
685 } else {
686 permission_info.default_setting =
687 content_settings_->GetDefaultContentSetting(permission_info.type,
688 NULL);
[email protected]df818272012-04-20 13:10:50689 }
palmer0da10b32015-02-11 00:42:19690
patricialor2a4f41a2017-03-08 02:52:56691 // For permissions that are still prompting the user and haven't been
692 // explicitly set by another source, check its embargo status.
693 if (PermissionUtil::IsPermission(permission_info.type) &&
694 permission_info.setting == CONTENT_SETTING_DEFAULT &&
695 permission_info.source ==
696 content_settings::SettingSource::SETTING_SOURCE_USER) {
697 // TODO(raymes): Use GetPermissionStatus() to retrieve information
698 // about *all* permissions once it has default behaviour implemented for
699 // ContentSettingTypes that aren't permissions.
700 PermissionResult permission_result =
701 PermissionManager::Get(profile_)->GetPermissionStatus(
702 permission_info.type, site_url_, site_url_);
703
704 // If under embargo, update |permission_info| to reflect that.
705 if (permission_result.content_setting == CONTENT_SETTING_BLOCK &&
706 (permission_result.source ==
707 PermissionStatusSource::MULTIPLE_DISMISSALS ||
708 permission_result.source ==
709 PermissionStatusSource::SAFE_BROWSING_BLACKLIST))
710 permission_info.setting = permission_result.content_setting;
711 }
712
palmer64a099982016-03-09 21:26:11713 permission_info_list.push_back(permission_info);
[email protected]df818272012-04-20 13:10:50714 }
715
reillyg85f57db2016-01-12 23:14:38716 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
717 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10718 const GURL origin = site_url_.GetOrigin();
719 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32720 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38721 chosen_object_info_list.push_back(
lgarron617a30f32017-03-24 21:42:07722 base::MakeUnique<PageInfoUI::ChosenObjectInfo>(ui_info,
723 std::move(object)));
reillyg85f57db2016-01-12 23:14:38724 }
725 }
726
avi09dd4d02016-10-14 20:40:09727 ui_->SetPermissionInfo(permission_info_list,
728 std::move(chosen_object_info_list));
[email protected]0b9fdd72012-04-04 10:00:33729}
730
lgarron617a30f32017-03-24 21:42:07731void PageInfo::PresentSiteData() {
[email protected]df818272012-04-20 13:10:50732 CookieInfoList cookie_info_list;
vabrbab3ffcb2016-10-04 10:08:10733 const LocalSharedObjectsContainer& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34734 tab_specific_content_settings()->allowed_local_shared_objects();
vabrbab3ffcb2016-10-04 10:08:10735 const LocalSharedObjectsContainer& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34736 tab_specific_content_settings()->blocked_local_shared_objects();
737
738 // Add first party cookie and site data counts.
lgarron617a30f32017-03-24 21:42:07739 PageInfoUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34740 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
741 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15742 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34743 cookie_info_list.push_back(cookie_info);
744
745 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34746 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
747 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15748 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50749 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33750
[email protected]df818272012-04-20 13:10:50751 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33752}
[email protected]16de6de2012-04-04 12:24:14753
lgarron617a30f32017-03-24 21:42:07754void PageInfo::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04755 // After initialization the status about the site's connection and its
756 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41757 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
758 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
lgarron617a30f32017-03-24 21:42:07759 PageInfoUI::IdentityInfo info;
[email protected]24c8818c2012-04-25 09:57:41760 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
761 info.site_identity = UTF16ToUTF8(organization_name());
762 else
jshin1fb76462016-04-05 22:13:03763 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41764
765 info.connection_status = site_connection_status_;
lgarron1a6300d2017-03-18 03:33:04766 info.connection_status_description = UTF16ToUTF8(site_connection_details_);
[email protected]24c8818c2012-04-25 09:57:41767 info.identity_status = site_identity_status_;
lgarron1a6300d2017-03-18 03:33:04768 info.identity_status_description = UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21769 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04770 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
[email protected]24c8818c2012-04-25 09:57:41771 ui_->SetIdentityInfo(info);
772}