blob: e0e59f3123c29b3697d3ff007ce67d236b741af6 [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"
jialiul02aad2d2015-04-01 18:56:0322#include "chrome/browser/browser_process.h"
[email protected]6b8a3c742014-07-25 00:25:3523#include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h"
[email protected]b0cb5e82012-07-19 19:22:4724#include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
25#include "chrome/browser/browsing_data/browsing_data_database_helper.h"
26#include "chrome/browser/browsing_data/browsing_data_file_system_helper.h"
27#include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
28#include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
peconn5100d432015-09-16 12:03:0829#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
vabrbab3ffcb2016-10-04 10:08:1030#include "chrome/browser/content_settings/local_shared_objects_container.h"
[email protected]77a91c72012-08-13 16:19:3431#include "chrome/browser/history/history_service_factory.h"
palmerf2cba0d2015-08-27 23:15:0632#include "chrome/browser/infobars/infobar_service.h"
reillyg85f57db2016-01-12 23:14:3833#include "chrome/browser/permissions/chooser_context_base.h"
patricialor7131c1fe2017-04-07 01:25:5234#include "chrome/browser/permissions/permission_decision_auto_blocker.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"
Jialiu Lin11e18542017-08-14 18:16:2640#include "chrome/browser/safe_browsing/safe_browsing_service.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"
tbansal08a0e3e2017-06-30 21:30:0854#include "components/content_settings/core/common/content_settings_utils.h"
nzolghadrd87a308d2016-12-07 15:45:5655#include "components/rappor/public/rappor_utils.h"
56#include "components/rappor/rappor_service_impl.h"
felt2493b4452015-09-17 20:33:5957#include "components/ssl_errors/error_info.h"
thestig4a2e88e2016-08-27 23:23:5158#include "components/strings/grit/components_chromium_strings.h"
59#include "components/strings/grit/components_strings.h"
melandory7be36d312017-03-29 15:51:1260#include "components/subresource_filter/core/browser/subresource_filter_features.h"
palmer153af982015-09-15 02:04:1961#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3362#include "content/public/browser/browser_thread.h"
[email protected]eb2140c2013-07-29 12:37:3463#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2064#include "content/public/common/url_constants.h"
[email protected]6e7845ae2013-03-29 21:48:1165#include "net/cert/cert_status_flags.h"
66#include "net/cert/x509_certificate.h"
[email protected]536fd0b2013-03-14 17:41:5767#include "net/ssl/ssl_cipher_suite_names.h"
68#include "net/ssl/ssl_connection_status_flags.h"
tfarina29a3a1742016-10-28 18:47:3369#include "third_party/boringssl/src/include/openssl/ssl.h"
[email protected]03ef4b2a2012-03-06 15:04:2070#include "ui/base/l10n/l10n_util.h"
Patricia Lora21a04cf2017-06-05 02:53:2971#include "url/origin.h"
[email protected]03ef4b2a2012-03-06 15:04:2072
[email protected]24a9f1c92013-11-13 12:33:3773#if defined(OS_CHROMEOS)
74#include "chrome/browser/chromeos/policy/policy_cert_service.h"
75#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
76#endif
77
estade3feb83f2015-09-01 23:00:4978#if !defined(OS_ANDROID)
mgiucaa319f212016-01-14 03:30:1179#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
lgarron617a30f32017-03-24 21:42:0780#include "chrome/browser/ui/page_info/page_info_infobar_delegate.h"
estade3feb83f2015-09-01 23:00:4981#endif
82
Jialiu Lin11e18542017-08-14 18:16:2683#if defined(SAFE_BROWSING_DB_LOCAL)
84#include "components/safe_browsing/password_protection/password_protection_service.h"
85#endif
86
[email protected]ab6df3b12013-12-24 23:32:2687using base::ASCIIToUTF16;
88using base::UTF8ToUTF16;
[email protected]f729d7a2013-12-26 07:07:5689using base::UTF16ToUTF8;
[email protected]0b9fdd72012-04-04 10:00:3390using content::BrowserThread;
91
92namespace {
93
jww1ed8ea72014-09-02 20:43:2594// Events for UMA. Do not reorder or change!
95enum SSLCertificateDecisionsDidRevoke {
96 USER_CERT_DECISIONS_NOT_REVOKED = 0,
97 USER_CERT_DECISIONS_REVOKED,
98 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM
99};
100
lgarron617a30f32017-03-24 21:42:07101// The list of content settings types to display on the Page Info UI. THE
csharrisonad1eaa6c2017-05-11 17:14:38102// ORDER OF THESE ITEMS IS IMPORTANT and comes from https://crbug.com/610358. To
103// propose changing it, email [email protected].
[email protected]0b9fdd72012-04-04 10:00:33104ContentSettingsType kPermissionType[] = {
sashab2b2a314f2015-01-17 06:42:21105 CONTENT_SETTINGS_TYPE_GEOLOCATION,
sashab2b2a314f2015-01-17 06:42:21106 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
107 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
palmer0da10b32015-02-11 00:42:19108 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
palmer7715e332016-05-27 00:41:19109 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
lshange085f202016-06-14 01:25:08110#if !defined(OS_ANDROID)
palmer7715e332016-05-27 00:41:19111 CONTENT_SETTINGS_TYPE_PLUGINS,
112 CONTENT_SETTINGS_TYPE_IMAGES,
lshange085f202016-06-14 01:25:08113#endif
palmer7715e332016-05-27 00:41:19114 CONTENT_SETTINGS_TYPE_POPUPS,
Charles Harrison239d47982017-06-13 02:42:31115 CONTENT_SETTINGS_TYPE_ADS,
nsatragno670fe922016-04-08 14:10:50116 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
Tommy Steimela8c3757e2017-08-24 00:15:46117 CONTENT_SETTINGS_TYPE_SOUND,
palmer7715e332016-05-27 00:41:19118 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
finnur46cafd42016-09-22 10:27:17119 CONTENT_SETTINGS_TYPE_AUTOPLAY,
palmer7715e332016-05-27 00:41:19120 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
[email protected]0b9fdd72012-04-04 10:00:33121};
122
lgarron617a30f32017-03-24 21:42:07123// Determines whether to show permission |type| in the Page Info UI. Only
mgiucaa319f212016-01-14 03:30:11124// applies to permissions listed in |kPermissionType|.
csharrisonad1eaa6c2017-05-11 17:14:38125bool ShouldShowPermission(ContentSettingsType type,
126 const GURL& site_url,
127 HostContentSettingsMap* content_settings) {
mgiucaa319f212016-01-14 03:30:11128#if !defined(OS_ANDROID)
finnur46cafd42016-09-22 10:27:17129 // Autoplay is Android-only at the moment.
mgiuca273b9672016-11-11 02:22:20130 if (type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
mgiuca0f3e1f72016-05-13 01:56:27131 return false;
mgiucaa319f212016-01-14 03:30:11132#endif
133
Charles Harrison239d47982017-06-13 02:42:31134 if (type == CONTENT_SETTINGS_TYPE_ADS) {
csharrisonad1eaa6c2017-05-11 17:14:38135 if (!base::FeatureList::IsEnabled(
136 subresource_filter::kSafeBrowsingSubresourceFilterExperimentalUI)) {
137 return false;
138 }
139
140 // The setting for subresource filtering should not show up if the site is
141 // not activated, both on android and desktop platforms.
142 return content_settings->GetWebsiteSetting(
Charles Harrison239d47982017-06-13 02:42:31143 site_url, GURL(), CONTENT_SETTINGS_TYPE_ADS_DATA, std::string(),
144 nullptr) != nullptr;
melandory7be36d312017-03-29 15:51:12145 }
146
Tommy Steimela8c3757e2017-08-24 00:15:46147 if (type == CONTENT_SETTINGS_TYPE_SOUND)
148 return base::FeatureList::IsEnabled(features::kSoundContentSetting);
149
mgiucaa319f212016-01-14 03:30:11150 return true;
151}
152
esecklercac56b62016-11-16 13:49:44153void CheckContentStatus(security_state::ContentStatus content_status,
estark00e83f12016-08-19 18:24:04154 bool* displayed,
155 bool* ran) {
156 switch (content_status) {
esecklercac56b62016-11-16 13:49:44157 case security_state::CONTENT_STATUS_DISPLAYED:
estark00e83f12016-08-19 18:24:04158 *displayed = true;
159 break;
esecklercac56b62016-11-16 13:49:44160 case security_state::CONTENT_STATUS_RAN:
estark00e83f12016-08-19 18:24:04161 *ran = true;
162 break;
esecklercac56b62016-11-16 13:49:44163 case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN:
estark00e83f12016-08-19 18:24:04164 *displayed = true;
165 *ran = true;
166 break;
esecklercac56b62016-11-16 13:49:44167 case security_state::CONTENT_STATUS_UNKNOWN:
168 case security_state::CONTENT_STATUS_NONE:
estark00e83f12016-08-19 18:24:04169 break;
170 }
171}
172
elawrenceb2ac2a232017-03-27 21:46:25173// If the |security_info| indicates that mixed content or certificate errors
174// were present, update |connection_status| and |connection_details|.
175void ReportAnyInsecureContent(const security_state::SecurityInfo& security_info,
thestig4427f13b2017-06-20 20:42:47176 PageInfo::SiteConnectionStatus* connection_status,
177 base::string16* connection_details) {
elawrenceb2ac2a232017-03-27 21:46:25178 bool displayed_insecure_content = false;
179 bool ran_insecure_content = false;
180 CheckContentStatus(security_info.mixed_content_status,
181 &displayed_insecure_content, &ran_insecure_content);
182 // Only note subresources with certificate errors if the main resource was
183 // loaded without major certificate errors. If the main resource had a
184 // certificate error, then it would not be that useful (and could
185 // potentially be confusing) to warn about subresources that had certificate
186 // errors too.
187 if (!net::IsCertStatusError(security_info.cert_status) ||
188 net::IsCertStatusMinorError(security_info.cert_status)) {
189 CheckContentStatus(security_info.content_with_cert_errors_status,
190 &displayed_insecure_content, &ran_insecure_content);
191 }
192
193 // Only one insecure content warning is displayed; show the most severe.
194 if (ran_insecure_content) {
thestig4427f13b2017-06-20 20:42:47195 *connection_status =
elawrenceb2ac2a232017-03-27 21:46:25196 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE;
thestig4427f13b2017-06-20 20:42:47197 connection_details->assign(l10n_util::GetStringFUTF16(
198 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25199 l10n_util::GetStringUTF16(
200 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR)));
estark00e83f12016-08-19 18:24:04201 return;
202 }
elawrenceb2ac2a232017-03-27 21:46:25203 if (security_info.contained_mixed_form) {
thestig4427f13b2017-06-20 20:42:47204 *connection_status = PageInfo::SITE_CONNECTION_STATUS_INSECURE_FORM_ACTION;
205 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_FORM_WARNING)));
209 return;
210 }
211 if (displayed_insecure_content) {
thestig4427f13b2017-06-20 20:42:47212 *connection_status =
elawrenceb2ac2a232017-03-27 21:46:25213 PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
thestig4427f13b2017-06-20 20:42:47214 connection_details->assign(l10n_util::GetStringFUTF16(
215 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25216 l10n_util::GetStringUTF16(
217 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
218 }
estark00e83f12016-08-19 18:24:04219}
220
estarkfcfccdb82016-11-14 02:17:29221void GetSiteIdentityByMaliciousContentStatus(
esecklercac56b62016-11-16 13:49:44222 security_state::MaliciousContentStatus malicious_content_status,
lgarron617a30f32017-03-24 21:42:07223 PageInfo::SiteIdentityStatus* status,
estarkfcfccdb82016-11-14 02:17:29224 base::string16* details) {
225 switch (malicious_content_status) {
esecklercac56b62016-11-16 13:49:44226 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
estarkfcfccdb82016-11-14 02:17:29227 NOTREACHED();
228 break;
esecklercac56b62016-11-16 13:49:44229 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
lgarron617a30f32017-03-24 21:42:07230 *status = PageInfo::SITE_IDENTITY_STATUS_MALWARE;
lgarronfc1d5e52017-05-03 23:15:21231 *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MALWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29232 break;
esecklercac56b62016-11-16 13:49:44233 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
lgarron617a30f32017-03-24 21:42:07234 *status = PageInfo::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
lgarron1a6300d2017-03-18 03:33:04235 *details =
lgarronfc1d5e52017-05-03 23:15:21236 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SOCIAL_ENGINEERING_DETAILS);
estarkfcfccdb82016-11-14 02:17:29237 break;
esecklercac56b62016-11-16 13:49:44238 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
lgarron617a30f32017-03-24 21:42:07239 *status = PageInfo::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
lgarron1a6300d2017-03-18 03:33:04240 *details =
lgarronfc1d5e52017-05-03 23:15:21241 l10n_util::GetStringUTF16(IDS_PAGE_INFO_UNWANTED_SOFTWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29242 break;
Jialiu Lin11e18542017-08-14 18:16:26243 case security_state::MALICIOUS_CONTENT_STATUS_PASSWORD_REUSE:
Jialiu Linfeb6bb32017-08-30 00:21:36244#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26245 *status = PageInfo::SITE_IDENTITY_STATUS_PASSWORD_REUSE;
246 *details =
247 l10n_util::GetStringUTF16(IDS_PAGE_INFO_CHANGE_PASSWORD_DETAILS);
248#endif
249 break;
estarkfcfccdb82016-11-14 02:17:29250 }
251}
252
jshin1fb76462016-04-05 22:13:03253base::string16 GetSimpleSiteName(const GURL& url) {
benwells2337b8102016-04-20 01:53:53254 return url_formatter::FormatUrlForSecurityDisplay(
255 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
palmer153af982015-09-15 02:04:19256}
257
reillyg85f57db2016-01-12 23:14:38258ChooserContextBase* GetUsbChooserContext(Profile* profile) {
259 return UsbChooserContextFactory::GetForProfile(profile);
260}
261
262// The list of chooser types that need to display entries in the Website
263// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
264// email [email protected].
Andrew Grieved1978b0e2017-07-28 15:53:41265const PageInfo::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52266 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
lgarron617a30f32017-03-24 21:42:07267 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_PAGE_INFO_USB_DEVICE_LABEL,
268 IDS_PAGE_INFO_DELETE_USB_DEVICE, "name"},
reillyg85f57db2016-01-12 23:14:38269};
270
[email protected]0b9fdd72012-04-04 10:00:33271} // namespace
272
lgarron617a30f32017-03-24 21:42:07273PageInfo::PageInfo(PageInfoUI* ui,
274 Profile* profile,
275 TabSpecificContentSettings* tab_specific_content_settings,
276 content::WebContents* web_contents,
277 const GURL& url,
278 const security_state::SecurityInfo& security_info)
[email protected]df818272012-04-20 13:10:50279 : TabSpecificContentSettings::SiteDataObserver(
280 tab_specific_content_settings),
dominicknbdd53b5f2016-09-28 01:08:13281 content::WebContentsObserver(web_contents),
[email protected]df818272012-04-20 13:10:50282 ui_(ui),
[email protected]66f157312012-08-01 13:50:26283 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33284 site_url_(url),
285 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]03ef4b2a2012-03-06 15:04:20286 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
alshabalin5e894c12016-10-25 06:47:46287 show_ssl_decision_revoke_button_(false),
peconn5100d432015-09-16 12:03:08288 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04289 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25290 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19291 did_revoke_user_ssl_decisions_(false),
estark8d67cd7a2016-10-24 05:06:41292 profile_(profile),
Jialiu Lin11e18542017-08-14 18:16:26293 security_level_(security_state::NONE),
Jialiu Linfeb6bb32017-08-30 00:21:36294#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26295 password_protection_service_(nullptr),
296#endif
297 show_change_password_buttons_(false) {
Jialiu Linfeb6bb32017-08-30 00:21:36298#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26299 safe_browsing::SafeBrowsingService* sb_service =
300 g_browser_process->safe_browsing_service();
301 if (sb_service && sb_service->enabled_by_prefs()) {
302 password_protection_service_ =
303 sb_service->GetPasswordProtectionService(profile_);
304 }
305#endif
306
estarka3121f6b2015-09-18 21:15:59307 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33308
309 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50310 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41311 PresentSiteIdentity();
[email protected]e22d64f2012-09-10 09:03:23312
lgarron617a30f32017-03-24 21:42:07313 // Every time the Page Info UI is opened a |PageInfo| object is
314 // created. So this counts how ofter the Page Info UI is opened.
315 RecordPageInfoAction(PAGE_INFO_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20316}
317
lgarron617a30f32017-03-24 21:42:07318PageInfo::~PageInfo() {}
[email protected]03ef4b2a2012-03-06 15:04:20319
lgarron617a30f32017-03-24 21:42:07320void PageInfo::RecordPageInfoAction(PageInfoAction action) {
321 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04322
estark8d67cd7a2016-10-24 05:06:41323 std::string histogram_name;
palmeree0e5af2015-06-05 03:10:40324
estark8d67cd7a2016-10-24 05:06:41325 if (site_url_.SchemeIsCryptographic()) {
esecklercac56b62016-11-16 13:49:44326 if (security_level_ == security_state::SECURE ||
327 security_level_ == security_state::EV_SECURE) {
estark8d67cd7a2016-10-24 05:06:41328 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Valid",
lgarron617a30f32017-03-24 21:42:07329 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44330 } else if (security_level_ == security_state::NONE) {
estark8d67cd7a2016-10-24 05:06:41331 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded",
lgarron617a30f32017-03-24 21:42:07332 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44333 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41334 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07335 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41336 }
337 return;
338 }
339
esecklercac56b62016-11-16 13:49:44340 if (security_level_ == security_state::HTTP_SHOW_WARNING) {
estark8d67cd7a2016-10-24 05:06:41341 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning",
lgarron617a30f32017-03-24 21:42:07342 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44343 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41344 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07345 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41346 } else {
347 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral",
lgarron617a30f32017-03-24 21:42:07348 action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04349 }
350}
351
lgarron617a30f32017-03-24 21:42:07352void PageInfo::OnSitePermissionChanged(ContentSettingsType type,
353 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23354 // Count how often a permission for a specific content type is changed using
lgarron617a30f32017-03-24 21:42:07355 // the Page Info UI.
raymes4a13d432015-09-08 00:44:07356 size_t num_values;
357 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
dchengf6f4e4942017-03-30 23:55:57358 UMA_HISTOGRAM_EXACT_LINEAR("WebsiteSettings.OriginInfo.PermissionChanged",
359 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56360
361 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
dchengf6f4e4942017-03-30 23:55:57362 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56363 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07364 num_values);
tommycli34cf29bf2016-09-08 05:46:25365
366 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
367 rappor::SampleDomainAndRegistryFromGURL(
368 g_browser_process->rappor_service(),
369 "ContentSettings.Plugins.AddedAllowException", site_url_);
370 }
sashab9debecd2014-12-18 04:15:56371 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
dchengf6f4e4942017-03-30 23:55:57372 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56373 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07374 num_values);
sashab9debecd2014-12-18 04:15:56375 }
[email protected]e22d64f2012-09-10 09:03:23376
lgarron04a93502014-11-04 22:25:04377 // This is technically redundant given the histogram above, but putting the
378 // total count of permission changes in another histogram makes it easier to
lgarron026e9c42017-04-07 20:09:31379 // compare it against other kinds of actions in Page Info.
lgarron617a30f32017-03-24 21:42:07380 RecordPageInfoAction(PAGE_INFO_CHANGED_PERMISSION);
lgarron04a93502014-11-04 22:25:04381
stefanocs8b3490cc2016-07-28 05:32:52382 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
patricialor7131c1fe2017-04-07 01:25:52383 profile_, site_url_, site_url_, type, PermissionSourceUI::OIB);
stefanocs8b3490cc2016-07-28 05:32:52384
patricialor7131c1fe2017-04-07 01:25:52385 // The permission may have been blocked due to being under embargo, so if it
386 // was changed away from BLOCK, clear embargo status if it exists.
387 if (setting != CONTENT_SETTING_BLOCK) {
388 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveEmbargoByUrl(
389 site_url_, type);
390 }
raymesfbaaaaa2015-11-10 02:20:40391 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
392 setting);
[email protected]df818272012-04-20 13:10:50393
[email protected]66f157312012-08-01 13:50:26394 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24395
396 // Refresh the UI to reflect the new setting.
397 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50398}
399
lgarron617a30f32017-03-24 21:42:07400void PageInfo::OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info,
401 const base::DictionaryValue& object) {
reillyg85f57db2016-01-12 23:14:38402 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
403 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10404 const GURL origin = site_url_.GetOrigin();
405 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38406
407 show_info_bar_ = true;
408
409 // Refresh the UI to reflect the changed settings.
410 PresentSitePermissions();
411}
412
lgarron617a30f32017-03-24 21:42:07413void PageInfo::OnSiteDataAccessed() {
[email protected]df818272012-04-20 13:10:50414 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33415}
416
lgarron617a30f32017-03-24 21:42:07417void PageInfo::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49418#if defined(OS_ANDROID)
419 NOTREACHED();
420#else
dominicknbdd53b5f2016-09-28 01:08:13421 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
palmerf2cba0d2015-08-27 23:15:06422 InfoBarService* infobar_service =
dominicknbdd53b5f2016-09-28 01:08:13423 InfoBarService::FromWebContents(web_contents());
palmerf2cba0d2015-08-27 23:15:06424 if (infobar_service)
lgarron617a30f32017-03-24 21:42:07425 PageInfoInfoBarDelegate::Create(infobar_service);
palmerf2cba0d2015-08-27 23:15:06426 }
jww1ed8ea72014-09-02 20:43:25427
428 SSLCertificateDecisionsDidRevoke user_decision =
429 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
430 : USER_CERT_DECISIONS_NOT_REVOKED;
431
432 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
433 user_decision,
434 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49435#endif
jww1ed8ea72014-09-02 20:43:25436}
437
lgarron617a30f32017-03-24 21:42:07438void PageInfo::OnRevokeSSLErrorBypassButtonPressed() {
jww1ed8ea72014-09-02 20:43:25439 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29440 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
441 site_url().host());
jww1ed8ea72014-09-02 20:43:25442 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26443}
444
Patricia Lora21a04cf2017-06-05 02:53:29445void PageInfo::OpenSiteSettingsView() {
446 // By default, this opens the general Content Settings pane. If the
447 // |kSiteSettings| and/or |kSiteDetails| flags are enabled this opens a
448 // settings page specific to the current origin of the page. crbug.com/655876
449 url::Origin site_origin = url::Origin(site_url());
450 std::string link_destination(chrome::kChromeUIContentSettingsURL);
Patti5f083d22017-09-07 02:13:19451 // TODO(https://crbug.com/444047): Site Details should work with file:// urls
452 // when this bug is fixed, so add it to the whitelist when that happens.
Patricia Lora21a04cf2017-06-05 02:53:29453 if ((base::CommandLine::ForCurrentProcess()->HasSwitch(
454 switches::kEnableSiteSettings) ||
455 base::FeatureList::IsEnabled(features::kSiteDetails)) &&
Patti5f083d22017-09-07 02:13:19456 !site_origin.unique() &&
457 (site_url().SchemeIsHTTPOrHTTPS() ||
458 site_url().SchemeIs(content_settings::kExtensionScheme))) {
Patricia Lora21a04cf2017-06-05 02:53:29459 std::string origin_string = site_origin.Serialize();
460 url::RawCanonOutputT<char> percent_encoded_origin;
461 url::EncodeURIComponent(origin_string.c_str(), origin_string.length(),
462 &percent_encoded_origin);
463 link_destination = chrome::kChromeUISiteDetailsPrefixURL +
464 std::string(percent_encoded_origin.data(),
465 percent_encoded_origin.length());
466 }
467 web_contents()->OpenURL(
468 content::OpenURLParams(GURL(link_destination), content::Referrer(),
469 WindowOpenDisposition::NEW_FOREGROUND_TAB,
470 ui::PAGE_TRANSITION_LINK, false));
471 RecordPageInfoAction(PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED);
472}
473
Jialiu Lin11e18542017-08-14 18:16:26474void PageInfo::OnChangePasswordButtonPressed(
475 content::WebContents* web_contents) {
Jialiu Linfeb6bb32017-08-30 00:21:36476#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26477 DCHECK(password_protection_service_);
478 password_protection_service_->OnWarningDone(
479 web_contents, safe_browsing::PasswordProtectionService::PAGE_INFO,
480 safe_browsing::PasswordProtectionService::CHANGE_PASSWORD);
481#endif
482}
483
484void PageInfo::OnWhitelistPasswordReuseButtonPressed(
485 content::WebContents* web_contents) {
Jialiu Linfeb6bb32017-08-30 00:21:36486#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26487 DCHECK(password_protection_service_);
488 password_protection_service_->OnWarningDone(
489 web_contents, safe_browsing::PasswordProtectionService::PAGE_INFO,
490 safe_browsing::PasswordProtectionService::MARK_AS_LEGITIMATE);
491#endif
492}
493
lgarron617a30f32017-03-24 21:42:07494void PageInfo::Init(const GURL& url,
495 const security_state::SecurityInfo& security_info) {
thestig0c55ee32017-06-20 22:17:51496#if !defined(OS_ANDROID)
meacerde53fcff2016-10-12 19:21:57497 // On desktop, internal URLs aren't handled by this class. Instead, a
lgarron026e9c42017-04-07 20:09:31498 // custom and simpler bubble is shown.
meacerde53fcff2016-10-12 19:21:57499 DCHECK(!url.SchemeIs(content::kChromeUIScheme) &&
500 !url.SchemeIs(content::kChromeDevToolsScheme) &&
501 !url.SchemeIs(content::kViewSourceScheme) &&
502 !url.SchemeIs(content_settings::kExtensionScheme));
503#endif
504
thestig0c55ee32017-06-20 22:17:51505 bool is_chrome_ui_native_scheme = false;
zpengdb4a58e2017-01-10 17:40:32506#if defined(OS_ANDROID)
thestig0c55ee32017-06-20 22:17:51507 is_chrome_ui_native_scheme = url.SchemeIs(chrome::kChromeUINativeScheme);
sashab97894ce2014-10-22 10:08:33508#endif
509
estark8d67cd7a2016-10-24 05:06:41510 security_level_ = security_info.security_level;
511
upendrag.gowda60886a6e2015-10-31 05:51:09512 if (url.SchemeIs(url::kAboutScheme)) {
513 // All about: URLs except about:blank are redirected.
514 DCHECK_EQ(url::kAboutBlankURL, url.spec());
515 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
516 site_identity_details_ =
517 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
518 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
519 site_connection_details_ = l10n_util::GetStringFUTF16(
520 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
521 UTF8ToUTF16(url.spec()));
522 return;
523 }
524
thestig0c55ee32017-06-20 22:17:51525 if (url.SchemeIs(content::kChromeUIScheme) || is_chrome_ui_native_scheme) {
[email protected]03ef4b2a2012-03-06 15:04:20526 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
527 site_identity_details_ =
528 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
529 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
530 return;
531 }
532
[email protected]03ef4b2a2012-03-06 15:04:20533 // Identity section.
jam8ae7cad2016-09-08 23:55:21534 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11535
estarkfcfccdb82016-11-14 02:17:29536 if (security_info.malicious_content_status !=
esecklercac56b62016-11-16 13:49:44537 security_state::MALICIOUS_CONTENT_STATUS_NONE) {
estarkfcfccdb82016-11-14 02:17:29538 // The site has been flagged by Safe Browsing as dangerous.
539 GetSiteIdentityByMaliciousContentStatus(
540 security_info.malicious_content_status, &site_identity_status_,
541 &site_identity_details_);
Jialiu Lin11e18542017-08-14 18:16:26542 show_change_password_buttons_ =
543 security_info.malicious_content_status ==
544 security_state::MALICIOUS_CONTENT_STATUS_PASSWORD_REUSE;
estarkfcfccdb82016-11-14 02:17:29545 } else if (certificate_ &&
546 (!net::IsCertStatusError(security_info.cert_status) ||
547 net::IsCertStatusMinorError(security_info.cert_status))) {
548 // HTTPS with no or minor errors.
estarka3121f6b2015-09-18 21:15:59549 if (security_info.security_level ==
esecklercac56b62016-11-16 13:49:44550 security_state::SECURE_WITH_POLICY_INSTALLED_CERT) {
[email protected]eaf3f322013-04-25 21:53:59551 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37552 site_identity_details_ = l10n_util::GetStringFUTF16(
553 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59554 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20555 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21556 base::string16 issuer_name(
557 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20558 if (issuer_name.empty()) {
559 issuer_name.assign(l10n_util::GetStringUTF16(
560 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
561 }
[email protected]94c74b42013-12-02 15:19:49562
[email protected]03ef4b2a2012-03-06 15:04:20563 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39564 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20565
566 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59567 if (security_info.cert_status &
568 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20569 site_identity_details_ += l10n_util::GetStringUTF16(
570 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59571 } else if (security_info.cert_status &
572 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20573 site_identity_details_ += l10n_util::GetStringUTF16(
574 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
575 } else {
576 NOTREACHED() << "Need to specify string for this warning";
577 }
[email protected]03ef4b2a2012-03-06 15:04:20578 } else {
estarkcf305562016-11-15 03:45:39579 // No major or minor errors.
estarka3121f6b2015-09-18 21:15:59580 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01581 // EV HTTPS page.
estarkcf305562016-11-15 03:45:39582 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
jam8ae7cad2016-09-08 23:55:21583 DCHECK(!certificate_->subject().organization_names.empty());
584 organization_name_ =
585 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01586 // An EV Cert is required to have a city (localityName) and country but
587 // state is "if any".
jam8ae7cad2016-09-08 23:55:21588 DCHECK(!certificate_->subject().locality_name.empty());
589 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01590 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21591 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01592 locality = l10n_util::GetStringFUTF16(
lgarronfc1d5e52017-05-03 23:15:21593 IDS_PAGE_INFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21594 UTF8ToUTF16(certificate_->subject().locality_name),
595 UTF8ToUTF16(certificate_->subject().state_or_province_name),
596 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01597 } else {
598 locality = l10n_util::GetStringFUTF16(
lgarronfc1d5e52017-05-03 23:15:21599 IDS_PAGE_INFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21600 UTF8ToUTF16(certificate_->subject().locality_name),
601 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01602 }
jam8ae7cad2016-09-08 23:55:21603 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01604 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39605 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED,
jam8ae7cad2016-09-08 23:55:21606 UTF8ToUTF16(certificate_->subject().organization_names[0]),
estarkcf305562016-11-15 03:45:39607 locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01608 } else {
609 // Non-EV OK HTTPS page.
estarkcf305562016-11-15 03:45:39610 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
rsleevi4f8012722014-09-30 01:28:01611 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21612 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01613 if (issuer_name.empty()) {
614 issuer_name.assign(l10n_util::GetStringUTF16(
615 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
616 }
[email protected]94c74b42013-12-02 15:19:49617
rsleevi4f8012722014-09-30 01:28:01618 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39619 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
rsleevi4f8012722014-09-30 01:28:01620 }
elawrencebe87bd62017-01-10 16:08:59621 if (security_info.sha1_in_chain) {
622 site_identity_status_ =
623 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM;
624 site_identity_details_ +=
625 UTF8ToUTF16("\n\n") +
626 l10n_util::GetStringUTF16(
627 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM);
rsleevi4f8012722014-09-30 01:28:01628 }
[email protected]03ef4b2a2012-03-06 15:04:20629 }
630 } else {
631 // HTTP or HTTPS with errors (not warnings).
632 site_identity_details_.assign(l10n_util::GetStringUTF16(
633 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
jam8ae7cad2016-09-08 23:55:21634 if (!security_info.scheme_is_cryptographic || !security_info.certificate)
[email protected]03ef4b2a2012-03-06 15:04:20635 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
636 else
637 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
638
[email protected]a04db822013-12-11 19:14:40639 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59640 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59641 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
jam8ae7cad2016-09-08 23:55:21642 certificate_, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20643 for (size_t i = 0; i < errors.size(); ++i) {
644 site_identity_details_ += bullet;
645 site_identity_details_ += errors[i].short_description();
646 }
647
estarka3121f6b2015-09-18 21:15:59648 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20649 site_identity_details_ += ASCIIToUTF16("\n\n");
lgarron1a6300d2017-03-18 03:33:04650 site_identity_details_ +=
651 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
[email protected]03ef4b2a2012-03-06 15:04:20652 }
653 }
654
655 // Site Connection
656 // We consider anything less than 80 bits encryption to be weak encryption.
657 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
658 // weakly encrypted connections.
659 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
660
jshin1fb76462016-04-05 22:13:03661 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19662 if (subject_name.empty()) {
663 subject_name.assign(
664 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
665 }
666
jam8ae7cad2016-09-08 23:55:21667 if (!security_info.certificate || !security_info.scheme_is_cryptographic) {
estarka3121f6b2015-09-18 21:15:59668 // Page is still loading (so SSL status is not yet available) or
669 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58670 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
671
672 site_connection_details_.assign(l10n_util::GetStringFUTF16(
673 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
674 subject_name));
estarka3121f6b2015-09-18 21:15:59675 } else if (security_info.security_bits < 0) {
676 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20677 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59678 } else if (security_info.security_bits == 0) {
esecklercac56b62016-11-16 13:49:44679 DCHECK_NE(security_info.security_level, security_state::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20680 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
681 site_connection_details_.assign(l10n_util::GetStringFUTF16(
682 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
683 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20684 } else {
685 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22686
lgarron3e2c33e2016-08-25 06:33:43687 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22688 site_connection_details_.assign(l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04689 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, subject_name));
Adam Langley71c2b59b2014-11-13 00:34:22690 } else {
691 site_connection_details_.assign(l10n_util::GetStringFUTF16(
692 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
693 subject_name));
694 }
695
thestig4427f13b2017-06-20 20:42:47696 ReportAnyInsecureContent(security_info, &site_connection_status_,
697 &site_connection_details_);
[email protected]03ef4b2a2012-03-06 15:04:20698 }
699
avi655876a2015-12-25 07:18:15700 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59701 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
702 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20703 int ssl_version =
estarka3121f6b2015-09-18 21:15:59704 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20705 const char* ssl_version_str;
706 net::SSLVersionToString(&ssl_version_str, ssl_version);
707 site_connection_details_ += ASCIIToUTF16("\n\n");
708 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04709 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, ASCIIToUTF16(ssl_version_str));
[email protected]03ef4b2a2012-03-06 15:04:20710
[email protected]03ef4b2a2012-03-06 15:04:20711 const char *key_exchange, *cipher, *mac;
davidben56a8aece2016-10-14 18:20:56712 bool is_aead, is_tls13;
713 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
714 &is_tls13, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20715
716 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57717 if (is_aead) {
davidben56a8aece2016-10-14 18:20:56718 if (is_tls13) {
719 // For TLS 1.3 ciphers, report the group (historically, curve) as the
720 // key exchange.
721 key_exchange = SSL_get_curve_name(security_info.key_exchange_group);
722 if (!key_exchange) {
723 NOTREACHED();
724 key_exchange = "";
725 }
726 }
[email protected]b6c1d9e82013-06-12 17:26:57727 site_connection_details_ += l10n_util::GetStringFUTF16(
728 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
729 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
730 } else {
731 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04732 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, ASCIIToUTF16(cipher),
733 ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
[email protected]b6c1d9e82013-06-12 17:26:57734 }
[email protected]03ef4b2a2012-03-06 15:04:20735 }
[email protected]e583f752012-08-30 13:26:21736
[email protected]71cd5ef2014-08-13 21:22:04737 // Check if a user decision has been made to allow or deny certificates with
738 // errors on this site.
739 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50740 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04741 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40742 // Only show an SSL decision revoke button if the user has chosen to bypass
743 // SSL host errors for this host in the past.
744 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]03ef4b2a2012-03-06 15:04:20745}
[email protected]0b9fdd72012-04-04 10:00:33746
lgarron617a30f32017-03-24 21:42:07747void PageInfo::PresentSitePermissions() {
[email protected]df818272012-04-20 13:10:50748 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38749 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50750
lgarron617a30f32017-03-24 21:42:07751 PageInfoUI::PermissionInfo permission_info;
[email protected]df818272012-04-20 13:10:50752 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
753 permission_info.type = kPermissionType[i];
754
csharrisonad1eaa6c2017-05-11 17:14:38755 if (!ShouldShowPermission(permission_info.type, site_url_,
756 content_settings_)) {
mgiucaa319f212016-01-14 03:30:11757 continue;
csharrisonad1eaa6c2017-05-11 17:14:38758 }
mgiucaa319f212016-01-14 03:30:11759
[email protected]df818272012-04-20 13:10:50760 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32761 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
762 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21763 DCHECK(value.get());
jdoerriedc72ee942016-12-07 15:43:28764 if (value->GetType() == base::Value::Type::INTEGER) {
sashab2b2a314f2015-01-17 06:42:21765 permission_info.setting =
766 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26767 } else {
sashab2b2a314f2015-01-17 06:42:21768 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26769 }
770
[email protected]8bdf45c32012-08-04 00:12:55771 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28772 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50773
[email protected]b1d113d2012-06-27 21:27:34774 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21775 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34776 permission_info.default_setting = permission_info.setting;
777 permission_info.setting = CONTENT_SETTING_DEFAULT;
778 } else {
779 permission_info.default_setting =
780 content_settings_->GetDefaultContentSetting(permission_info.type,
781 NULL);
[email protected]df818272012-04-20 13:10:50782 }
palmer0da10b32015-02-11 00:42:19783
patricialor2a4f41a2017-03-08 02:52:56784 // For permissions that are still prompting the user and haven't been
785 // explicitly set by another source, check its embargo status.
786 if (PermissionUtil::IsPermission(permission_info.type) &&
787 permission_info.setting == CONTENT_SETTING_DEFAULT &&
788 permission_info.source ==
789 content_settings::SettingSource::SETTING_SOURCE_USER) {
790 // TODO(raymes): Use GetPermissionStatus() to retrieve information
791 // about *all* permissions once it has default behaviour implemented for
792 // ContentSettingTypes that aren't permissions.
793 PermissionResult permission_result =
794 PermissionManager::Get(profile_)->GetPermissionStatus(
795 permission_info.type, site_url_, site_url_);
796
797 // If under embargo, update |permission_info| to reflect that.
798 if (permission_result.content_setting == CONTENT_SETTING_BLOCK &&
799 (permission_result.source ==
800 PermissionStatusSource::MULTIPLE_DISMISSALS ||
801 permission_result.source ==
802 PermissionStatusSource::SAFE_BROWSING_BLACKLIST))
803 permission_info.setting = permission_result.content_setting;
804 }
805
palmer64a099982016-03-09 21:26:11806 permission_info_list.push_back(permission_info);
[email protected]df818272012-04-20 13:10:50807 }
808
reillyg85f57db2016-01-12 23:14:38809 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
810 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10811 const GURL origin = site_url_.GetOrigin();
812 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32813 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38814 chosen_object_info_list.push_back(
lgarron617a30f32017-03-24 21:42:07815 base::MakeUnique<PageInfoUI::ChosenObjectInfo>(ui_info,
816 std::move(object)));
reillyg85f57db2016-01-12 23:14:38817 }
818 }
819
avi09dd4d02016-10-14 20:40:09820 ui_->SetPermissionInfo(permission_info_list,
821 std::move(chosen_object_info_list));
[email protected]0b9fdd72012-04-04 10:00:33822}
823
lgarron617a30f32017-03-24 21:42:07824void PageInfo::PresentSiteData() {
[email protected]df818272012-04-20 13:10:50825 CookieInfoList cookie_info_list;
vabrbab3ffcb2016-10-04 10:08:10826 const LocalSharedObjectsContainer& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34827 tab_specific_content_settings()->allowed_local_shared_objects();
vabrbab3ffcb2016-10-04 10:08:10828 const LocalSharedObjectsContainer& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34829 tab_specific_content_settings()->blocked_local_shared_objects();
830
831 // Add first party cookie and site data counts.
lgarron617a30f32017-03-24 21:42:07832 PageInfoUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34833 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
834 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15835 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34836 cookie_info_list.push_back(cookie_info);
837
838 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34839 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
840 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15841 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50842 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33843
[email protected]df818272012-04-20 13:10:50844 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33845}
[email protected]16de6de2012-04-04 12:24:14846
lgarron617a30f32017-03-24 21:42:07847void PageInfo::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04848 // After initialization the status about the site's connection and its
849 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41850 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
851 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
lgarron617a30f32017-03-24 21:42:07852 PageInfoUI::IdentityInfo info;
[email protected]24c8818c2012-04-25 09:57:41853 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
854 info.site_identity = UTF16ToUTF8(organization_name());
855 else
jshin1fb76462016-04-05 22:13:03856 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41857
858 info.connection_status = site_connection_status_;
lgarron1a6300d2017-03-18 03:33:04859 info.connection_status_description = UTF16ToUTF8(site_connection_details_);
[email protected]24c8818c2012-04-25 09:57:41860 info.identity_status = site_identity_status_;
lgarron1a6300d2017-03-18 03:33:04861 info.identity_status_description = UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21862 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04863 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
Jialiu Lin11e18542017-08-14 18:16:26864 info.show_change_password_buttons = show_change_password_buttons_;
[email protected]24c8818c2012-04-25 09:57:41865 ui_->SetIdentityInfo(info);
Jialiu Linfeb6bb32017-08-30 00:21:36866#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26867 if (password_protection_service_ && show_change_password_buttons_) {
868 password_protection_service_->OnWarningShown(
869 web_contents(), safe_browsing::PasswordProtectionService::PAGE_INFO);
870 }
871#endif
[email protected]24c8818c2012-04-25 09:57:41872}