blob: 90204f5152c4d8c56069cc06405569497d01da11 [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"
Patricia Lora21a04cf2017-06-05 02:53:2946#include "chrome/common/chrome_features.h"
[email protected]71cd5ef2014-08-13 21:22:0447#include "chrome/common/chrome_switches.h"
jsbellddb849e2015-08-27 00:12:5648#include "chrome/common/url_constants.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"
Patricia Lora21a04cf2017-06-05 02:53:2970#include "url/origin.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
csharrisonad1eaa6c2017-05-11 17:14:3897// ORDER OF THESE ITEMS IS IMPORTANT and comes from https://crbug.com/610358. To
98// propose changing it, email [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,
Charles Harrison239d47982017-06-13 02:42:31110 CONTENT_SETTINGS_TYPE_ADS,
nsatragno670fe922016-04-08 14:10:50111 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
palmer7715e332016-05-27 00:41:19112 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
finnur46cafd42016-09-22 10:27:17113 CONTENT_SETTINGS_TYPE_AUTOPLAY,
palmer7715e332016-05-27 00:41:19114 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
[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|.
csharrisonad1eaa6c2017-05-11 17:14:38119bool ShouldShowPermission(ContentSettingsType type,
120 const GURL& site_url,
121 HostContentSettingsMap* content_settings) {
mgiucaa319f212016-01-14 03:30:11122#if !defined(OS_ANDROID)
finnur46cafd42016-09-22 10:27:17123 // Autoplay is Android-only at the moment.
mgiuca273b9672016-11-11 02:22:20124 if (type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
mgiuca0f3e1f72016-05-13 01:56:27125 return false;
mgiucaa319f212016-01-14 03:30:11126#endif
127
Charles Harrison239d47982017-06-13 02:42:31128 if (type == CONTENT_SETTINGS_TYPE_ADS) {
csharrisonad1eaa6c2017-05-11 17:14:38129 if (!base::FeatureList::IsEnabled(
130 subresource_filter::kSafeBrowsingSubresourceFilterExperimentalUI)) {
131 return false;
132 }
133
134 // The setting for subresource filtering should not show up if the site is
135 // not activated, both on android and desktop platforms.
136 return content_settings->GetWebsiteSetting(
Charles Harrison239d47982017-06-13 02:42:31137 site_url, GURL(), CONTENT_SETTINGS_TYPE_ADS_DATA, std::string(),
138 nullptr) != nullptr;
melandory7be36d312017-03-29 15:51:12139 }
140
mgiucaa319f212016-01-14 03:30:11141 return true;
142}
143
esecklercac56b62016-11-16 13:49:44144void CheckContentStatus(security_state::ContentStatus content_status,
estark00e83f12016-08-19 18:24:04145 bool* displayed,
146 bool* ran) {
147 switch (content_status) {
esecklercac56b62016-11-16 13:49:44148 case security_state::CONTENT_STATUS_DISPLAYED:
estark00e83f12016-08-19 18:24:04149 *displayed = true;
150 break;
esecklercac56b62016-11-16 13:49:44151 case security_state::CONTENT_STATUS_RAN:
estark00e83f12016-08-19 18:24:04152 *ran = true;
153 break;
esecklercac56b62016-11-16 13:49:44154 case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN:
estark00e83f12016-08-19 18:24:04155 *displayed = true;
156 *ran = true;
157 break;
esecklercac56b62016-11-16 13:49:44158 case security_state::CONTENT_STATUS_UNKNOWN:
159 case security_state::CONTENT_STATUS_NONE:
estark00e83f12016-08-19 18:24:04160 break;
161 }
162}
163
elawrenceb2ac2a232017-03-27 21:46:25164// If the |security_info| indicates that mixed content or certificate errors
165// were present, update |connection_status| and |connection_details|.
166void ReportAnyInsecureContent(const security_state::SecurityInfo& security_info,
thestig4427f13b2017-06-20 20:42:47167 PageInfo::SiteConnectionStatus* connection_status,
168 base::string16* connection_details) {
elawrenceb2ac2a232017-03-27 21:46:25169 bool displayed_insecure_content = false;
170 bool ran_insecure_content = false;
171 CheckContentStatus(security_info.mixed_content_status,
172 &displayed_insecure_content, &ran_insecure_content);
173 // Only note subresources with certificate errors if the main resource was
174 // loaded without major certificate errors. If the main resource had a
175 // certificate error, then it would not be that useful (and could
176 // potentially be confusing) to warn about subresources that had certificate
177 // errors too.
178 if (!net::IsCertStatusError(security_info.cert_status) ||
179 net::IsCertStatusMinorError(security_info.cert_status)) {
180 CheckContentStatus(security_info.content_with_cert_errors_status,
181 &displayed_insecure_content, &ran_insecure_content);
182 }
183
184 // Only one insecure content warning is displayed; show the most severe.
185 if (ran_insecure_content) {
thestig4427f13b2017-06-20 20:42:47186 *connection_status =
elawrenceb2ac2a232017-03-27 21:46:25187 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE;
thestig4427f13b2017-06-20 20:42:47188 connection_details->assign(l10n_util::GetStringFUTF16(
189 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25190 l10n_util::GetStringUTF16(
191 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR)));
estark00e83f12016-08-19 18:24:04192 return;
193 }
elawrenceb2ac2a232017-03-27 21:46:25194 if (security_info.contained_mixed_form) {
thestig4427f13b2017-06-20 20:42:47195 *connection_status = PageInfo::SITE_CONNECTION_STATUS_INSECURE_FORM_ACTION;
196 connection_details->assign(l10n_util::GetStringFUTF16(
197 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25198 l10n_util::GetStringUTF16(
199 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_FORM_WARNING)));
200 return;
201 }
202 if (displayed_insecure_content) {
thestig4427f13b2017-06-20 20:42:47203 *connection_status =
elawrenceb2ac2a232017-03-27 21:46:25204 PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
thestig4427f13b2017-06-20 20:42:47205 connection_details->assign(l10n_util::GetStringFUTF16(
206 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25207 l10n_util::GetStringUTF16(
208 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
209 }
estark00e83f12016-08-19 18:24:04210}
211
estarkfcfccdb82016-11-14 02:17:29212void GetSiteIdentityByMaliciousContentStatus(
esecklercac56b62016-11-16 13:49:44213 security_state::MaliciousContentStatus malicious_content_status,
lgarron617a30f32017-03-24 21:42:07214 PageInfo::SiteIdentityStatus* status,
estarkfcfccdb82016-11-14 02:17:29215 base::string16* details) {
216 switch (malicious_content_status) {
esecklercac56b62016-11-16 13:49:44217 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
estarkfcfccdb82016-11-14 02:17:29218 NOTREACHED();
219 break;
esecklercac56b62016-11-16 13:49:44220 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
lgarron617a30f32017-03-24 21:42:07221 *status = PageInfo::SITE_IDENTITY_STATUS_MALWARE;
lgarronfc1d5e52017-05-03 23:15:21222 *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MALWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29223 break;
esecklercac56b62016-11-16 13:49:44224 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
lgarron617a30f32017-03-24 21:42:07225 *status = PageInfo::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
lgarron1a6300d2017-03-18 03:33:04226 *details =
lgarronfc1d5e52017-05-03 23:15:21227 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SOCIAL_ENGINEERING_DETAILS);
estarkfcfccdb82016-11-14 02:17:29228 break;
esecklercac56b62016-11-16 13:49:44229 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
lgarron617a30f32017-03-24 21:42:07230 *status = PageInfo::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
lgarron1a6300d2017-03-18 03:33:04231 *details =
lgarronfc1d5e52017-05-03 23:15:21232 l10n_util::GetStringUTF16(IDS_PAGE_INFO_UNWANTED_SOFTWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29233 break;
234 }
235}
236
jshin1fb76462016-04-05 22:13:03237base::string16 GetSimpleSiteName(const GURL& url) {
benwells2337b8102016-04-20 01:53:53238 return url_formatter::FormatUrlForSecurityDisplay(
239 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
palmer153af982015-09-15 02:04:19240}
241
reillyg85f57db2016-01-12 23:14:38242ChooserContextBase* GetUsbChooserContext(Profile* profile) {
243 return UsbChooserContextFactory::GetForProfile(profile);
244}
245
246// The list of chooser types that need to display entries in the Website
247// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
248// email [email protected].
lgarron617a30f32017-03-24 21:42:07249PageInfo::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52250 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
lgarron617a30f32017-03-24 21:42:07251 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_PAGE_INFO_USB_DEVICE_LABEL,
252 IDS_PAGE_INFO_DELETE_USB_DEVICE, "name"},
reillyg85f57db2016-01-12 23:14:38253};
254
[email protected]0b9fdd72012-04-04 10:00:33255} // namespace
256
lgarron617a30f32017-03-24 21:42:07257PageInfo::PageInfo(PageInfoUI* ui,
258 Profile* profile,
259 TabSpecificContentSettings* tab_specific_content_settings,
260 content::WebContents* web_contents,
261 const GURL& url,
262 const security_state::SecurityInfo& security_info)
[email protected]df818272012-04-20 13:10:50263 : TabSpecificContentSettings::SiteDataObserver(
264 tab_specific_content_settings),
dominicknbdd53b5f2016-09-28 01:08:13265 content::WebContentsObserver(web_contents),
[email protected]df818272012-04-20 13:10:50266 ui_(ui),
[email protected]66f157312012-08-01 13:50:26267 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33268 site_url_(url),
269 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]03ef4b2a2012-03-06 15:04:20270 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
alshabalin5e894c12016-10-25 06:47:46271 show_ssl_decision_revoke_button_(false),
peconn5100d432015-09-16 12:03:08272 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04273 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25274 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19275 did_revoke_user_ssl_decisions_(false),
estark8d67cd7a2016-10-24 05:06:41276 profile_(profile),
esecklercac56b62016-11-16 13:49:44277 security_level_(security_state::NONE) {
estarka3121f6b2015-09-18 21:15:59278 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33279
280 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50281 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41282 PresentSiteIdentity();
[email protected]e22d64f2012-09-10 09:03:23283
lgarron617a30f32017-03-24 21:42:07284 // Every time the Page Info UI is opened a |PageInfo| object is
285 // created. So this counts how ofter the Page Info UI is opened.
286 RecordPageInfoAction(PAGE_INFO_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20287}
288
lgarron617a30f32017-03-24 21:42:07289PageInfo::~PageInfo() {}
[email protected]03ef4b2a2012-03-06 15:04:20290
lgarron617a30f32017-03-24 21:42:07291void PageInfo::RecordPageInfoAction(PageInfoAction action) {
292 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04293
estark8d67cd7a2016-10-24 05:06:41294 std::string histogram_name;
palmeree0e5af2015-06-05 03:10:40295
estark8d67cd7a2016-10-24 05:06:41296 if (site_url_.SchemeIsCryptographic()) {
esecklercac56b62016-11-16 13:49:44297 if (security_level_ == security_state::SECURE ||
298 security_level_ == security_state::EV_SECURE) {
estark8d67cd7a2016-10-24 05:06:41299 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Valid",
lgarron617a30f32017-03-24 21:42:07300 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44301 } else if (security_level_ == security_state::NONE) {
estark8d67cd7a2016-10-24 05:06:41302 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded",
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.HttpsUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07306 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41307 }
308 return;
309 }
310
esecklercac56b62016-11-16 13:49:44311 if (security_level_ == security_state::HTTP_SHOW_WARNING) {
estark8d67cd7a2016-10-24 05:06:41312 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning",
lgarron617a30f32017-03-24 21:42:07313 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44314 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41315 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07316 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41317 } else {
318 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral",
lgarron617a30f32017-03-24 21:42:07319 action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04320 }
321}
322
lgarron617a30f32017-03-24 21:42:07323void PageInfo::OnSitePermissionChanged(ContentSettingsType type,
324 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23325 // Count how often a permission for a specific content type is changed using
lgarron617a30f32017-03-24 21:42:07326 // the Page Info UI.
raymes4a13d432015-09-08 00:44:07327 size_t num_values;
328 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
dchengf6f4e4942017-03-30 23:55:57329 UMA_HISTOGRAM_EXACT_LINEAR("WebsiteSettings.OriginInfo.PermissionChanged",
330 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56331
332 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
dchengf6f4e4942017-03-30 23:55:57333 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56334 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07335 num_values);
tommycli34cf29bf2016-09-08 05:46:25336
337 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
338 rappor::SampleDomainAndRegistryFromGURL(
339 g_browser_process->rappor_service(),
340 "ContentSettings.Plugins.AddedAllowException", site_url_);
341 }
sashab9debecd2014-12-18 04:15:56342 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
dchengf6f4e4942017-03-30 23:55:57343 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56344 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07345 num_values);
sashab9debecd2014-12-18 04:15:56346 }
[email protected]e22d64f2012-09-10 09:03:23347
lgarron04a93502014-11-04 22:25:04348 // This is technically redundant given the histogram above, but putting the
349 // total count of permission changes in another histogram makes it easier to
lgarron026e9c42017-04-07 20:09:31350 // compare it against other kinds of actions in Page Info.
lgarron617a30f32017-03-24 21:42:07351 RecordPageInfoAction(PAGE_INFO_CHANGED_PERMISSION);
lgarron04a93502014-11-04 22:25:04352
stefanocs8b3490cc2016-07-28 05:32:52353 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
patricialor7131c1fe2017-04-07 01:25:52354 profile_, site_url_, site_url_, type, PermissionSourceUI::OIB);
stefanocs8b3490cc2016-07-28 05:32:52355
patricialor7131c1fe2017-04-07 01:25:52356 // The permission may have been blocked due to being under embargo, so if it
357 // was changed away from BLOCK, clear embargo status if it exists.
358 if (setting != CONTENT_SETTING_BLOCK) {
359 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveEmbargoByUrl(
360 site_url_, type);
361 }
raymesfbaaaaa2015-11-10 02:20:40362 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
363 setting);
[email protected]df818272012-04-20 13:10:50364
[email protected]66f157312012-08-01 13:50:26365 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24366
367 // Refresh the UI to reflect the new setting.
368 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50369}
370
lgarron617a30f32017-03-24 21:42:07371void PageInfo::OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info,
372 const base::DictionaryValue& object) {
reillyg85f57db2016-01-12 23:14:38373 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
374 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10375 const GURL origin = site_url_.GetOrigin();
376 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38377
378 show_info_bar_ = true;
379
380 // Refresh the UI to reflect the changed settings.
381 PresentSitePermissions();
382}
383
lgarron617a30f32017-03-24 21:42:07384void PageInfo::OnSiteDataAccessed() {
[email protected]df818272012-04-20 13:10:50385 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33386}
387
lgarron617a30f32017-03-24 21:42:07388void PageInfo::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49389#if defined(OS_ANDROID)
390 NOTREACHED();
391#else
dominicknbdd53b5f2016-09-28 01:08:13392 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
palmerf2cba0d2015-08-27 23:15:06393 InfoBarService* infobar_service =
dominicknbdd53b5f2016-09-28 01:08:13394 InfoBarService::FromWebContents(web_contents());
palmerf2cba0d2015-08-27 23:15:06395 if (infobar_service)
lgarron617a30f32017-03-24 21:42:07396 PageInfoInfoBarDelegate::Create(infobar_service);
palmerf2cba0d2015-08-27 23:15:06397 }
jww1ed8ea72014-09-02 20:43:25398
399 SSLCertificateDecisionsDidRevoke user_decision =
400 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
401 : USER_CERT_DECISIONS_NOT_REVOKED;
402
403 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
404 user_decision,
405 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49406#endif
jww1ed8ea72014-09-02 20:43:25407}
408
lgarron617a30f32017-03-24 21:42:07409void PageInfo::OnRevokeSSLErrorBypassButtonPressed() {
jww1ed8ea72014-09-02 20:43:25410 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29411 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
412 site_url().host());
jww1ed8ea72014-09-02 20:43:25413 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26414}
415
Patricia Lora21a04cf2017-06-05 02:53:29416void PageInfo::OpenSiteSettingsView() {
417 // By default, this opens the general Content Settings pane. If the
418 // |kSiteSettings| and/or |kSiteDetails| flags are enabled this opens a
419 // settings page specific to the current origin of the page. crbug.com/655876
420 url::Origin site_origin = url::Origin(site_url());
421 std::string link_destination(chrome::kChromeUIContentSettingsURL);
422 if ((base::CommandLine::ForCurrentProcess()->HasSwitch(
423 switches::kEnableSiteSettings) ||
424 base::FeatureList::IsEnabled(features::kSiteDetails)) &&
425 !site_origin.unique()) {
426 std::string origin_string = site_origin.Serialize();
427 url::RawCanonOutputT<char> percent_encoded_origin;
428 url::EncodeURIComponent(origin_string.c_str(), origin_string.length(),
429 &percent_encoded_origin);
430 link_destination = chrome::kChromeUISiteDetailsPrefixURL +
431 std::string(percent_encoded_origin.data(),
432 percent_encoded_origin.length());
433 }
434 web_contents()->OpenURL(
435 content::OpenURLParams(GURL(link_destination), content::Referrer(),
436 WindowOpenDisposition::NEW_FOREGROUND_TAB,
437 ui::PAGE_TRANSITION_LINK, false));
438 RecordPageInfoAction(PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED);
439}
440
lgarron617a30f32017-03-24 21:42:07441void PageInfo::Init(const GURL& url,
442 const security_state::SecurityInfo& security_info) {
meacerde53fcff2016-10-12 19:21:57443#if !defined(OS_ANDROID) && !defined(OS_IOS)
444 // On desktop, internal URLs aren't handled by this class. Instead, a
lgarron026e9c42017-04-07 20:09:31445 // custom and simpler bubble is shown.
meacerde53fcff2016-10-12 19:21:57446 DCHECK(!url.SchemeIs(content::kChromeUIScheme) &&
447 !url.SchemeIs(content::kChromeDevToolsScheme) &&
448 !url.SchemeIs(content::kViewSourceScheme) &&
449 !url.SchemeIs(content_settings::kExtensionScheme));
450#endif
451
sashab97894ce2014-10-22 10:08:33452 bool isChromeUINativeScheme = false;
zpengdb4a58e2017-01-10 17:40:32453#if defined(OS_ANDROID)
sashab97894ce2014-10-22 10:08:33454 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
455#endif
456
estark8d67cd7a2016-10-24 05:06:41457 security_level_ = security_info.security_level;
458
upendrag.gowda60886a6e2015-10-31 05:51:09459 if (url.SchemeIs(url::kAboutScheme)) {
460 // All about: URLs except about:blank are redirected.
461 DCHECK_EQ(url::kAboutBlankURL, url.spec());
462 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
463 site_identity_details_ =
464 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
465 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
466 site_connection_details_ = l10n_util::GetStringFUTF16(
467 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
468 UTF8ToUTF16(url.spec()));
469 return;
470 }
471
472 if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) {
[email protected]03ef4b2a2012-03-06 15:04:20473 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
474 site_identity_details_ =
475 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
476 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
477 return;
478 }
479
[email protected]03ef4b2a2012-03-06 15:04:20480 // Identity section.
jam8ae7cad2016-09-08 23:55:21481 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11482
estarkfcfccdb82016-11-14 02:17:29483 if (security_info.malicious_content_status !=
esecklercac56b62016-11-16 13:49:44484 security_state::MALICIOUS_CONTENT_STATUS_NONE) {
estarkfcfccdb82016-11-14 02:17:29485 // The site has been flagged by Safe Browsing as dangerous.
486 GetSiteIdentityByMaliciousContentStatus(
487 security_info.malicious_content_status, &site_identity_status_,
488 &site_identity_details_);
489 } else if (certificate_ &&
490 (!net::IsCertStatusError(security_info.cert_status) ||
491 net::IsCertStatusMinorError(security_info.cert_status))) {
492 // HTTPS with no or minor errors.
estarka3121f6b2015-09-18 21:15:59493 if (security_info.security_level ==
esecklercac56b62016-11-16 13:49:44494 security_state::SECURE_WITH_POLICY_INSTALLED_CERT) {
[email protected]eaf3f322013-04-25 21:53:59495 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37496 site_identity_details_ = l10n_util::GetStringFUTF16(
497 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59498 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20499 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21500 base::string16 issuer_name(
501 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20502 if (issuer_name.empty()) {
503 issuer_name.assign(l10n_util::GetStringUTF16(
504 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
505 }
[email protected]94c74b42013-12-02 15:19:49506
[email protected]03ef4b2a2012-03-06 15:04:20507 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39508 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20509
510 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59511 if (security_info.cert_status &
512 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20513 site_identity_details_ += l10n_util::GetStringUTF16(
514 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59515 } else if (security_info.cert_status &
516 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20517 site_identity_details_ += l10n_util::GetStringUTF16(
518 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
519 } else {
520 NOTREACHED() << "Need to specify string for this warning";
521 }
[email protected]03ef4b2a2012-03-06 15:04:20522 } else {
estarkcf305562016-11-15 03:45:39523 // No major or minor errors.
estarka3121f6b2015-09-18 21:15:59524 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01525 // EV HTTPS page.
estarkcf305562016-11-15 03:45:39526 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
jam8ae7cad2016-09-08 23:55:21527 DCHECK(!certificate_->subject().organization_names.empty());
528 organization_name_ =
529 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01530 // An EV Cert is required to have a city (localityName) and country but
531 // state is "if any".
jam8ae7cad2016-09-08 23:55:21532 DCHECK(!certificate_->subject().locality_name.empty());
533 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01534 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21535 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01536 locality = l10n_util::GetStringFUTF16(
lgarronfc1d5e52017-05-03 23:15:21537 IDS_PAGE_INFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21538 UTF8ToUTF16(certificate_->subject().locality_name),
539 UTF8ToUTF16(certificate_->subject().state_or_province_name),
540 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01541 } else {
542 locality = l10n_util::GetStringFUTF16(
lgarronfc1d5e52017-05-03 23:15:21543 IDS_PAGE_INFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21544 UTF8ToUTF16(certificate_->subject().locality_name),
545 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01546 }
jam8ae7cad2016-09-08 23:55:21547 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01548 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39549 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED,
jam8ae7cad2016-09-08 23:55:21550 UTF8ToUTF16(certificate_->subject().organization_names[0]),
estarkcf305562016-11-15 03:45:39551 locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01552 } else {
553 // Non-EV OK HTTPS page.
estarkcf305562016-11-15 03:45:39554 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
rsleevi4f8012722014-09-30 01:28:01555 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21556 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01557 if (issuer_name.empty()) {
558 issuer_name.assign(l10n_util::GetStringUTF16(
559 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
560 }
[email protected]94c74b42013-12-02 15:19:49561
rsleevi4f8012722014-09-30 01:28:01562 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39563 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
rsleevi4f8012722014-09-30 01:28:01564 }
elawrencebe87bd62017-01-10 16:08:59565 if (security_info.sha1_in_chain) {
566 site_identity_status_ =
567 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM;
568 site_identity_details_ +=
569 UTF8ToUTF16("\n\n") +
570 l10n_util::GetStringUTF16(
571 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM);
rsleevi4f8012722014-09-30 01:28:01572 }
[email protected]03ef4b2a2012-03-06 15:04:20573 }
574 } else {
575 // HTTP or HTTPS with errors (not warnings).
576 site_identity_details_.assign(l10n_util::GetStringUTF16(
577 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
jam8ae7cad2016-09-08 23:55:21578 if (!security_info.scheme_is_cryptographic || !security_info.certificate)
[email protected]03ef4b2a2012-03-06 15:04:20579 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
580 else
581 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
582
[email protected]a04db822013-12-11 19:14:40583 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59584 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59585 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
jam8ae7cad2016-09-08 23:55:21586 certificate_, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20587 for (size_t i = 0; i < errors.size(); ++i) {
588 site_identity_details_ += bullet;
589 site_identity_details_ += errors[i].short_description();
590 }
591
estarka3121f6b2015-09-18 21:15:59592 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20593 site_identity_details_ += ASCIIToUTF16("\n\n");
lgarron1a6300d2017-03-18 03:33:04594 site_identity_details_ +=
595 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
[email protected]03ef4b2a2012-03-06 15:04:20596 }
597 }
598
599 // Site Connection
600 // We consider anything less than 80 bits encryption to be weak encryption.
601 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
602 // weakly encrypted connections.
603 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
604
jshin1fb76462016-04-05 22:13:03605 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19606 if (subject_name.empty()) {
607 subject_name.assign(
608 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
609 }
610
jam8ae7cad2016-09-08 23:55:21611 if (!security_info.certificate || !security_info.scheme_is_cryptographic) {
estarka3121f6b2015-09-18 21:15:59612 // Page is still loading (so SSL status is not yet available) or
613 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58614 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
615
616 site_connection_details_.assign(l10n_util::GetStringFUTF16(
617 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
618 subject_name));
estarka3121f6b2015-09-18 21:15:59619 } else if (security_info.security_bits < 0) {
620 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20621 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59622 } else if (security_info.security_bits == 0) {
esecklercac56b62016-11-16 13:49:44623 DCHECK_NE(security_info.security_level, security_state::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20624 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
625 site_connection_details_.assign(l10n_util::GetStringFUTF16(
626 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
627 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20628 } else {
629 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22630
lgarron3e2c33e2016-08-25 06:33:43631 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22632 site_connection_details_.assign(l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04633 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, subject_name));
Adam Langley71c2b59b2014-11-13 00:34:22634 } else {
635 site_connection_details_.assign(l10n_util::GetStringFUTF16(
636 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
637 subject_name));
638 }
639
thestig4427f13b2017-06-20 20:42:47640 ReportAnyInsecureContent(security_info, &site_connection_status_,
641 &site_connection_details_);
[email protected]03ef4b2a2012-03-06 15:04:20642 }
643
avi655876a2015-12-25 07:18:15644 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59645 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
646 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20647 int ssl_version =
estarka3121f6b2015-09-18 21:15:59648 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20649 const char* ssl_version_str;
650 net::SSLVersionToString(&ssl_version_str, ssl_version);
651 site_connection_details_ += ASCIIToUTF16("\n\n");
652 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04653 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, ASCIIToUTF16(ssl_version_str));
[email protected]03ef4b2a2012-03-06 15:04:20654
[email protected]03ef4b2a2012-03-06 15:04:20655 const char *key_exchange, *cipher, *mac;
davidben56a8aece2016-10-14 18:20:56656 bool is_aead, is_tls13;
657 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
658 &is_tls13, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20659
660 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57661 if (is_aead) {
davidben56a8aece2016-10-14 18:20:56662 if (is_tls13) {
663 // For TLS 1.3 ciphers, report the group (historically, curve) as the
664 // key exchange.
665 key_exchange = SSL_get_curve_name(security_info.key_exchange_group);
666 if (!key_exchange) {
667 NOTREACHED();
668 key_exchange = "";
669 }
670 }
[email protected]b6c1d9e82013-06-12 17:26:57671 site_connection_details_ += l10n_util::GetStringFUTF16(
672 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
673 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
674 } else {
675 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04676 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, ASCIIToUTF16(cipher),
677 ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
[email protected]b6c1d9e82013-06-12 17:26:57678 }
[email protected]03ef4b2a2012-03-06 15:04:20679 }
[email protected]e583f752012-08-30 13:26:21680
[email protected]71cd5ef2014-08-13 21:22:04681 // Check if a user decision has been made to allow or deny certificates with
682 // errors on this site.
683 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50684 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04685 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40686 // Only show an SSL decision revoke button if the user has chosen to bypass
687 // SSL host errors for this host in the past.
688 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]03ef4b2a2012-03-06 15:04:20689}
[email protected]0b9fdd72012-04-04 10:00:33690
lgarron617a30f32017-03-24 21:42:07691void PageInfo::PresentSitePermissions() {
[email protected]df818272012-04-20 13:10:50692 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38693 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50694
lgarron617a30f32017-03-24 21:42:07695 PageInfoUI::PermissionInfo permission_info;
[email protected]df818272012-04-20 13:10:50696 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
697 permission_info.type = kPermissionType[i];
698
csharrisonad1eaa6c2017-05-11 17:14:38699 if (!ShouldShowPermission(permission_info.type, site_url_,
700 content_settings_)) {
mgiucaa319f212016-01-14 03:30:11701 continue;
csharrisonad1eaa6c2017-05-11 17:14:38702 }
mgiucaa319f212016-01-14 03:30:11703
[email protected]df818272012-04-20 13:10:50704 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32705 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
706 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21707 DCHECK(value.get());
jdoerriedc72ee942016-12-07 15:43:28708 if (value->GetType() == base::Value::Type::INTEGER) {
sashab2b2a314f2015-01-17 06:42:21709 permission_info.setting =
710 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26711 } else {
sashab2b2a314f2015-01-17 06:42:21712 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26713 }
714
[email protected]8bdf45c32012-08-04 00:12:55715 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28716 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50717
[email protected]b1d113d2012-06-27 21:27:34718 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21719 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34720 permission_info.default_setting = permission_info.setting;
721 permission_info.setting = CONTENT_SETTING_DEFAULT;
722 } else {
723 permission_info.default_setting =
724 content_settings_->GetDefaultContentSetting(permission_info.type,
725 NULL);
[email protected]df818272012-04-20 13:10:50726 }
palmer0da10b32015-02-11 00:42:19727
patricialor2a4f41a2017-03-08 02:52:56728 // For permissions that are still prompting the user and haven't been
729 // explicitly set by another source, check its embargo status.
730 if (PermissionUtil::IsPermission(permission_info.type) &&
731 permission_info.setting == CONTENT_SETTING_DEFAULT &&
732 permission_info.source ==
733 content_settings::SettingSource::SETTING_SOURCE_USER) {
734 // TODO(raymes): Use GetPermissionStatus() to retrieve information
735 // about *all* permissions once it has default behaviour implemented for
736 // ContentSettingTypes that aren't permissions.
737 PermissionResult permission_result =
738 PermissionManager::Get(profile_)->GetPermissionStatus(
739 permission_info.type, site_url_, site_url_);
740
741 // If under embargo, update |permission_info| to reflect that.
742 if (permission_result.content_setting == CONTENT_SETTING_BLOCK &&
743 (permission_result.source ==
744 PermissionStatusSource::MULTIPLE_DISMISSALS ||
745 permission_result.source ==
746 PermissionStatusSource::SAFE_BROWSING_BLACKLIST))
747 permission_info.setting = permission_result.content_setting;
748 }
749
palmer64a099982016-03-09 21:26:11750 permission_info_list.push_back(permission_info);
[email protected]df818272012-04-20 13:10:50751 }
752
reillyg85f57db2016-01-12 23:14:38753 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
754 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10755 const GURL origin = site_url_.GetOrigin();
756 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32757 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38758 chosen_object_info_list.push_back(
lgarron617a30f32017-03-24 21:42:07759 base::MakeUnique<PageInfoUI::ChosenObjectInfo>(ui_info,
760 std::move(object)));
reillyg85f57db2016-01-12 23:14:38761 }
762 }
763
avi09dd4d02016-10-14 20:40:09764 ui_->SetPermissionInfo(permission_info_list,
765 std::move(chosen_object_info_list));
[email protected]0b9fdd72012-04-04 10:00:33766}
767
lgarron617a30f32017-03-24 21:42:07768void PageInfo::PresentSiteData() {
[email protected]df818272012-04-20 13:10:50769 CookieInfoList cookie_info_list;
vabrbab3ffcb2016-10-04 10:08:10770 const LocalSharedObjectsContainer& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34771 tab_specific_content_settings()->allowed_local_shared_objects();
vabrbab3ffcb2016-10-04 10:08:10772 const LocalSharedObjectsContainer& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34773 tab_specific_content_settings()->blocked_local_shared_objects();
774
775 // Add first party cookie and site data counts.
lgarron617a30f32017-03-24 21:42:07776 PageInfoUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34777 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
778 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15779 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34780 cookie_info_list.push_back(cookie_info);
781
782 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34783 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
784 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15785 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50786 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33787
[email protected]df818272012-04-20 13:10:50788 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33789}
[email protected]16de6de2012-04-04 12:24:14790
lgarron617a30f32017-03-24 21:42:07791void PageInfo::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04792 // After initialization the status about the site's connection and its
793 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41794 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
795 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
lgarron617a30f32017-03-24 21:42:07796 PageInfoUI::IdentityInfo info;
[email protected]24c8818c2012-04-25 09:57:41797 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
798 info.site_identity = UTF16ToUTF8(organization_name());
799 else
jshin1fb76462016-04-05 22:13:03800 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41801
802 info.connection_status = site_connection_status_;
lgarron1a6300d2017-03-18 03:33:04803 info.connection_status_description = UTF16ToUTF8(site_connection_details_);
[email protected]24c8818c2012-04-25 09:57:41804 info.identity_status = site_identity_status_;
lgarron1a6300d2017-03-18 03:33:04805 info.identity_status_description = UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21806 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04807 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
[email protected]24c8818c2012-04-25 09:57:41808 ui_->SetIdentityInfo(info);
809}