blob: 85b402458a9f3454d54c7df062d5a2ca8920a4cd [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"
Tommy Steimeldea90f72017-11-07 20:58:0319#include "base/metrics/user_metrics.h"
[email protected]3ea1b182013-02-08 22:38:4120#include "base/strings/string_number_conversions.h"
[email protected]774cc3c2013-06-07 20:26:4521#include "base/strings/utf_string_conversions.h"
[email protected]0b9fdd72012-04-04 10:00:3322#include "base/values.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"
Jialiu Lin11e18542017-08-14 18:16:2641#include "chrome/browser/safe_browsing/safe_browsing_service.h"
[email protected]71cd5ef2014-08-13 21:22:0442#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
43#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
lgarron617a30f32017-03-24 21:42:0744#include "chrome/browser/ui/page_info/page_info_ui.h"
reillyg85f57db2016-01-12 23:14:3845#include "chrome/browser/usb/usb_chooser_context.h"
46#include "chrome/browser/usb/usb_chooser_context_factory.h"
Patricia Lora21a04cf2017-06-05 02:53:2947#include "chrome/common/chrome_features.h"
[email protected]71cd5ef2014-08-13 21:22:0448#include "chrome/common/chrome_switches.h"
jsbellddb849e2015-08-27 00:12:5649#include "chrome/common/url_constants.h"
reillyg85f57db2016-01-12 23:14:3850#include "chrome/grit/theme_resources.h"
Patti0601e532017-09-20 08:39:3051#include "components/content_settings/core/browser/content_settings_registry.h"
mukai8eaec822014-10-25 17:53:1652#include "components/content_settings/core/browser/content_settings_utils.h"
53#include "components/content_settings/core/browser/host_content_settings_map.h"
palmer0da10b32015-02-11 00:42:1954#include "components/content_settings/core/common/content_settings.h"
vasiliif62dbf92014-09-05 10:23:1355#include "components/content_settings/core/common/content_settings_pattern.h"
tbansal08a0e3e2017-06-30 21:30:0856#include "components/content_settings/core/common/content_settings_utils.h"
nzolghadrd87a308d2016-12-07 15:45:5657#include "components/rappor/public/rappor_utils.h"
58#include "components/rappor/rappor_service_impl.h"
felt2493b4452015-09-17 20:33:5959#include "components/ssl_errors/error_info.h"
thestig4a2e88e2016-08-27 23:23:5160#include "components/strings/grit/components_chromium_strings.h"
61#include "components/strings/grit/components_strings.h"
melandory7be36d312017-03-29 15:51:1262#include "components/subresource_filter/core/browser/subresource_filter_features.h"
palmer153af982015-09-15 02:04:1963#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3364#include "content/public/browser/browser_thread.h"
[email protected]eb2140c2013-07-29 12:37:3465#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2066#include "content/public/common/url_constants.h"
[email protected]6e7845ae2013-03-29 21:48:1167#include "net/cert/cert_status_flags.h"
68#include "net/cert/x509_certificate.h"
[email protected]536fd0b2013-03-14 17:41:5769#include "net/ssl/ssl_cipher_suite_names.h"
70#include "net/ssl/ssl_connection_status_flags.h"
tfarina29a3a1742016-10-28 18:47:3371#include "third_party/boringssl/src/include/openssl/ssl.h"
[email protected]03ef4b2a2012-03-06 15:04:2072#include "ui/base/l10n/l10n_util.h"
Patricia Lora21a04cf2017-06-05 02:53:2973#include "url/origin.h"
[email protected]03ef4b2a2012-03-06 15:04:2074
[email protected]24a9f1c92013-11-13 12:33:3775#if defined(OS_CHROMEOS)
76#include "chrome/browser/chromeos/policy/policy_cert_service.h"
77#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
78#endif
79
estade3feb83f2015-09-01 23:00:4980#if !defined(OS_ANDROID)
mgiucaa319f212016-01-14 03:30:1181#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
lgarron617a30f32017-03-24 21:42:0782#include "chrome/browser/ui/page_info/page_info_infobar_delegate.h"
estade3feb83f2015-09-01 23:00:4983#endif
84
Jialiu Lin11e18542017-08-14 18:16:2685#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin0d8cc722017-09-19 01:01:5186#include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
Jialiu Lin11e18542017-08-14 18:16:2687#endif
88
[email protected]ab6df3b12013-12-24 23:32:2689using base::ASCIIToUTF16;
90using base::UTF8ToUTF16;
[email protected]f729d7a2013-12-26 07:07:5691using base::UTF16ToUTF8;
[email protected]0b9fdd72012-04-04 10:00:3392using content::BrowserThread;
93
94namespace {
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,
Tommy Steimela8c3757e2017-08-24 00:15:46112 CONTENT_SETTINGS_TYPE_SOUND,
palmer7715e332016-05-27 00:41:19113 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
finnur46cafd42016-09-22 10:27:17114 CONTENT_SETTINGS_TYPE_AUTOPLAY,
palmer7715e332016-05-27 00:41:19115 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
[email protected]0b9fdd72012-04-04 10:00:33116};
117
Patti0601e532017-09-20 08:39:30118// Checks whether this permission is currently the factory default, as set by
119// Chrome. Specifically, that the following three conditions are true:
120// - The current active setting comes from the default or pref provider.
121// - The setting is the factory default setting (as opposed to a global
122// default setting set by the user).
123// - The setting is a wildcard setting applying to all origins (which can only
124// be set from the default provider).
125bool IsPermissionFactoryDefault(HostContentSettingsMap* content_settings,
126 const PageInfoUI::PermissionInfo& info) {
127 const ContentSetting factory_default_setting =
128 content_settings::ContentSettingsRegistry::GetInstance()
129 ->Get(info.type)
130 ->GetInitialDefaultSetting();
131 return (info.source == content_settings::SETTING_SOURCE_USER &&
132 factory_default_setting == info.default_setting &&
133 info.setting == CONTENT_SETTING_DEFAULT);
134}
135
lgarron617a30f32017-03-24 21:42:07136// Determines whether to show permission |type| in the Page Info UI. Only
mgiucaa319f212016-01-14 03:30:11137// applies to permissions listed in |kPermissionType|.
Patti0601e532017-09-20 08:39:30138bool ShouldShowPermission(const PageInfoUI::PermissionInfo& info,
csharrisonad1eaa6c2017-05-11 17:14:38139 const GURL& site_url,
Tommy Steimelc9f6c932017-10-13 23:33:04140 HostContentSettingsMap* content_settings,
141 content::WebContents* web_contents) {
Patti0601e532017-09-20 08:39:30142 // Note |CONTENT_SETTINGS_TYPE_ADS| will show up regardless of its default
143 // value when it has been activated on the current origin.
144 if (info.type == CONTENT_SETTINGS_TYPE_ADS) {
csharrisonad1eaa6c2017-05-11 17:14:38145 if (!base::FeatureList::IsEnabled(
146 subresource_filter::kSafeBrowsingSubresourceFilterExperimentalUI)) {
147 return false;
148 }
149
150 // The setting for subresource filtering should not show up if the site is
151 // not activated, both on android and desktop platforms.
152 return content_settings->GetWebsiteSetting(
Charles Harrison239d47982017-06-13 02:42:31153 site_url, GURL(), CONTENT_SETTINGS_TYPE_ADS_DATA, std::string(),
154 nullptr) != nullptr;
melandory7be36d312017-03-29 15:51:12155 }
156
Tommy Steimelc9f6c932017-10-13 23:33:04157 if (info.type == CONTENT_SETTINGS_TYPE_SOUND) {
158 if (!base::FeatureList::IsEnabled(features::kSoundContentSetting))
159 return false;
160
Tommy Steimel18360512017-11-01 00:38:19161 // The sound content setting should always show up when the tab has played
162 // audio.
163 if (web_contents && web_contents->WasEverAudible())
Tommy Steimelc9f6c932017-10-13 23:33:04164 return true;
165 }
166
Patti749d4d12017-10-11 06:20:30167#if defined(OS_ANDROID)
168 // Special geolocation DSE settings apply only on Android, so make sure it
169 // gets checked there regardless of default setting on Desktop.
170 if (info.type == CONTENT_SETTINGS_TYPE_GEOLOCATION)
171 return true;
172#endif
173
Patti0601e532017-09-20 08:39:30174 // All other content settings only show when they are non-factory-default.
175 if ((base::CommandLine::ForCurrentProcess()->HasSwitch(
176 switches::kEnableSiteSettings) ||
177 base::FeatureList::IsEnabled(features::kSiteDetails)) &&
178 IsPermissionFactoryDefault(content_settings, info)) {
179 return false;
180 }
181
182#if !defined(OS_ANDROID)
183 // Autoplay is Android-only at the moment.
184 if (info.type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
185 return false;
186#endif
187
mgiucaa319f212016-01-14 03:30:11188 return true;
189}
190
esecklercac56b62016-11-16 13:49:44191void CheckContentStatus(security_state::ContentStatus content_status,
estark00e83f12016-08-19 18:24:04192 bool* displayed,
193 bool* ran) {
194 switch (content_status) {
esecklercac56b62016-11-16 13:49:44195 case security_state::CONTENT_STATUS_DISPLAYED:
estark00e83f12016-08-19 18:24:04196 *displayed = true;
197 break;
esecklercac56b62016-11-16 13:49:44198 case security_state::CONTENT_STATUS_RAN:
estark00e83f12016-08-19 18:24:04199 *ran = true;
200 break;
esecklercac56b62016-11-16 13:49:44201 case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN:
estark00e83f12016-08-19 18:24:04202 *displayed = true;
203 *ran = true;
204 break;
esecklercac56b62016-11-16 13:49:44205 case security_state::CONTENT_STATUS_UNKNOWN:
206 case security_state::CONTENT_STATUS_NONE:
estark00e83f12016-08-19 18:24:04207 break;
208 }
209}
210
elawrenceb2ac2a232017-03-27 21:46:25211// If the |security_info| indicates that mixed content or certificate errors
212// were present, update |connection_status| and |connection_details|.
213void ReportAnyInsecureContent(const security_state::SecurityInfo& security_info,
thestig4427f13b2017-06-20 20:42:47214 PageInfo::SiteConnectionStatus* connection_status,
215 base::string16* connection_details) {
elawrenceb2ac2a232017-03-27 21:46:25216 bool displayed_insecure_content = false;
217 bool ran_insecure_content = false;
218 CheckContentStatus(security_info.mixed_content_status,
219 &displayed_insecure_content, &ran_insecure_content);
220 // Only note subresources with certificate errors if the main resource was
221 // loaded without major certificate errors. If the main resource had a
222 // certificate error, then it would not be that useful (and could
223 // potentially be confusing) to warn about subresources that had certificate
224 // errors too.
225 if (!net::IsCertStatusError(security_info.cert_status) ||
226 net::IsCertStatusMinorError(security_info.cert_status)) {
227 CheckContentStatus(security_info.content_with_cert_errors_status,
228 &displayed_insecure_content, &ran_insecure_content);
229 }
230
231 // Only one insecure content warning is displayed; show the most severe.
232 if (ran_insecure_content) {
thestig4427f13b2017-06-20 20:42:47233 *connection_status =
elawrenceb2ac2a232017-03-27 21:46:25234 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE;
thestig4427f13b2017-06-20 20:42:47235 connection_details->assign(l10n_util::GetStringFUTF16(
236 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25237 l10n_util::GetStringUTF16(
238 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR)));
estark00e83f12016-08-19 18:24:04239 return;
240 }
elawrenceb2ac2a232017-03-27 21:46:25241 if (security_info.contained_mixed_form) {
thestig4427f13b2017-06-20 20:42:47242 *connection_status = PageInfo::SITE_CONNECTION_STATUS_INSECURE_FORM_ACTION;
243 connection_details->assign(l10n_util::GetStringFUTF16(
244 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25245 l10n_util::GetStringUTF16(
246 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_FORM_WARNING)));
247 return;
248 }
249 if (displayed_insecure_content) {
thestig4427f13b2017-06-20 20:42:47250 *connection_status =
elawrenceb2ac2a232017-03-27 21:46:25251 PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
thestig4427f13b2017-06-20 20:42:47252 connection_details->assign(l10n_util::GetStringFUTF16(
253 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25254 l10n_util::GetStringUTF16(
255 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
256 }
estark00e83f12016-08-19 18:24:04257}
258
estarkfcfccdb82016-11-14 02:17:29259void GetSiteIdentityByMaliciousContentStatus(
esecklercac56b62016-11-16 13:49:44260 security_state::MaliciousContentStatus malicious_content_status,
lgarron617a30f32017-03-24 21:42:07261 PageInfo::SiteIdentityStatus* status,
estarkfcfccdb82016-11-14 02:17:29262 base::string16* details) {
263 switch (malicious_content_status) {
esecklercac56b62016-11-16 13:49:44264 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
estarkfcfccdb82016-11-14 02:17:29265 NOTREACHED();
266 break;
esecklercac56b62016-11-16 13:49:44267 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
lgarron617a30f32017-03-24 21:42:07268 *status = PageInfo::SITE_IDENTITY_STATUS_MALWARE;
lgarronfc1d5e52017-05-03 23:15:21269 *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MALWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29270 break;
esecklercac56b62016-11-16 13:49:44271 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
lgarron617a30f32017-03-24 21:42:07272 *status = PageInfo::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
lgarron1a6300d2017-03-18 03:33:04273 *details =
lgarronfc1d5e52017-05-03 23:15:21274 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SOCIAL_ENGINEERING_DETAILS);
estarkfcfccdb82016-11-14 02:17:29275 break;
esecklercac56b62016-11-16 13:49:44276 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
lgarron617a30f32017-03-24 21:42:07277 *status = PageInfo::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
lgarron1a6300d2017-03-18 03:33:04278 *details =
lgarronfc1d5e52017-05-03 23:15:21279 l10n_util::GetStringUTF16(IDS_PAGE_INFO_UNWANTED_SOFTWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29280 break;
Jialiu Lin11e18542017-08-14 18:16:26281 case security_state::MALICIOUS_CONTENT_STATUS_PASSWORD_REUSE:
Jialiu Linfeb6bb32017-08-30 00:21:36282#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26283 *status = PageInfo::SITE_IDENTITY_STATUS_PASSWORD_REUSE;
284 *details =
285 l10n_util::GetStringUTF16(IDS_PAGE_INFO_CHANGE_PASSWORD_DETAILS);
286#endif
287 break;
estarkfcfccdb82016-11-14 02:17:29288 }
289}
290
jshin1fb76462016-04-05 22:13:03291base::string16 GetSimpleSiteName(const GURL& url) {
benwells2337b8102016-04-20 01:53:53292 return url_formatter::FormatUrlForSecurityDisplay(
293 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
palmer153af982015-09-15 02:04:19294}
295
reillyg85f57db2016-01-12 23:14:38296ChooserContextBase* GetUsbChooserContext(Profile* profile) {
297 return UsbChooserContextFactory::GetForProfile(profile);
298}
299
300// The list of chooser types that need to display entries in the Website
301// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
302// email [email protected].
Andrew Grieved1978b0e2017-07-28 15:53:41303const PageInfo::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52304 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
lgarron617a30f32017-03-24 21:42:07305 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_PAGE_INFO_USB_DEVICE_LABEL,
306 IDS_PAGE_INFO_DELETE_USB_DEVICE, "name"},
reillyg85f57db2016-01-12 23:14:38307};
308
[email protected]0b9fdd72012-04-04 10:00:33309} // namespace
310
lgarron617a30f32017-03-24 21:42:07311PageInfo::PageInfo(PageInfoUI* ui,
312 Profile* profile,
313 TabSpecificContentSettings* tab_specific_content_settings,
314 content::WebContents* web_contents,
315 const GURL& url,
316 const security_state::SecurityInfo& security_info)
[email protected]df818272012-04-20 13:10:50317 : TabSpecificContentSettings::SiteDataObserver(
318 tab_specific_content_settings),
dominicknbdd53b5f2016-09-28 01:08:13319 content::WebContentsObserver(web_contents),
[email protected]df818272012-04-20 13:10:50320 ui_(ui),
[email protected]66f157312012-08-01 13:50:26321 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33322 site_url_(url),
323 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]03ef4b2a2012-03-06 15:04:20324 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
alshabalin5e894c12016-10-25 06:47:46325 show_ssl_decision_revoke_button_(false),
peconn5100d432015-09-16 12:03:08326 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04327 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25328 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19329 did_revoke_user_ssl_decisions_(false),
estark8d67cd7a2016-10-24 05:06:41330 profile_(profile),
Jialiu Lin11e18542017-08-14 18:16:26331 security_level_(security_state::NONE),
Jialiu Linfeb6bb32017-08-30 00:21:36332#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin0d8cc722017-09-19 01:01:51333 password_protection_service_(
334 safe_browsing::ChromePasswordProtectionService::
335 GetPasswordProtectionService(profile_)),
Jialiu Lin11e18542017-08-14 18:16:26336#endif
337 show_change_password_buttons_(false) {
estarka3121f6b2015-09-18 21:15:59338 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33339
340 PresentSitePermissions();
[email protected]24c8818c2012-04-25 09:57:41341 PresentSiteIdentity();
Pattie8c616202017-09-29 07:58:03342 PresentSiteData();
[email protected]e22d64f2012-09-10 09:03:23343
lgarron617a30f32017-03-24 21:42:07344 // Every time the Page Info UI is opened a |PageInfo| object is
345 // created. So this counts how ofter the Page Info UI is opened.
346 RecordPageInfoAction(PAGE_INFO_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20347}
348
Carlos ILe5dfda72017-09-21 02:33:05349PageInfo::~PageInfo() {
350 // Check if Re-enable warnings button was visible, if so, log on UMA whether
351 // it was clicked or not.
352 SSLCertificateDecisionsDidRevoke user_decision =
353 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
354 : USER_CERT_DECISIONS_NOT_REVOKED;
355 if (show_ssl_decision_revoke_button_) {
356 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions2",
357 user_decision,
358 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
359 }
360}
[email protected]03ef4b2a2012-03-06 15:04:20361
lgarron617a30f32017-03-24 21:42:07362void PageInfo::RecordPageInfoAction(PageInfoAction action) {
363 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04364
estark8d67cd7a2016-10-24 05:06:41365 std::string histogram_name;
estark8d67cd7a2016-10-24 05:06:41366 if (site_url_.SchemeIsCryptographic()) {
esecklercac56b62016-11-16 13:49:44367 if (security_level_ == security_state::SECURE ||
368 security_level_ == security_state::EV_SECURE) {
estark8d67cd7a2016-10-24 05:06:41369 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Valid",
lgarron617a30f32017-03-24 21:42:07370 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44371 } else if (security_level_ == security_state::NONE) {
estark8d67cd7a2016-10-24 05:06:41372 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded",
lgarron617a30f32017-03-24 21:42:07373 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44374 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41375 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07376 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41377 }
378 return;
379 }
380
esecklercac56b62016-11-16 13:49:44381 if (security_level_ == security_state::HTTP_SHOW_WARNING) {
estark8d67cd7a2016-10-24 05:06:41382 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning",
lgarron617a30f32017-03-24 21:42:07383 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44384 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41385 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07386 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41387 } else {
388 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral",
lgarron617a30f32017-03-24 21:42:07389 action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04390 }
391}
392
lgarron617a30f32017-03-24 21:42:07393void PageInfo::OnSitePermissionChanged(ContentSettingsType type,
394 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23395 // Count how often a permission for a specific content type is changed using
lgarron617a30f32017-03-24 21:42:07396 // the Page Info UI.
raymes4a13d432015-09-08 00:44:07397 size_t num_values;
398 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
dchengf6f4e4942017-03-30 23:55:57399 UMA_HISTOGRAM_EXACT_LINEAR("WebsiteSettings.OriginInfo.PermissionChanged",
400 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56401
402 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
dchengf6f4e4942017-03-30 23:55:57403 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56404 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07405 num_values);
tommycli34cf29bf2016-09-08 05:46:25406
407 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
408 rappor::SampleDomainAndRegistryFromGURL(
409 g_browser_process->rappor_service(),
410 "ContentSettings.Plugins.AddedAllowException", site_url_);
411 }
sashab9debecd2014-12-18 04:15:56412 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
dchengf6f4e4942017-03-30 23:55:57413 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56414 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07415 num_values);
sashab9debecd2014-12-18 04:15:56416 }
[email protected]e22d64f2012-09-10 09:03:23417
lgarron04a93502014-11-04 22:25:04418 // This is technically redundant given the histogram above, but putting the
419 // total count of permission changes in another histogram makes it easier to
lgarron026e9c42017-04-07 20:09:31420 // compare it against other kinds of actions in Page Info.
lgarron617a30f32017-03-24 21:42:07421 RecordPageInfoAction(PAGE_INFO_CHANGED_PERMISSION);
Tommy Steimeldea90f72017-11-07 20:58:03422 if (type == CONTENT_SETTINGS_TYPE_SOUND) {
423 ContentSetting default_setting =
424 content_settings_->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_SOUND,
425 nullptr);
426 bool mute = (setting == CONTENT_SETTING_BLOCK) ||
427 (setting == CONTENT_SETTING_DEFAULT &&
428 default_setting == CONTENT_SETTING_BLOCK);
429 if (mute) {
430 base::RecordAction(
431 base::UserMetricsAction("SoundContentSetting.MuteBy.PageInfo"));
432 } else {
433 base::RecordAction(
434 base::UserMetricsAction("SoundContentSetting.UnmuteBy.PageInfo"));
435 }
436 }
lgarron04a93502014-11-04 22:25:04437
stefanocs8b3490cc2016-07-28 05:32:52438 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
patricialor7131c1fe2017-04-07 01:25:52439 profile_, site_url_, site_url_, type, PermissionSourceUI::OIB);
stefanocs8b3490cc2016-07-28 05:32:52440
patricialor7131c1fe2017-04-07 01:25:52441 // The permission may have been blocked due to being under embargo, so if it
442 // was changed away from BLOCK, clear embargo status if it exists.
443 if (setting != CONTENT_SETTING_BLOCK) {
444 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveEmbargoByUrl(
445 site_url_, type);
446 }
raymesfbaaaaa2015-11-10 02:20:40447 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
448 setting);
[email protected]df818272012-04-20 13:10:50449
Tommy Steimel97ee2f82017-11-01 21:39:52450 // When the sound setting is changed, no reload is necessary.
451 if (type != CONTENT_SETTINGS_TYPE_SOUND)
452 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24453
454 // Refresh the UI to reflect the new setting.
455 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50456}
457
lgarron617a30f32017-03-24 21:42:07458void PageInfo::OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info,
459 const base::DictionaryValue& object) {
reillyg85f57db2016-01-12 23:14:38460 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
461 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10462 const GURL origin = site_url_.GetOrigin();
463 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38464 show_info_bar_ = true;
465
466 // Refresh the UI to reflect the changed settings.
467 PresentSitePermissions();
468}
469
lgarron617a30f32017-03-24 21:42:07470void PageInfo::OnSiteDataAccessed() {
[email protected]df818272012-04-20 13:10:50471 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33472}
473
lgarron617a30f32017-03-24 21:42:07474void PageInfo::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49475#if defined(OS_ANDROID)
476 NOTREACHED();
477#else
dominicknbdd53b5f2016-09-28 01:08:13478 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
palmerf2cba0d2015-08-27 23:15:06479 InfoBarService* infobar_service =
dominicknbdd53b5f2016-09-28 01:08:13480 InfoBarService::FromWebContents(web_contents());
palmerf2cba0d2015-08-27 23:15:06481 if (infobar_service)
lgarron617a30f32017-03-24 21:42:07482 PageInfoInfoBarDelegate::Create(infobar_service);
palmerf2cba0d2015-08-27 23:15:06483 }
estade3feb83f2015-09-01 23:00:49484#endif
jww1ed8ea72014-09-02 20:43:25485}
486
lgarron617a30f32017-03-24 21:42:07487void PageInfo::OnRevokeSSLErrorBypassButtonPressed() {
jww1ed8ea72014-09-02 20:43:25488 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29489 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
490 site_url().host());
jww1ed8ea72014-09-02 20:43:25491 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26492}
493
Patricia Lora21a04cf2017-06-05 02:53:29494void PageInfo::OpenSiteSettingsView() {
495 // By default, this opens the general Content Settings pane. If the
496 // |kSiteSettings| and/or |kSiteDetails| flags are enabled this opens a
497 // settings page specific to the current origin of the page. crbug.com/655876
Daniel Cheng88186bd52017-10-20 08:14:46498 url::Origin site_origin = url::Origin::Create(site_url());
Patricia Lora21a04cf2017-06-05 02:53:29499 std::string link_destination(chrome::kChromeUIContentSettingsURL);
Patti5f083d22017-09-07 02:13:19500 // TODO(https://crbug.com/444047): Site Details should work with file:// urls
501 // when this bug is fixed, so add it to the whitelist when that happens.
Patricia Lora21a04cf2017-06-05 02:53:29502 if ((base::CommandLine::ForCurrentProcess()->HasSwitch(
503 switches::kEnableSiteSettings) ||
504 base::FeatureList::IsEnabled(features::kSiteDetails)) &&
Patti5f083d22017-09-07 02:13:19505 !site_origin.unique() &&
506 (site_url().SchemeIsHTTPOrHTTPS() ||
507 site_url().SchemeIs(content_settings::kExtensionScheme))) {
Patricia Lora21a04cf2017-06-05 02:53:29508 std::string origin_string = site_origin.Serialize();
509 url::RawCanonOutputT<char> percent_encoded_origin;
510 url::EncodeURIComponent(origin_string.c_str(), origin_string.length(),
511 &percent_encoded_origin);
512 link_destination = chrome::kChromeUISiteDetailsPrefixURL +
513 std::string(percent_encoded_origin.data(),
514 percent_encoded_origin.length());
515 }
516 web_contents()->OpenURL(
517 content::OpenURLParams(GURL(link_destination), content::Referrer(),
518 WindowOpenDisposition::NEW_FOREGROUND_TAB,
519 ui::PAGE_TRANSITION_LINK, false));
520 RecordPageInfoAction(PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED);
521}
522
Jialiu Lin11e18542017-08-14 18:16:26523void PageInfo::OnChangePasswordButtonPressed(
524 content::WebContents* web_contents) {
Jialiu Linfeb6bb32017-08-30 00:21:36525#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26526 DCHECK(password_protection_service_);
Jialiu Lin3fc7f38f2017-09-21 18:38:37527 password_protection_service_->OnUserAction(
Jialiu Lin11e18542017-08-14 18:16:26528 web_contents, safe_browsing::PasswordProtectionService::PAGE_INFO,
529 safe_browsing::PasswordProtectionService::CHANGE_PASSWORD);
530#endif
531}
532
533void PageInfo::OnWhitelistPasswordReuseButtonPressed(
534 content::WebContents* web_contents) {
Jialiu Linfeb6bb32017-08-30 00:21:36535#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26536 DCHECK(password_protection_service_);
Jialiu Lin3fc7f38f2017-09-21 18:38:37537 password_protection_service_->OnUserAction(
Jialiu Lin11e18542017-08-14 18:16:26538 web_contents, safe_browsing::PasswordProtectionService::PAGE_INFO,
539 safe_browsing::PasswordProtectionService::MARK_AS_LEGITIMATE);
540#endif
541}
542
lgarron617a30f32017-03-24 21:42:07543void PageInfo::Init(const GURL& url,
544 const security_state::SecurityInfo& security_info) {
thestig0c55ee32017-06-20 22:17:51545#if !defined(OS_ANDROID)
meacerde53fcff2016-10-12 19:21:57546 // On desktop, internal URLs aren't handled by this class. Instead, a
lgarron026e9c42017-04-07 20:09:31547 // custom and simpler bubble is shown.
meacerde53fcff2016-10-12 19:21:57548 DCHECK(!url.SchemeIs(content::kChromeUIScheme) &&
549 !url.SchemeIs(content::kChromeDevToolsScheme) &&
550 !url.SchemeIs(content::kViewSourceScheme) &&
551 !url.SchemeIs(content_settings::kExtensionScheme));
552#endif
553
thestig0c55ee32017-06-20 22:17:51554 bool is_chrome_ui_native_scheme = false;
zpengdb4a58e2017-01-10 17:40:32555#if defined(OS_ANDROID)
thestig0c55ee32017-06-20 22:17:51556 is_chrome_ui_native_scheme = url.SchemeIs(chrome::kChromeUINativeScheme);
sashab97894ce2014-10-22 10:08:33557#endif
558
estark8d67cd7a2016-10-24 05:06:41559 security_level_ = security_info.security_level;
560
upendrag.gowda60886a6e2015-10-31 05:51:09561 if (url.SchemeIs(url::kAboutScheme)) {
562 // All about: URLs except about:blank are redirected.
563 DCHECK_EQ(url::kAboutBlankURL, url.spec());
564 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
565 site_identity_details_ =
566 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
567 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
568 site_connection_details_ = l10n_util::GetStringFUTF16(
569 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
570 UTF8ToUTF16(url.spec()));
571 return;
572 }
573
thestig0c55ee32017-06-20 22:17:51574 if (url.SchemeIs(content::kChromeUIScheme) || is_chrome_ui_native_scheme) {
[email protected]03ef4b2a2012-03-06 15:04:20575 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
576 site_identity_details_ =
577 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
578 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
579 return;
580 }
581
[email protected]03ef4b2a2012-03-06 15:04:20582 // Identity section.
jam8ae7cad2016-09-08 23:55:21583 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11584
estarkfcfccdb82016-11-14 02:17:29585 if (security_info.malicious_content_status !=
esecklercac56b62016-11-16 13:49:44586 security_state::MALICIOUS_CONTENT_STATUS_NONE) {
estarkfcfccdb82016-11-14 02:17:29587 // The site has been flagged by Safe Browsing as dangerous.
588 GetSiteIdentityByMaliciousContentStatus(
589 security_info.malicious_content_status, &site_identity_status_,
590 &site_identity_details_);
Jialiu Lin11e18542017-08-14 18:16:26591 show_change_password_buttons_ =
592 security_info.malicious_content_status ==
593 security_state::MALICIOUS_CONTENT_STATUS_PASSWORD_REUSE;
estarkfcfccdb82016-11-14 02:17:29594 } else if (certificate_ &&
595 (!net::IsCertStatusError(security_info.cert_status) ||
596 net::IsCertStatusMinorError(security_info.cert_status))) {
597 // HTTPS with no or minor errors.
estarka3121f6b2015-09-18 21:15:59598 if (security_info.security_level ==
esecklercac56b62016-11-16 13:49:44599 security_state::SECURE_WITH_POLICY_INSTALLED_CERT) {
[email protected]eaf3f322013-04-25 21:53:59600 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37601 site_identity_details_ = l10n_util::GetStringFUTF16(
602 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59603 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20604 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21605 base::string16 issuer_name(
606 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20607 if (issuer_name.empty()) {
608 issuer_name.assign(l10n_util::GetStringUTF16(
609 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
610 }
[email protected]94c74b42013-12-02 15:19:49611
[email protected]03ef4b2a2012-03-06 15:04:20612 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39613 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20614
615 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59616 if (security_info.cert_status &
617 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20618 site_identity_details_ += l10n_util::GetStringUTF16(
619 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59620 } else if (security_info.cert_status &
621 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20622 site_identity_details_ += l10n_util::GetStringUTF16(
623 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
624 } else {
625 NOTREACHED() << "Need to specify string for this warning";
626 }
[email protected]03ef4b2a2012-03-06 15:04:20627 } else {
estarkcf305562016-11-15 03:45:39628 // No major or minor errors.
estarka3121f6b2015-09-18 21:15:59629 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01630 // EV HTTPS page.
estarkcf305562016-11-15 03:45:39631 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
jam8ae7cad2016-09-08 23:55:21632 DCHECK(!certificate_->subject().organization_names.empty());
633 organization_name_ =
634 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01635 // An EV Cert is required to have a city (localityName) and country but
636 // state is "if any".
jam8ae7cad2016-09-08 23:55:21637 DCHECK(!certificate_->subject().locality_name.empty());
638 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01639 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21640 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01641 locality = l10n_util::GetStringFUTF16(
lgarronfc1d5e52017-05-03 23:15:21642 IDS_PAGE_INFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21643 UTF8ToUTF16(certificate_->subject().locality_name),
644 UTF8ToUTF16(certificate_->subject().state_or_province_name),
645 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01646 } else {
647 locality = l10n_util::GetStringFUTF16(
lgarronfc1d5e52017-05-03 23:15:21648 IDS_PAGE_INFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21649 UTF8ToUTF16(certificate_->subject().locality_name),
650 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01651 }
jam8ae7cad2016-09-08 23:55:21652 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01653 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39654 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED,
jam8ae7cad2016-09-08 23:55:21655 UTF8ToUTF16(certificate_->subject().organization_names[0]),
estarkcf305562016-11-15 03:45:39656 locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01657 } else {
658 // Non-EV OK HTTPS page.
estarkcf305562016-11-15 03:45:39659 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
rsleevi4f8012722014-09-30 01:28:01660 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21661 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01662 if (issuer_name.empty()) {
663 issuer_name.assign(l10n_util::GetStringUTF16(
664 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
665 }
[email protected]94c74b42013-12-02 15:19:49666
rsleevi4f8012722014-09-30 01:28:01667 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39668 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
rsleevi4f8012722014-09-30 01:28:01669 }
elawrencebe87bd62017-01-10 16:08:59670 if (security_info.sha1_in_chain) {
671 site_identity_status_ =
672 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM;
673 site_identity_details_ +=
674 UTF8ToUTF16("\n\n") +
675 l10n_util::GetStringUTF16(
676 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM);
rsleevi4f8012722014-09-30 01:28:01677 }
[email protected]03ef4b2a2012-03-06 15:04:20678 }
679 } else {
680 // HTTP or HTTPS with errors (not warnings).
681 site_identity_details_.assign(l10n_util::GetStringUTF16(
682 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
jam8ae7cad2016-09-08 23:55:21683 if (!security_info.scheme_is_cryptographic || !security_info.certificate)
[email protected]03ef4b2a2012-03-06 15:04:20684 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
685 else
686 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
687
[email protected]a04db822013-12-11 19:14:40688 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59689 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59690 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
jam8ae7cad2016-09-08 23:55:21691 certificate_, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20692 for (size_t i = 0; i < errors.size(); ++i) {
693 site_identity_details_ += bullet;
694 site_identity_details_ += errors[i].short_description();
695 }
696
estarka3121f6b2015-09-18 21:15:59697 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20698 site_identity_details_ += ASCIIToUTF16("\n\n");
lgarron1a6300d2017-03-18 03:33:04699 site_identity_details_ +=
700 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
[email protected]03ef4b2a2012-03-06 15:04:20701 }
702 }
703
704 // Site Connection
705 // We consider anything less than 80 bits encryption to be weak encryption.
706 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
707 // weakly encrypted connections.
708 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
709
jshin1fb76462016-04-05 22:13:03710 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19711 if (subject_name.empty()) {
712 subject_name.assign(
713 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
714 }
715
jam8ae7cad2016-09-08 23:55:21716 if (!security_info.certificate || !security_info.scheme_is_cryptographic) {
estarka3121f6b2015-09-18 21:15:59717 // Page is still loading (so SSL status is not yet available) or
718 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58719 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
720
721 site_connection_details_.assign(l10n_util::GetStringFUTF16(
722 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
723 subject_name));
estarka3121f6b2015-09-18 21:15:59724 } else if (security_info.security_bits < 0) {
725 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20726 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59727 } else if (security_info.security_bits == 0) {
esecklercac56b62016-11-16 13:49:44728 DCHECK_NE(security_info.security_level, security_state::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20729 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
730 site_connection_details_.assign(l10n_util::GetStringFUTF16(
731 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
732 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20733 } else {
734 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22735
lgarron3e2c33e2016-08-25 06:33:43736 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22737 site_connection_details_.assign(l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04738 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, subject_name));
Adam Langley71c2b59b2014-11-13 00:34:22739 } else {
740 site_connection_details_.assign(l10n_util::GetStringFUTF16(
741 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
742 subject_name));
743 }
744
thestig4427f13b2017-06-20 20:42:47745 ReportAnyInsecureContent(security_info, &site_connection_status_,
746 &site_connection_details_);
[email protected]03ef4b2a2012-03-06 15:04:20747 }
748
avi655876a2015-12-25 07:18:15749 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59750 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
751 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20752 int ssl_version =
estarka3121f6b2015-09-18 21:15:59753 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20754 const char* ssl_version_str;
755 net::SSLVersionToString(&ssl_version_str, ssl_version);
756 site_connection_details_ += ASCIIToUTF16("\n\n");
757 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04758 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, ASCIIToUTF16(ssl_version_str));
[email protected]03ef4b2a2012-03-06 15:04:20759
[email protected]03ef4b2a2012-03-06 15:04:20760 const char *key_exchange, *cipher, *mac;
davidben56a8aece2016-10-14 18:20:56761 bool is_aead, is_tls13;
762 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
763 &is_tls13, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20764
765 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57766 if (is_aead) {
davidben56a8aece2016-10-14 18:20:56767 if (is_tls13) {
768 // For TLS 1.3 ciphers, report the group (historically, curve) as the
769 // key exchange.
770 key_exchange = SSL_get_curve_name(security_info.key_exchange_group);
771 if (!key_exchange) {
772 NOTREACHED();
773 key_exchange = "";
774 }
775 }
[email protected]b6c1d9e82013-06-12 17:26:57776 site_connection_details_ += l10n_util::GetStringFUTF16(
777 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
778 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
779 } else {
780 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04781 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, ASCIIToUTF16(cipher),
782 ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
[email protected]b6c1d9e82013-06-12 17:26:57783 }
[email protected]03ef4b2a2012-03-06 15:04:20784 }
[email protected]e583f752012-08-30 13:26:21785
[email protected]71cd5ef2014-08-13 21:22:04786 // Check if a user decision has been made to allow or deny certificates with
787 // errors on this site.
788 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50789 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04790 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40791 // Only show an SSL decision revoke button if the user has chosen to bypass
792 // SSL host errors for this host in the past.
793 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]03ef4b2a2012-03-06 15:04:20794}
[email protected]0b9fdd72012-04-04 10:00:33795
lgarron617a30f32017-03-24 21:42:07796void PageInfo::PresentSitePermissions() {
[email protected]df818272012-04-20 13:10:50797 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38798 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50799
lgarron617a30f32017-03-24 21:42:07800 PageInfoUI::PermissionInfo permission_info;
[email protected]df818272012-04-20 13:10:50801 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
802 permission_info.type = kPermissionType[i];
803
804 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32805 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
806 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21807 DCHECK(value.get());
jdoerrie76cee9c2017-10-06 22:42:42808 if (value->type() == base::Value::Type::INTEGER) {
sashab2b2a314f2015-01-17 06:42:21809 permission_info.setting =
810 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26811 } else {
sashab2b2a314f2015-01-17 06:42:21812 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26813 }
814
[email protected]8bdf45c32012-08-04 00:12:55815 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28816 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50817
[email protected]b1d113d2012-06-27 21:27:34818 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21819 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34820 permission_info.default_setting = permission_info.setting;
821 permission_info.setting = CONTENT_SETTING_DEFAULT;
822 } else {
823 permission_info.default_setting =
824 content_settings_->GetDefaultContentSetting(permission_info.type,
825 NULL);
[email protected]df818272012-04-20 13:10:50826 }
palmer0da10b32015-02-11 00:42:19827
patricialor2a4f41a2017-03-08 02:52:56828 // For permissions that are still prompting the user and haven't been
829 // explicitly set by another source, check its embargo status.
830 if (PermissionUtil::IsPermission(permission_info.type) &&
831 permission_info.setting == CONTENT_SETTING_DEFAULT &&
832 permission_info.source ==
833 content_settings::SettingSource::SETTING_SOURCE_USER) {
834 // TODO(raymes): Use GetPermissionStatus() to retrieve information
835 // about *all* permissions once it has default behaviour implemented for
836 // ContentSettingTypes that aren't permissions.
837 PermissionResult permission_result =
838 PermissionManager::Get(profile_)->GetPermissionStatus(
839 permission_info.type, site_url_, site_url_);
840
841 // If under embargo, update |permission_info| to reflect that.
842 if (permission_result.content_setting == CONTENT_SETTING_BLOCK &&
843 (permission_result.source ==
844 PermissionStatusSource::MULTIPLE_DISMISSALS ||
845 permission_result.source ==
846 PermissionStatusSource::SAFE_BROWSING_BLACKLIST))
847 permission_info.setting = permission_result.content_setting;
848 }
849
Tommy Steimelc9f6c932017-10-13 23:33:04850 if (ShouldShowPermission(permission_info, site_url_, content_settings_,
851 web_contents())) {
Patti0601e532017-09-20 08:39:30852 permission_info_list.push_back(permission_info);
Tommy Steimelc9f6c932017-10-13 23:33:04853 }
[email protected]df818272012-04-20 13:10:50854 }
855
reillyg85f57db2016-01-12 23:14:38856 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
857 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10858 const GURL origin = site_url_.GetOrigin();
859 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32860 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38861 chosen_object_info_list.push_back(
lgarron617a30f32017-03-24 21:42:07862 base::MakeUnique<PageInfoUI::ChosenObjectInfo>(ui_info,
863 std::move(object)));
reillyg85f57db2016-01-12 23:14:38864 }
865 }
866
avi09dd4d02016-10-14 20:40:09867 ui_->SetPermissionInfo(permission_info_list,
868 std::move(chosen_object_info_list));
[email protected]0b9fdd72012-04-04 10:00:33869}
870
lgarron617a30f32017-03-24 21:42:07871void PageInfo::PresentSiteData() {
[email protected]df818272012-04-20 13:10:50872 CookieInfoList cookie_info_list;
vabrbab3ffcb2016-10-04 10:08:10873 const LocalSharedObjectsContainer& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34874 tab_specific_content_settings()->allowed_local_shared_objects();
vabrbab3ffcb2016-10-04 10:08:10875 const LocalSharedObjectsContainer& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34876 tab_specific_content_settings()->blocked_local_shared_objects();
877
878 // Add first party cookie and site data counts.
lgarron617a30f32017-03-24 21:42:07879 PageInfoUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34880 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
881 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15882 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34883 cookie_info_list.push_back(cookie_info);
884
885 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34886 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
887 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15888 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50889 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33890
[email protected]df818272012-04-20 13:10:50891 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33892}
[email protected]16de6de2012-04-04 12:24:14893
lgarron617a30f32017-03-24 21:42:07894void PageInfo::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04895 // After initialization the status about the site's connection and its
896 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41897 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
898 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
lgarron617a30f32017-03-24 21:42:07899 PageInfoUI::IdentityInfo info;
[email protected]24c8818c2012-04-25 09:57:41900 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
901 info.site_identity = UTF16ToUTF8(organization_name());
902 else
jshin1fb76462016-04-05 22:13:03903 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41904
905 info.connection_status = site_connection_status_;
lgarron1a6300d2017-03-18 03:33:04906 info.connection_status_description = UTF16ToUTF8(site_connection_details_);
[email protected]24c8818c2012-04-25 09:57:41907 info.identity_status = site_identity_status_;
lgarron1a6300d2017-03-18 03:33:04908 info.identity_status_description = UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21909 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04910 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
Jialiu Lin11e18542017-08-14 18:16:26911 info.show_change_password_buttons = show_change_password_buttons_;
[email protected]24c8818c2012-04-25 09:57:41912 ui_->SetIdentityInfo(info);
Jialiu Linfeb6bb32017-08-30 00:21:36913#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26914 if (password_protection_service_ && show_change_password_buttons_) {
Jialiu Linfecb75432017-11-07 19:14:59915 password_protection_service_->RecordWarningAction(
916 safe_browsing::PasswordProtectionService::PAGE_INFO,
917 safe_browsing::PasswordProtectionService::SHOWN);
Jialiu Lin11e18542017-08-14 18:16:26918 }
919#endif
[email protected]24c8818c2012-04-25 09:57:41920}