blob: 0352cd9ec8ad4318d62561bdcaccf1e23f417b05 [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
Eric Lawrence6758d1d2017-11-21 16:06:0510#include <memory>
[email protected]03ef4b2a2012-03-06 15:04:2011#include <string>
Eric Lawrence6758d1d2017-11-21 16:06:0512#include <utility>
[email protected]03ef4b2a2012-03-06 15:04:2013#include <vector>
14
[email protected]eb2140c2013-07-29 12:37:3415#include "base/command_line.h"
[email protected]15b092542012-05-16 13:08:1416#include "base/i18n/time_formatting.h"
[email protected]71cd5ef2014-08-13 21:22:0417#include "base/metrics/field_trial.h"
Christopher Thompson0c4e06c22018-07-11 22:29:5918#include "base/metrics/histogram_functions.h"
asvitkine75036032016-09-01 20:49:3419#include "base/metrics/histogram_macros.h"
Tommy Steimeldea90f72017-11-07 20:58:0320#include "base/metrics/user_metrics.h"
Avi Drissman22f82872018-12-25 23:09:0721#include "base/stl_util.h"
[email protected]3ea1b182013-02-08 22:38:4122#include "base/strings/string_number_conversions.h"
[email protected]774cc3c2013-06-07 20:26:4523#include "base/strings/utf_string_conversions.h"
[email protected]0b9fdd72012-04-04 10:00:3324#include "base/values.h"
Suman Kancherlad54a6e5b2019-01-29 22:17:4925#include "build/build_config.h"
jialiul02aad2d2015-04-01 18:56:0326#include "chrome/browser/browser_process.h"
[email protected]b0cb5e82012-07-19 19:22:4727#include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
28#include "chrome/browser/browsing_data/browsing_data_database_helper.h"
29#include "chrome/browser/browsing_data/browsing_data_file_system_helper.h"
30#include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
31#include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
peconn5100d432015-09-16 12:03:0832#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
vabrbab3ffcb2016-10-04 10:08:1033#include "chrome/browser/content_settings/local_shared_objects_container.h"
[email protected]77a91c72012-08-13 16:19:3434#include "chrome/browser/history/history_service_factory.h"
palmerf2cba0d2015-08-27 23:15:0635#include "chrome/browser/infobars/infobar_service.h"
reillyg85f57db2016-01-12 23:14:3836#include "chrome/browser/permissions/chooser_context_base.h"
patricialor7131c1fe2017-04-07 01:25:5237#include "chrome/browser/permissions/permission_decision_auto_blocker.h"
patricialor2a4f41a2017-03-08 02:52:5638#include "chrome/browser/permissions/permission_manager.h"
39#include "chrome/browser/permissions/permission_result.h"
tsergeantf1e89352016-01-15 20:34:5440#include "chrome/browser/permissions/permission_uma_util.h"
41#include "chrome/browser/permissions/permission_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2042#include "chrome/browser/profiles/profile.h"
Jialiu Lin11e18542017-08-14 18:16:2643#include "chrome/browser/safe_browsing/safe_browsing_service.h"
[email protected]71cd5ef2014-08-13 21:22:0444#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
45#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
lgarron617a30f32017-03-24 21:42:0746#include "chrome/browser/ui/page_info/page_info_ui.h"
reillyg85f57db2016-01-12 23:14:3847#include "chrome/browser/usb/usb_chooser_context.h"
48#include "chrome/browser/usb/usb_chooser_context_factory.h"
Suman Kancherlad54a6e5b2019-01-29 22:17:4949#include "chrome/browser/vr/vr_tab_helper.h"
Patricia Lora21a04cf2017-06-05 02:53:2950#include "chrome/common/chrome_features.h"
[email protected]71cd5ef2014-08-13 21:22:0451#include "chrome/common/chrome_switches.h"
jsbellddb849e2015-08-27 00:12:5652#include "chrome/common/url_constants.h"
reillyg85f57db2016-01-12 23:14:3853#include "chrome/grit/theme_resources.h"
Patti0601e532017-09-20 08:39:3054#include "components/content_settings/core/browser/content_settings_registry.h"
mukai8eaec822014-10-25 17:53:1655#include "components/content_settings/core/browser/content_settings_utils.h"
56#include "components/content_settings/core/browser/host_content_settings_map.h"
palmer0da10b32015-02-11 00:42:1957#include "components/content_settings/core/common/content_settings.h"
vasiliif62dbf92014-09-05 10:23:1358#include "components/content_settings/core/common/content_settings_pattern.h"
tbansal08a0e3e2017-06-30 21:30:0859#include "components/content_settings/core/common/content_settings_utils.h"
Bettina29c22cb52019-06-28 17:41:5160#include "components/password_manager/core/browser/password_manager_metrics_util.h"
nzolghadrd87a308d2016-12-07 15:45:5661#include "components/rappor/public/rappor_utils.h"
62#include "components/rappor/rappor_service_impl.h"
Bettina29c22cb52019-06-28 17:41:5163#include "components/signin/core/browser/account_info.h"
felt2493b4452015-09-17 20:33:5964#include "components/ssl_errors/error_info.h"
thestig4a2e88e2016-08-27 23:23:5165#include "components/strings/grit/components_chromium_strings.h"
66#include "components/strings/grit/components_strings.h"
melandory7be36d312017-03-29 15:51:1267#include "components/subresource_filter/core/browser/subresource_filter_features.h"
palmer153af982015-09-15 02:04:1968#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3369#include "content/public/browser/browser_thread.h"
[email protected]eb2140c2013-07-29 12:37:3470#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2071#include "content/public/common/url_constants.h"
[email protected]6e7845ae2013-03-29 21:48:1172#include "net/cert/cert_status_flags.h"
73#include "net/cert/x509_certificate.h"
[email protected]536fd0b2013-03-14 17:41:5774#include "net/ssl/ssl_cipher_suite_names.h"
75#include "net/ssl/ssl_connection_status_flags.h"
tfarina29a3a1742016-10-28 18:47:3376#include "third_party/boringssl/src/include/openssl/ssl.h"
[email protected]03ef4b2a2012-03-06 15:04:2077#include "ui/base/l10n/l10n_util.h"
Patricia Lora21a04cf2017-06-05 02:53:2978#include "url/origin.h"
[email protected]03ef4b2a2012-03-06 15:04:2079
[email protected]24a9f1c92013-11-13 12:33:3780#if defined(OS_CHROMEOS)
81#include "chrome/browser/chromeos/policy/policy_cert_service.h"
82#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
83#endif
84
estade3feb83f2015-09-01 23:00:4985#if !defined(OS_ANDROID)
Reilly Grant4e9d4f22019-02-13 17:17:3086#include "chrome/browser/serial/serial_chooser_context.h"
87#include "chrome/browser/serial/serial_chooser_context_factory.h"
Christopher Lam0dbac2b2017-11-14 07:12:1088#include "chrome/browser/ui/browser_finder.h"
89#include "chrome/browser/ui/chrome_pages.h"
mgiucaa319f212016-01-14 03:30:1190#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
lgarron617a30f32017-03-24 21:42:0791#include "chrome/browser/ui/page_info/page_info_infobar_delegate.h"
estade3feb83f2015-09-01 23:00:4992#endif
93
Michael Thiessen4c9e4a82019-03-08 04:39:4494#if defined(FULL_SAFE_BROWSING)
Jialiu Lin0d8cc722017-09-19 01:01:5195#include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
Jialiu Lin11e18542017-08-14 18:16:2696#endif
97
[email protected]ab6df3b12013-12-24 23:32:2698using base::ASCIIToUTF16;
[email protected]f729d7a2013-12-26 07:07:5699using base::UTF16ToUTF8;
Ovidio Henriquez3fc113f2019-04-23 14:37:10100using base::UTF8ToUTF16;
[email protected]0b9fdd72012-04-04 10:00:33101using content::BrowserThread;
Bettina29c22cb52019-06-28 17:41:51102using password_manager::metrics_util::PasswordType;
[email protected]0b9fdd72012-04-04 10:00:33103
104namespace {
105
lgarron617a30f32017-03-24 21:42:07106// The list of content settings types to display on the Page Info UI. THE
csharrisonad1eaa6c2017-05-11 17:14:38107// ORDER OF THESE ITEMS IS IMPORTANT and comes from https://crbug.com/610358. To
108// propose changing it, email [email protected].
[email protected]0b9fdd72012-04-04 10:00:33109ContentSettingsType kPermissionType[] = {
sashab2b2a314f2015-01-17 06:42:21110 CONTENT_SETTINGS_TYPE_GEOLOCATION,
sashab2b2a314f2015-01-17 06:42:21111 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
112 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
Alexander Shalamovce5aab52018-02-07 11:45:15113 CONTENT_SETTINGS_TYPE_SENSORS,
palmer0da10b32015-02-11 00:42:19114 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
palmer7715e332016-05-27 00:41:19115 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
lshange085f202016-06-14 01:25:08116#if !defined(OS_ANDROID)
palmer7715e332016-05-27 00:41:19117 CONTENT_SETTINGS_TYPE_PLUGINS,
118 CONTENT_SETTINGS_TYPE_IMAGES,
lshange085f202016-06-14 01:25:08119#endif
palmer7715e332016-05-27 00:41:19120 CONTENT_SETTINGS_TYPE_POPUPS,
Charles Harrison239d47982017-06-13 02:42:31121 CONTENT_SETTINGS_TYPE_ADS,
nsatragno670fe922016-04-08 14:10:50122 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
Tommy Steimela8c3757e2017-08-24 00:15:46123 CONTENT_SETTINGS_TYPE_SOUND,
palmer7715e332016-05-27 00:41:19124 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
finnur46cafd42016-09-22 10:27:17125 CONTENT_SETTINGS_TYPE_AUTOPLAY,
palmer7715e332016-05-27 00:41:19126 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
Gary Kacmarcik10533cf2017-11-22 03:31:28127 CONTENT_SETTINGS_TYPE_CLIPBOARD_READ,
Reilly Granta69ab672018-04-06 18:26:07128 CONTENT_SETTINGS_TYPE_USB_GUARD,
Reilly Grant87d6eb022019-04-19 23:55:59129#if !defined(OS_ANDROID)
130 CONTENT_SETTINGS_TYPE_SERIAL_GUARD,
Reilly Grant87d6eb022019-04-19 23:55:59131#endif
Jun Caic6040772019-06-28 20:39:32132 CONTENT_SETTINGS_TYPE_BLUETOOTH_SCANNING,
[email protected]0b9fdd72012-04-04 10:00:33133};
134
Patti0601e532017-09-20 08:39:30135// Checks whether this permission is currently the factory default, as set by
136// Chrome. Specifically, that the following three conditions are true:
137// - The current active setting comes from the default or pref provider.
138// - The setting is the factory default setting (as opposed to a global
139// default setting set by the user).
140// - The setting is a wildcard setting applying to all origins (which can only
141// be set from the default provider).
142bool IsPermissionFactoryDefault(HostContentSettingsMap* content_settings,
143 const PageInfoUI::PermissionInfo& info) {
144 const ContentSetting factory_default_setting =
145 content_settings::ContentSettingsRegistry::GetInstance()
146 ->Get(info.type)
147 ->GetInitialDefaultSetting();
148 return (info.source == content_settings::SETTING_SOURCE_USER &&
149 factory_default_setting == info.default_setting &&
150 info.setting == CONTENT_SETTING_DEFAULT);
151}
152
lgarron617a30f32017-03-24 21:42:07153// Determines whether to show permission |type| in the Page Info UI. Only
mgiucaa319f212016-01-14 03:30:11154// applies to permissions listed in |kPermissionType|.
shahriar rostamia9c769d2017-12-06 04:54:08155bool ShouldShowPermission(
156 const PageInfoUI::PermissionInfo& info,
157 const GURL& site_url,
158 HostContentSettingsMap* content_settings,
159 content::WebContents* web_contents,
160 TabSpecificContentSettings* tab_specific_content_settings) {
Patti0601e532017-09-20 08:39:30161 // Note |CONTENT_SETTINGS_TYPE_ADS| will show up regardless of its default
162 // value when it has been activated on the current origin.
163 if (info.type == CONTENT_SETTINGS_TYPE_ADS) {
csharrisonad1eaa6c2017-05-11 17:14:38164 if (!base::FeatureList::IsEnabled(
Charlie Harrisonb73f7622018-06-01 14:24:34165 subresource_filter::kSafeBrowsingSubresourceFilter)) {
csharrisonad1eaa6c2017-05-11 17:14:38166 return false;
167 }
168
169 // The setting for subresource filtering should not show up if the site is
170 // not activated, both on android and desktop platforms.
171 return content_settings->GetWebsiteSetting(
Charles Harrison239d47982017-06-13 02:42:31172 site_url, GURL(), CONTENT_SETTINGS_TYPE_ADS_DATA, std::string(),
173 nullptr) != nullptr;
melandory7be36d312017-03-29 15:51:12174 }
175
Tommy Steimelc9f6c932017-10-13 23:33:04176 if (info.type == CONTENT_SETTINGS_TYPE_SOUND) {
Tommy Steimel18360512017-11-01 00:38:19177 // The sound content setting should always show up when the tab has played
178 // audio.
179 if (web_contents && web_contents->WasEverAudible())
Tommy Steimelc9f6c932017-10-13 23:33:04180 return true;
181 }
182
Patti749d4d12017-10-11 06:20:30183#if defined(OS_ANDROID)
184 // Special geolocation DSE settings apply only on Android, so make sure it
185 // gets checked there regardless of default setting on Desktop.
186 if (info.type == CONTENT_SETTINGS_TYPE_GEOLOCATION)
187 return true;
Pattid7c4d542017-12-07 00:54:14188#else
Patti8c57f37d2018-01-31 04:33:21189 // Flash is shown if the user has ever changed its setting for |site_url|.
190 if (info.type == CONTENT_SETTINGS_TYPE_PLUGINS &&
191 content_settings->GetWebsiteSetting(site_url, site_url,
192 CONTENT_SETTINGS_TYPE_PLUGINS_DATA,
193 std::string(), nullptr) != nullptr) {
Pattid7c4d542017-12-07 00:54:14194 return true;
Patti8c57f37d2018-01-31 04:33:21195 }
Patti749d4d12017-10-11 06:20:30196#endif
197
Patti0601e532017-09-20 08:39:30198#if !defined(OS_ANDROID)
199 // Autoplay is Android-only at the moment.
200 if (info.type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
201 return false;
202#endif
203
shahriar rostamia9c769d2017-12-06 04:54:08204 // Show the content setting if it has been changed by the user since the last
205 // page load.
206 if (tab_specific_content_settings->HasContentSettingChangedViaPageInfo(
207 info.type)) {
208 return true;
209 }
210
211 // Show the content setting when it has a non-default value.
212 if (!IsPermissionFactoryDefault(content_settings, info))
213 return true;
214
215 return false;
mgiucaa319f212016-01-14 03:30:11216}
217
Emily Starkd75d54ce2019-03-12 20:23:09218// If the |visible_security_state| indicates that mixed content or certificate
219// errors were present, update |connection_status| and |connection_details|.
220void ReportAnyInsecureContent(
221 const security_state::VisibleSecurityState& visible_security_state,
222 PageInfo::SiteConnectionStatus* connection_status,
223 base::string16* connection_details) {
224 bool displayed_insecure_content =
225 visible_security_state.displayed_mixed_content;
226 bool ran_insecure_content = visible_security_state.ran_mixed_content;
elawrenceb2ac2a232017-03-27 21:46:25227 // Only note subresources with certificate errors if the main resource was
228 // loaded without major certificate errors. If the main resource had a
229 // certificate error, then it would not be that useful (and could
230 // potentially be confusing) to warn about subresources that had certificate
231 // errors too.
Emily Starkd75d54ce2019-03-12 20:23:09232 if (!net::IsCertStatusError(visible_security_state.cert_status) ||
233 net::IsCertStatusMinorError(visible_security_state.cert_status)) {
234 displayed_insecure_content =
235 displayed_insecure_content ||
236 visible_security_state.displayed_content_with_cert_errors;
237 ran_insecure_content = ran_insecure_content ||
238 visible_security_state.ran_content_with_cert_errors;
elawrenceb2ac2a232017-03-27 21:46:25239 }
240
241 // Only one insecure content warning is displayed; show the most severe.
242 if (ran_insecure_content) {
thestig4427f13b2017-06-20 20:42:47243 *connection_status =
elawrenceb2ac2a232017-03-27 21:46:25244 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE;
thestig4427f13b2017-06-20 20:42:47245 connection_details->assign(l10n_util::GetStringFUTF16(
246 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25247 l10n_util::GetStringUTF16(
248 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR)));
estark00e83f12016-08-19 18:24:04249 return;
250 }
Emily Starkd75d54ce2019-03-12 20:23:09251 if (visible_security_state.contained_mixed_form) {
thestig4427f13b2017-06-20 20:42:47252 *connection_status = PageInfo::SITE_CONNECTION_STATUS_INSECURE_FORM_ACTION;
253 connection_details->assign(l10n_util::GetStringFUTF16(
254 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25255 l10n_util::GetStringUTF16(
256 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_FORM_WARNING)));
257 return;
258 }
259 if (displayed_insecure_content) {
thestig4427f13b2017-06-20 20:42:47260 *connection_status =
elawrenceb2ac2a232017-03-27 21:46:25261 PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
thestig4427f13b2017-06-20 20:42:47262 connection_details->assign(l10n_util::GetStringFUTF16(
263 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25264 l10n_util::GetStringUTF16(
265 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
266 }
estark00e83f12016-08-19 18:24:04267}
268
jshin1fb76462016-04-05 22:13:03269base::string16 GetSimpleSiteName(const GURL& url) {
benwells2337b8102016-04-20 01:53:53270 return url_formatter::FormatUrlForSecurityDisplay(
271 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
palmer153af982015-09-15 02:04:19272}
273
reillyg85f57db2016-01-12 23:14:38274ChooserContextBase* GetUsbChooserContext(Profile* profile) {
275 return UsbChooserContextFactory::GetForProfile(profile);
276}
277
Reilly Grant4e9d4f22019-02-13 17:17:30278#if !defined(OS_ANDROID)
279ChooserContextBase* GetSerialChooserContext(Profile* profile) {
280 return SerialChooserContextFactory::GetForProfile(profile);
281}
282#endif
283
reillyg85f57db2016-01-12 23:14:38284// The list of chooser types that need to display entries in the Website
285// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
286// email [email protected].
Andrew Grieved1978b0e2017-07-28 15:53:41287const PageInfo::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52288 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
Reilly Grant4e9d4f22019-02-13 17:17:30289 IDS_PAGE_INFO_USB_DEVICE_SECONDARY_LABEL,
Ovidio Henriquez017d3b8f2019-02-01 18:51:24290 IDS_PAGE_INFO_USB_DEVICE_ALLOWED_BY_POLICY_LABEL,
Ovidio Henriquez3fc113f2019-04-23 14:37:10291 IDS_PAGE_INFO_DELETE_USB_DEVICE, &UsbChooserContext::GetObjectName},
Reilly Grant4e9d4f22019-02-13 17:17:30292#if !defined(OS_ANDROID)
293 {CONTENT_SETTINGS_TYPE_SERIAL_CHOOSER_DATA, &GetSerialChooserContext,
294 IDS_PAGE_INFO_SERIAL_PORT_SECONDARY_LABEL,
295 /*allowed_by_policy_description_string_id=*/-1,
Ovidio Henriquez3fc113f2019-04-23 14:37:10296 IDS_PAGE_INFO_DELETE_SERIAL_PORT, &SerialChooserContext::GetObjectName},
Reilly Grant4e9d4f22019-02-13 17:17:30297#endif
reillyg85f57db2016-01-12 23:14:38298};
299
Christopher Thompson0c4e06c22018-07-11 22:29:59300// Time open histogram prefixes.
301const char kPageInfoTimePrefix[] = "Security.PageInfo.TimeOpen";
302const char kPageInfoTimeActionPrefix[] = "Security.PageInfo.TimeOpen.Action";
303const char kPageInfoTimeNoActionPrefix[] =
304 "Security.PageInfo.TimeOpen.NoAction";
305
[email protected]0b9fdd72012-04-04 10:00:33306} // namespace
307
Emily Starkd75d54ce2019-03-12 20:23:09308PageInfo::PageInfo(
309 PageInfoUI* ui,
310 Profile* profile,
311 TabSpecificContentSettings* tab_specific_content_settings,
312 content::WebContents* web_contents,
313 const GURL& url,
314 security_state::SecurityLevel security_level,
315 const security_state::VisibleSecurityState& visible_security_state)
[email protected]df818272012-04-20 13:10:50316 : TabSpecificContentSettings::SiteDataObserver(
317 tab_specific_content_settings),
dominicknbdd53b5f2016-09-28 01:08:13318 content::WebContentsObserver(web_contents),
[email protected]df818272012-04-20 13:10:50319 ui_(ui),
[email protected]66f157312012-08-01 13:50:26320 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33321 site_url_(url),
322 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
Joe DeBlasioecda2b42019-06-26 22:18:40323 safe_browsing_status_(SAFE_BROWSING_STATUS_NONE),
[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),
Michael Thiessen4c9e4a82019-03-08 04:39:44332#if defined(FULL_SAFE_BROWSING)
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
Christopher Thompson0c4e06c22018-07-11 22:29:59337 show_change_password_buttons_(false),
338 did_perform_action_(false) {
Joe DeBlasioc7187e62019-04-25 21:14:15339 ComputeUIInputs(url, security_level, visible_security_state);
[email protected]0b9fdd72012-04-04 10:00:33340
341 PresentSitePermissions();
[email protected]24c8818c2012-04-25 09:57:41342 PresentSiteIdentity();
Pattie8c616202017-09-29 07:58:03343 PresentSiteData();
Suman Kancherlad54a6e5b2019-01-29 22:17:49344 PresentPageFeatureInfo();
[email protected]e22d64f2012-09-10 09:03:23345
lgarron617a30f32017-03-24 21:42:07346 // Every time the Page Info UI is opened a |PageInfo| object is
347 // created. So this counts how ofter the Page Info UI is opened.
348 RecordPageInfoAction(PAGE_INFO_OPENED);
Christopher Thompson0c4e06c22018-07-11 22:29:59349
350 // Record the time when the Page Info UI is opened so the total time it is
351 // open can be measured.
352 start_time_ = base::TimeTicks::Now();
[email protected]03ef4b2a2012-03-06 15:04:20353}
354
Carlos ILe5dfda72017-09-21 02:33:05355PageInfo::~PageInfo() {
356 // Check if Re-enable warnings button was visible, if so, log on UMA whether
357 // it was clicked or not.
358 SSLCertificateDecisionsDidRevoke user_decision =
359 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
360 : USER_CERT_DECISIONS_NOT_REVOKED;
361 if (show_ssl_decision_revoke_button_) {
362 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions2",
363 user_decision,
364 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
365 }
Christopher Thompson0c4e06c22018-07-11 22:29:59366
367 // Record the total time the Page Info UI was open for all opens as well as
368 // split between whether any action was taken.
369 base::UmaHistogramCustomTimes(
Joe DeBlasioc7b95282018-11-08 18:41:37370 security_state::GetSecurityLevelHistogramName(
371 kPageInfoTimePrefix, security_level_),
Christopher Thompson0c4e06c22018-07-11 22:29:59372 base::TimeTicks::Now() - start_time_,
373 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), 100);
374 if (did_perform_action_) {
375 base::UmaHistogramCustomTimes(
Joe DeBlasioc7b95282018-11-08 18:41:37376 security_state::GetSecurityLevelHistogramName(
377 kPageInfoTimeActionPrefix, security_level_),
Christopher Thompson0c4e06c22018-07-11 22:29:59378 base::TimeTicks::Now() - start_time_,
379 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1),
380 100);
381 } else {
382 base::UmaHistogramCustomTimes(
Joe DeBlasioc7b95282018-11-08 18:41:37383 security_state::GetSecurityLevelHistogramName(
384 kPageInfoTimeNoActionPrefix, security_level_),
Christopher Thompson0c4e06c22018-07-11 22:29:59385 base::TimeTicks::Now() - start_time_,
386 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1),
387 100);
388 }
Carlos ILe5dfda72017-09-21 02:33:05389}
[email protected]03ef4b2a2012-03-06 15:04:20390
Joe DeBlasioc7187e62019-04-25 21:14:15391void PageInfo::UpdateSecurityState(
392 security_state::SecurityLevel security_level,
393 const security_state::VisibleSecurityState& visible_security_state) {
394 ComputeUIInputs(site_url_, security_level, visible_security_state);
395 PresentSiteIdentity();
396}
397
lgarron617a30f32017-03-24 21:42:07398void PageInfo::RecordPageInfoAction(PageInfoAction action) {
Christopher Thompson0c4e06c22018-07-11 22:29:59399 if (action != PAGE_INFO_OPENED)
400 did_perform_action_ = true;
401
lgarron617a30f32017-03-24 21:42:07402 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04403
estark8d67cd7a2016-10-24 05:06:41404 std::string histogram_name;
estark8d67cd7a2016-10-24 05:06:41405 if (site_url_.SchemeIsCryptographic()) {
Carlos ILcb2321112018-02-01 18:05:23406 if (security_level_ == security_state::SECURE) {
407 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.ValidNonEV",
408 action, PAGE_INFO_COUNT);
409 } else if (security_level_ == security_state::EV_SECURE) {
410 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.ValidEV",
lgarron617a30f32017-03-24 21:42:07411 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44412 } else if (security_level_ == security_state::NONE) {
estark8d67cd7a2016-10-24 05:06:41413 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded",
lgarron617a30f32017-03-24 21:42:07414 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44415 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41416 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07417 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41418 }
419 return;
420 }
421
esecklercac56b62016-11-16 13:49:44422 if (security_level_ == security_state::HTTP_SHOW_WARNING) {
estark8d67cd7a2016-10-24 05:06:41423 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning",
lgarron617a30f32017-03-24 21:42:07424 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44425 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41426 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07427 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41428 } else {
429 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral",
lgarron617a30f32017-03-24 21:42:07430 action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04431 }
432}
433
lgarron617a30f32017-03-24 21:42:07434void PageInfo::OnSitePermissionChanged(ContentSettingsType type,
435 ContentSetting setting) {
shahriar rostamia9c769d2017-12-06 04:54:08436 tab_specific_content_settings()->ContentSettingChangedViaPageInfo(type);
437
[email protected]e22d64f2012-09-10 09:03:23438 // Count how often a permission for a specific content type is changed using
lgarron617a30f32017-03-24 21:42:07439 // the Page Info UI.
raymes4a13d432015-09-08 00:44:07440 size_t num_values;
441 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
dchengf6f4e4942017-03-30 23:55:57442 UMA_HISTOGRAM_EXACT_LINEAR("WebsiteSettings.OriginInfo.PermissionChanged",
443 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56444
445 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
dchengf6f4e4942017-03-30 23:55:57446 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56447 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07448 num_values);
tommycli34cf29bf2016-09-08 05:46:25449
450 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
451 rappor::SampleDomainAndRegistryFromGURL(
452 g_browser_process->rappor_service(),
453 "ContentSettings.Plugins.AddedAllowException", site_url_);
454 }
sashab9debecd2014-12-18 04:15:56455 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
dchengf6f4e4942017-03-30 23:55:57456 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56457 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07458 num_values);
sashab9debecd2014-12-18 04:15:56459 }
[email protected]e22d64f2012-09-10 09:03:23460
lgarron04a93502014-11-04 22:25:04461 // This is technically redundant given the histogram above, but putting the
462 // total count of permission changes in another histogram makes it easier to
lgarron026e9c42017-04-07 20:09:31463 // compare it against other kinds of actions in Page Info.
lgarron617a30f32017-03-24 21:42:07464 RecordPageInfoAction(PAGE_INFO_CHANGED_PERMISSION);
Tommy Steimeldea90f72017-11-07 20:58:03465 if (type == CONTENT_SETTINGS_TYPE_SOUND) {
466 ContentSetting default_setting =
467 content_settings_->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_SOUND,
468 nullptr);
469 bool mute = (setting == CONTENT_SETTING_BLOCK) ||
470 (setting == CONTENT_SETTING_DEFAULT &&
471 default_setting == CONTENT_SETTING_BLOCK);
472 if (mute) {
473 base::RecordAction(
474 base::UserMetricsAction("SoundContentSetting.MuteBy.PageInfo"));
475 } else {
476 base::RecordAction(
477 base::UserMetricsAction("SoundContentSetting.UnmuteBy.PageInfo"));
478 }
479 }
lgarron04a93502014-11-04 22:25:04480
stefanocs8b3490cc2016-07-28 05:32:52481 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
patricialor7131c1fe2017-04-07 01:25:52482 profile_, site_url_, site_url_, type, PermissionSourceUI::OIB);
stefanocs8b3490cc2016-07-28 05:32:52483
patricialor7131c1fe2017-04-07 01:25:52484 // The permission may have been blocked due to being under embargo, so if it
485 // was changed away from BLOCK, clear embargo status if it exists.
486 if (setting != CONTENT_SETTING_BLOCK) {
487 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveEmbargoByUrl(
488 site_url_, type);
489 }
raymesfbaaaaa2015-11-10 02:20:40490 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
491 setting);
[email protected]df818272012-04-20 13:10:50492
Tommy Steimel97ee2f82017-11-01 21:39:52493 // When the sound setting is changed, no reload is necessary.
494 if (type != CONTENT_SETTINGS_TYPE_SOUND)
495 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24496
497 // Refresh the UI to reflect the new setting.
498 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50499}
500
lgarron617a30f32017-03-24 21:42:07501void PageInfo::OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info,
Ovidio Henriquez3fc113f2019-04-23 14:37:10502 const base::Value& object) {
reillyg85f57db2016-01-12 23:14:38503 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
504 ChooserContextBase* context = ui_info.get_context(profile_);
Reilly Grantbcdeddb2019-05-06 22:37:24505 const auto origin = url::Origin::Create(site_url_);
reillyg36a7fab32016-01-28 19:15:10506 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38507 show_info_bar_ = true;
508
509 // Refresh the UI to reflect the changed settings.
510 PresentSitePermissions();
511}
512
lgarron617a30f32017-03-24 21:42:07513void PageInfo::OnSiteDataAccessed() {
[email protected]df818272012-04-20 13:10:50514 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33515}
516
Dana Fried08b774a2019-05-10 18:21:48517void PageInfo::OnUIClosing(bool* reload_prompt) {
518 if (reload_prompt)
519 *reload_prompt = false;
estade3feb83f2015-09-01 23:00:49520#if defined(OS_ANDROID)
521 NOTREACHED();
522#else
dominicknbdd53b5f2016-09-28 01:08:13523 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
palmerf2cba0d2015-08-27 23:15:06524 InfoBarService* infobar_service =
dominicknbdd53b5f2016-09-28 01:08:13525 InfoBarService::FromWebContents(web_contents());
Dana Fried08b774a2019-05-10 18:21:48526 if (infobar_service) {
lgarron617a30f32017-03-24 21:42:07527 PageInfoInfoBarDelegate::Create(infobar_service);
Dana Fried08b774a2019-05-10 18:21:48528 if (reload_prompt)
529 *reload_prompt = true;
530 }
palmerf2cba0d2015-08-27 23:15:06531 }
estade3feb83f2015-09-01 23:00:49532#endif
jww1ed8ea72014-09-02 20:43:25533}
534
lgarron617a30f32017-03-24 21:42:07535void PageInfo::OnRevokeSSLErrorBypassButtonPressed() {
jww1ed8ea72014-09-02 20:43:25536 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29537 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
538 site_url().host());
jww1ed8ea72014-09-02 20:43:25539 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26540}
541
Patricia Lora21a04cf2017-06-05 02:53:29542void PageInfo::OpenSiteSettingsView() {
Christopher Lam0dbac2b2017-11-14 07:12:10543#if defined(OS_ANDROID)
544 NOTREACHED();
545#else
546 chrome::ShowSiteSettings(chrome::FindBrowserWithWebContents(web_contents()),
547 site_url());
Patricia Lora21a04cf2017-06-05 02:53:29548 RecordPageInfoAction(PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED);
Christopher Lam0dbac2b2017-11-14 07:12:10549#endif
Patricia Lora21a04cf2017-06-05 02:53:29550}
551
Jialiu Lin11e18542017-08-14 18:16:26552void PageInfo::OnChangePasswordButtonPressed(
553 content::WebContents* web_contents) {
Michael Thiessen4c9e4a82019-03-08 04:39:44554#if defined(FULL_SAFE_BROWSING)
Jialiu Lin11e18542017-08-14 18:16:26555 DCHECK(password_protection_service_);
Joe DeBlasioecda2b42019-06-26 22:18:40556 DCHECK(safe_browsing_status_ == SAFE_BROWSING_STATUS_SIGN_IN_PASSWORD_REUSE ||
557 safe_browsing_status_ ==
558 SAFE_BROWSING_STATUS_ENTERPRISE_PASSWORD_REUSE);
Jialiu Lin3fc7f38f2017-09-21 18:38:37559 password_protection_service_->OnUserAction(
Jialiu Lind7defe652018-06-20 18:47:06560 web_contents,
Joe DeBlasioecda2b42019-06-26 22:18:40561 safe_browsing_status_ == SAFE_BROWSING_STATUS_SIGN_IN_PASSWORD_REUSE
Bettina29c22cb52019-06-28 17:41:51562 ? PasswordType::PRIMARY_ACCOUNT_PASSWORD
563 : PasswordType::ENTERPRISE_PASSWORD,
Jialiu Lina97fe522018-07-26 16:47:26564 safe_browsing::WarningUIType::PAGE_INFO,
565 safe_browsing::WarningAction::CHANGE_PASSWORD);
Jialiu Lin11e18542017-08-14 18:16:26566#endif
567}
568
569void PageInfo::OnWhitelistPasswordReuseButtonPressed(
570 content::WebContents* web_contents) {
Michael Thiessen4c9e4a82019-03-08 04:39:44571#if defined(FULL_SAFE_BROWSING)
Jialiu Lin11e18542017-08-14 18:16:26572 DCHECK(password_protection_service_);
Joe DeBlasioecda2b42019-06-26 22:18:40573 DCHECK(safe_browsing_status_ == SAFE_BROWSING_STATUS_SIGN_IN_PASSWORD_REUSE ||
574 safe_browsing_status_ ==
575 SAFE_BROWSING_STATUS_ENTERPRISE_PASSWORD_REUSE);
Jialiu Lin3fc7f38f2017-09-21 18:38:37576 password_protection_service_->OnUserAction(
Jialiu Lind7defe652018-06-20 18:47:06577 web_contents,
Joe DeBlasioecda2b42019-06-26 22:18:40578 safe_browsing_status_ == SAFE_BROWSING_STATUS_SIGN_IN_PASSWORD_REUSE
Bettina29c22cb52019-06-28 17:41:51579 ? PasswordType::PRIMARY_ACCOUNT_PASSWORD
580 : PasswordType::ENTERPRISE_PASSWORD,
Jialiu Lina97fe522018-07-26 16:47:26581 safe_browsing::WarningUIType::PAGE_INFO,
582 safe_browsing::WarningAction::MARK_AS_LEGITIMATE);
Jialiu Lin11e18542017-08-14 18:16:26583#endif
584}
585
Joe DeBlasioc7187e62019-04-25 21:14:15586void PageInfo::ComputeUIInputs(
Emily Starkd75d54ce2019-03-12 20:23:09587 const GURL& url,
588 security_state::SecurityLevel security_level,
589 const security_state::VisibleSecurityState& visible_security_state) {
thestig0c55ee32017-06-20 22:17:51590#if !defined(OS_ANDROID)
meacerde53fcff2016-10-12 19:21:57591 // On desktop, internal URLs aren't handled by this class. Instead, a
lgarron026e9c42017-04-07 20:09:31592 // custom and simpler bubble is shown.
meacerde53fcff2016-10-12 19:21:57593 DCHECK(!url.SchemeIs(content::kChromeUIScheme) &&
594 !url.SchemeIs(content::kChromeDevToolsScheme) &&
595 !url.SchemeIs(content::kViewSourceScheme) &&
596 !url.SchemeIs(content_settings::kExtensionScheme));
597#endif
598
thestig0c55ee32017-06-20 22:17:51599 bool is_chrome_ui_native_scheme = false;
zpengdb4a58e2017-01-10 17:40:32600#if defined(OS_ANDROID)
thestig0c55ee32017-06-20 22:17:51601 is_chrome_ui_native_scheme = url.SchemeIs(chrome::kChromeUINativeScheme);
sashab97894ce2014-10-22 10:08:33602#endif
603
Emily Starkd75d54ce2019-03-12 20:23:09604 security_level_ = security_level;
estark8d67cd7a2016-10-24 05:06:41605
upendrag.gowda60886a6e2015-10-31 05:51:09606 if (url.SchemeIs(url::kAboutScheme)) {
607 // All about: URLs except about:blank are redirected.
608 DCHECK_EQ(url::kAboutBlankURL, url.spec());
609 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
Joe DeBlasioecda2b42019-06-26 22:18:40610 site_details_message_ =
upendrag.gowda60886a6e2015-10-31 05:51:09611 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
612 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
613 site_connection_details_ = l10n_util::GetStringFUTF16(
614 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
615 UTF8ToUTF16(url.spec()));
616 return;
617 }
618
thestig0c55ee32017-06-20 22:17:51619 if (url.SchemeIs(content::kChromeUIScheme) || is_chrome_ui_native_scheme) {
[email protected]03ef4b2a2012-03-06 15:04:20620 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
Joe DeBlasioecda2b42019-06-26 22:18:40621 site_details_message_ =
[email protected]03ef4b2a2012-03-06 15:04:20622 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
623 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
624 return;
625 }
626
[email protected]03ef4b2a2012-03-06 15:04:20627 // Identity section.
Emily Starkd75d54ce2019-03-12 20:23:09628 certificate_ = visible_security_state.certificate;
[email protected]f61c1ce2012-05-09 13:55:11629
Joe DeBlasioecda2b42019-06-26 22:18:40630 if (certificate_ &&
631 (!net::IsCertStatusError(visible_security_state.cert_status) ||
632 net::IsCertStatusMinorError(visible_security_state.cert_status))) {
estarkfcfccdb82016-11-14 02:17:29633 // HTTPS with no or minor errors.
Emily Starkd75d54ce2019-03-12 20:23:09634 if (security_level == security_state::SECURE_WITH_POLICY_INSTALLED_CERT) {
Eric Lawrence6758d1d2017-11-21 16:06:05635#if defined(OS_CHROMEOS)
[email protected]eaf3f322013-04-25 21:53:59636 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
Joe DeBlasioecda2b42019-06-26 22:18:40637 site_details_message_ = l10n_util::GetStringFUTF16(
[email protected]24a9f1c92013-11-13 12:33:37638 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
Eric Lawrence6758d1d2017-11-21 16:06:05639#else
640 DCHECK(false) << "Policy certificates exist only on ChromeOS";
641#endif
Emily Starkd75d54ce2019-03-12 20:23:09642 } else if (net::IsCertStatusMinorError(
643 visible_security_state.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20644 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21645 base::string16 issuer_name(
646 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20647 if (issuer_name.empty()) {
648 issuer_name.assign(l10n_util::GetStringUTF16(
649 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
650 }
[email protected]94c74b42013-12-02 15:19:49651
Joe DeBlasioecda2b42019-06-26 22:18:40652 site_details_message_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39653 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20654
Joe DeBlasioecda2b42019-06-26 22:18:40655 site_details_message_ += ASCIIToUTF16("\n\n");
Emily Starkd75d54ce2019-03-12 20:23:09656 if (visible_security_state.cert_status &
estarka3121f6b2015-09-18 21:15:59657 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
Joe DeBlasioecda2b42019-06-26 22:18:40658 site_details_message_ += l10n_util::GetStringUTF16(
[email protected]03ef4b2a2012-03-06 15:04:20659 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
Emily Starkd75d54ce2019-03-12 20:23:09660 } else if (visible_security_state.cert_status &
estarka3121f6b2015-09-18 21:15:59661 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
Joe DeBlasioecda2b42019-06-26 22:18:40662 site_details_message_ += l10n_util::GetStringUTF16(
[email protected]03ef4b2a2012-03-06 15:04:20663 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
664 } else {
665 NOTREACHED() << "Need to specify string for this warning";
666 }
[email protected]03ef4b2a2012-03-06 15:04:20667 } else {
estarkcf305562016-11-15 03:45:39668 // No major or minor errors.
Emily Starkd75d54ce2019-03-12 20:23:09669 if (visible_security_state.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01670 // EV HTTPS page.
estarkcf305562016-11-15 03:45:39671 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
jam8ae7cad2016-09-08 23:55:21672 DCHECK(!certificate_->subject().organization_names.empty());
673 organization_name_ =
674 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01675 // An EV Cert is required to have a city (localityName) and country but
676 // state is "if any".
jam8ae7cad2016-09-08 23:55:21677 DCHECK(!certificate_->subject().locality_name.empty());
678 DCHECK(!certificate_->subject().country_name.empty());
Joe DeBlasioecda2b42019-06-26 22:18:40679 site_details_message_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39680 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED,
Christopher Thompsonf3ba20122019-06-06 22:01:01681 organization_name_,
682 UTF8ToUTF16(certificate_->subject().country_name)));
rsleevi4f8012722014-09-30 01:28:01683 } else {
684 // Non-EV OK HTTPS page.
estarkcf305562016-11-15 03:45:39685 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
rsleevi4f8012722014-09-30 01:28:01686 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21687 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01688 if (issuer_name.empty()) {
689 issuer_name.assign(l10n_util::GetStringUTF16(
690 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
691 }
[email protected]94c74b42013-12-02 15:19:49692
Joe DeBlasioecda2b42019-06-26 22:18:40693 site_details_message_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39694 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
rsleevi4f8012722014-09-30 01:28:01695 }
Emily Starkd75d54ce2019-03-12 20:23:09696 if (security_state::IsSHA1InChain(visible_security_state)) {
elawrencebe87bd62017-01-10 16:08:59697 site_identity_status_ =
698 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM;
Joe DeBlasioecda2b42019-06-26 22:18:40699 site_details_message_ +=
elawrencebe87bd62017-01-10 16:08:59700 UTF8ToUTF16("\n\n") +
701 l10n_util::GetStringUTF16(
702 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM);
rsleevi4f8012722014-09-30 01:28:01703 }
[email protected]03ef4b2a2012-03-06 15:04:20704 }
705 } else {
706 // HTTP or HTTPS with errors (not warnings).
Joe DeBlasioecda2b42019-06-26 22:18:40707 site_details_message_.assign(l10n_util::GetStringUTF16(
[email protected]03ef4b2a2012-03-06 15:04:20708 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
Emily Starkd75d54ce2019-03-12 20:23:09709 if (!security_state::IsSchemeCryptographic(visible_security_state.url) ||
710 !visible_security_state.certificate) {
[email protected]03ef4b2a2012-03-06 15:04:20711 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
Emily Starkd75d54ce2019-03-12 20:23:09712 } else {
[email protected]03ef4b2a2012-03-06 15:04:20713 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
Emily Starkd75d54ce2019-03-12 20:23:09714 }
[email protected]03ef4b2a2012-03-06 15:04:20715
[email protected]a04db822013-12-11 19:14:40716 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59717 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59718 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
Emily Starkd75d54ce2019-03-12 20:23:09719 certificate_, visible_security_state.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20720 for (size_t i = 0; i < errors.size(); ++i) {
Joe DeBlasioecda2b42019-06-26 22:18:40721 site_details_message_ += bullet;
722 site_details_message_ += errors[i].short_description();
[email protected]03ef4b2a2012-03-06 15:04:20723 }
724
Emily Starkd75d54ce2019-03-12 20:23:09725 if (visible_security_state.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
Joe DeBlasioecda2b42019-06-26 22:18:40726 site_details_message_ += ASCIIToUTF16("\n\n");
727 site_details_message_ +=
lgarron1a6300d2017-03-18 03:33:04728 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
[email protected]03ef4b2a2012-03-06 15:04:20729 }
730 }
731
Joe DeBlasioecda2b42019-06-26 22:18:40732 if (visible_security_state.malicious_content_status !=
733 security_state::MALICIOUS_CONTENT_STATUS_NONE) {
734 // The site has been flagged by Safe Browsing. Takes precedence over TLS.
735 GetSafeBrowsingStatusByMaliciousContentStatus(
736 visible_security_state.malicious_content_status, &safe_browsing_status_,
737 &site_details_message_);
738#if defined(FULL_SAFE_BROWSING)
739 bool old_show_change_pw_buttons = show_change_password_buttons_;
740#endif
741 show_change_password_buttons_ =
742 (visible_security_state.malicious_content_status ==
743 security_state::MALICIOUS_CONTENT_STATUS_SIGN_IN_PASSWORD_REUSE ||
744 visible_security_state.malicious_content_status ==
745 security_state::
746 MALICIOUS_CONTENT_STATUS_ENTERPRISE_PASSWORD_REUSE);
747#if defined(FULL_SAFE_BROWSING)
748 // Only record password reuse when adding the button, not on updates.
749 if (show_change_password_buttons_ && !old_show_change_pw_buttons) {
750 RecordPasswordReuseEvent();
751 }
752#endif
753 }
754
[email protected]03ef4b2a2012-03-06 15:04:20755 // Site Connection
756 // We consider anything less than 80 bits encryption to be weak encryption.
757 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
758 // weakly encrypted connections.
759 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
760
jshin1fb76462016-04-05 22:13:03761 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19762 if (subject_name.empty()) {
763 subject_name.assign(
764 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
765 }
766
Emily Starkd75d54ce2019-03-12 20:23:09767 if (!visible_security_state.certificate ||
768 !security_state::IsSchemeCryptographic(visible_security_state.url)) {
estarka3121f6b2015-09-18 21:15:59769 // Page is still loading (so SSL status is not yet available) or
770 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58771 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
772
773 site_connection_details_.assign(l10n_util::GetStringFUTF16(
774 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
775 subject_name));
Emily Starkd75d54ce2019-03-12 20:23:09776 } else if (!visible_security_state.connection_info_initialized) {
777 DCHECK_NE(security_level, security_state::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20778 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
[email protected]03ef4b2a2012-03-06 15:04:20779 } else {
780 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22781
Emily Starkd75d54ce2019-03-12 20:23:09782 if (net::ObsoleteSSLStatus(
783 visible_security_state.connection_status,
784 visible_security_state.peer_signature_algorithm) ==
785 net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22786 site_connection_details_.assign(l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04787 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, subject_name));
Adam Langley71c2b59b2014-11-13 00:34:22788 } else {
789 site_connection_details_.assign(l10n_util::GetStringFUTF16(
790 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
791 subject_name));
792 }
793
Emily Starkd75d54ce2019-03-12 20:23:09794 ReportAnyInsecureContent(visible_security_state, &site_connection_status_,
thestig4427f13b2017-06-20 20:42:47795 &site_connection_details_);
[email protected]03ef4b2a2012-03-06 15:04:20796 }
797
Emily Starkd75d54ce2019-03-12 20:23:09798 uint16_t cipher_suite = net::SSLConnectionStatusToCipherSuite(
799 visible_security_state.connection_status);
800 if (visible_security_state.connection_info_initialized && cipher_suite) {
801 int ssl_version = net::SSLConnectionStatusToVersion(
802 visible_security_state.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20803 const char* ssl_version_str;
804 net::SSLVersionToString(&ssl_version_str, ssl_version);
805 site_connection_details_ += ASCIIToUTF16("\n\n");
806 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04807 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, ASCIIToUTF16(ssl_version_str));
[email protected]03ef4b2a2012-03-06 15:04:20808
[email protected]03ef4b2a2012-03-06 15:04:20809 const char *key_exchange, *cipher, *mac;
davidben56a8aece2016-10-14 18:20:56810 bool is_aead, is_tls13;
811 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
812 &is_tls13, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20813
814 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57815 if (is_aead) {
davidben56a8aece2016-10-14 18:20:56816 if (is_tls13) {
817 // For TLS 1.3 ciphers, report the group (historically, curve) as the
818 // key exchange.
Emily Starkd75d54ce2019-03-12 20:23:09819 key_exchange =
820 SSL_get_curve_name(visible_security_state.key_exchange_group);
davidben56a8aece2016-10-14 18:20:56821 if (!key_exchange) {
822 NOTREACHED();
823 key_exchange = "";
824 }
825 }
[email protected]b6c1d9e82013-06-12 17:26:57826 site_connection_details_ += l10n_util::GetStringFUTF16(
827 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
828 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
829 } else {
830 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04831 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, ASCIIToUTF16(cipher),
832 ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
[email protected]b6c1d9e82013-06-12 17:26:57833 }
[email protected]03ef4b2a2012-03-06 15:04:20834 }
[email protected]e583f752012-08-30 13:26:21835
[email protected]71cd5ef2014-08-13 21:22:04836 // Check if a user decision has been made to allow or deny certificates with
837 // errors on this site.
838 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50839 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04840 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40841 // Only show an SSL decision revoke button if the user has chosen to bypass
Joe DeBlasioecda2b42019-06-26 22:18:40842 // SSL host errors for this host in the past, and we're not presently on a
843 // Safe Browsing error (since otherwise it's confusing which warning you're
844 // re-enabling).
845 show_ssl_decision_revoke_button_ =
846 delegate->HasAllowException(url.host()) &&
847 visible_security_state.malicious_content_status ==
848 security_state::MALICIOUS_CONTENT_STATUS_NONE;
[email protected]03ef4b2a2012-03-06 15:04:20849}
[email protected]0b9fdd72012-04-04 10:00:33850
lgarron617a30f32017-03-24 21:42:07851void PageInfo::PresentSitePermissions() {
[email protected]df818272012-04-20 13:10:50852 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38853 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50854
lgarron617a30f32017-03-24 21:42:07855 PageInfoUI::PermissionInfo permission_info;
Avi Drissman22f82872018-12-25 23:09:07856 for (size_t i = 0; i < base::size(kPermissionType); ++i) {
[email protected]df818272012-04-20 13:10:50857 permission_info.type = kPermissionType[i];
858
859 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32860 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
861 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21862 DCHECK(value.get());
jdoerrie76cee9c2017-10-06 22:42:42863 if (value->type() == base::Value::Type::INTEGER) {
sashab2b2a314f2015-01-17 06:42:21864 permission_info.setting =
865 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26866 } else {
sashab2b2a314f2015-01-17 06:42:21867 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26868 }
869
[email protected]8bdf45c32012-08-04 00:12:55870 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28871 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50872
[email protected]b1d113d2012-06-27 21:27:34873 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21874 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34875 permission_info.default_setting = permission_info.setting;
876 permission_info.setting = CONTENT_SETTING_DEFAULT;
877 } else {
878 permission_info.default_setting =
879 content_settings_->GetDefaultContentSetting(permission_info.type,
880 NULL);
[email protected]df818272012-04-20 13:10:50881 }
palmer0da10b32015-02-11 00:42:19882
patricialor2a4f41a2017-03-08 02:52:56883 // For permissions that are still prompting the user and haven't been
884 // explicitly set by another source, check its embargo status.
885 if (PermissionUtil::IsPermission(permission_info.type) &&
886 permission_info.setting == CONTENT_SETTING_DEFAULT &&
887 permission_info.source ==
888 content_settings::SettingSource::SETTING_SOURCE_USER) {
889 // TODO(raymes): Use GetPermissionStatus() to retrieve information
890 // about *all* permissions once it has default behaviour implemented for
891 // ContentSettingTypes that aren't permissions.
892 PermissionResult permission_result =
893 PermissionManager::Get(profile_)->GetPermissionStatus(
894 permission_info.type, site_url_, site_url_);
895
896 // If under embargo, update |permission_info| to reflect that.
897 if (permission_result.content_setting == CONTENT_SETTING_BLOCK &&
Timothy Loh8fbdac52018-03-15 03:34:30898 permission_result.source ==
899 PermissionStatusSource::MULTIPLE_DISMISSALS) {
patricialor2a4f41a2017-03-08 02:52:56900 permission_info.setting = permission_result.content_setting;
Timothy Loh8fbdac52018-03-15 03:34:30901 }
patricialor2a4f41a2017-03-08 02:52:56902 }
903
Tommy Steimelc9f6c932017-10-13 23:33:04904 if (ShouldShowPermission(permission_info, site_url_, content_settings_,
shahriar rostamia9c769d2017-12-06 04:54:08905 web_contents(), tab_specific_content_settings())) {
Patti0601e532017-09-20 08:39:30906 permission_info_list.push_back(permission_info);
Tommy Steimelc9f6c932017-10-13 23:33:04907 }
[email protected]df818272012-04-20 13:10:50908 }
909
Reilly Grantbcdeddb2019-05-06 22:37:24910 const auto origin = url::Origin::Create(site_url_);
reillyg85f57db2016-01-12 23:14:38911 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
912 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10913 auto chosen_objects = context->GetGrantedObjects(origin, origin);
Ovidio Henriquez0e7c32a2019-01-16 03:15:29914 for (std::unique_ptr<ChooserContextBase::Object>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38915 chosen_object_info_list.push_back(
Jinho Bangcc280792018-01-17 23:33:55916 std::make_unique<PageInfoUI::ChosenObjectInfo>(ui_info,
lgarron617a30f32017-03-24 21:42:07917 std::move(object)));
reillyg85f57db2016-01-12 23:14:38918 }
919 }
920
avi09dd4d02016-10-14 20:40:09921 ui_->SetPermissionInfo(permission_info_list,
922 std::move(chosen_object_info_list));
[email protected]0b9fdd72012-04-04 10:00:33923}
924
lgarron617a30f32017-03-24 21:42:07925void PageInfo::PresentSiteData() {
[email protected]df818272012-04-20 13:10:50926 CookieInfoList cookie_info_list;
vabrbab3ffcb2016-10-04 10:08:10927 const LocalSharedObjectsContainer& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34928 tab_specific_content_settings()->allowed_local_shared_objects();
vabrbab3ffcb2016-10-04 10:08:10929 const LocalSharedObjectsContainer& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34930 tab_specific_content_settings()->blocked_local_shared_objects();
931
932 // Add first party cookie and site data counts.
lgarron617a30f32017-03-24 21:42:07933 PageInfoUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34934 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
935 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15936 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34937 cookie_info_list.push_back(cookie_info);
938
939 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34940 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
941 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15942 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50943 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33944
[email protected]df818272012-04-20 13:10:50945 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33946}
[email protected]16de6de2012-04-04 12:24:14947
lgarron617a30f32017-03-24 21:42:07948void PageInfo::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04949 // After initialization the status about the site's connection and its
950 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41951 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
952 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
lgarron617a30f32017-03-24 21:42:07953 PageInfoUI::IdentityInfo info;
[email protected]24c8818c2012-04-25 09:57:41954 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
955 info.site_identity = UTF16ToUTF8(organization_name());
956 else
jshin1fb76462016-04-05 22:13:03957 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41958
959 info.connection_status = site_connection_status_;
lgarron1a6300d2017-03-18 03:33:04960 info.connection_status_description = UTF16ToUTF8(site_connection_details_);
[email protected]24c8818c2012-04-25 09:57:41961 info.identity_status = site_identity_status_;
Joe DeBlasioecda2b42019-06-26 22:18:40962 info.safe_browsing_status = safe_browsing_status_;
963 info.identity_status_description = UTF16ToUTF8(site_details_message_);
jam8ae7cad2016-09-08 23:55:21964 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04965 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
Jialiu Lin11e18542017-08-14 18:16:26966 info.show_change_password_buttons = show_change_password_buttons_;
[email protected]24c8818c2012-04-25 09:57:41967 ui_->SetIdentityInfo(info);
[email protected]24c8818c2012-04-25 09:57:41968}
Patti7f21c4b2017-11-28 03:37:17969
Suman Kancherlad54a6e5b2019-01-29 22:17:49970void PageInfo::PresentPageFeatureInfo() {
971 PageInfoUI::PageFeatureInfo info;
972 info.is_vr_presentation_in_headset =
973 vr::VrTabHelper::IsContentDisplayedInHeadset(web_contents());
974
975 ui_->SetPageFeatureInfo(info);
976}
977
Joe DeBlasioc7187e62019-04-25 21:14:15978#if defined(FULL_SAFE_BROWSING)
979void PageInfo::RecordPasswordReuseEvent() {
980 if (!password_protection_service_) {
981 return;
982 }
983
Joe DeBlasioecda2b42019-06-26 22:18:40984 if (safe_browsing_status_ == SAFE_BROWSING_STATUS_SIGN_IN_PASSWORD_REUSE) {
Joe DeBlasioc7187e62019-04-25 21:14:15985 safe_browsing::LogWarningAction(
986 safe_browsing::WarningUIType::PAGE_INFO,
987 safe_browsing::WarningAction::SHOWN,
Bettina29c22cb52019-06-28 17:41:51988 password_protection_service_
989 ->GetPasswordProtectionReusedPasswordAccountType(
990 PasswordType::PRIMARY_ACCOUNT_PASSWORD,
991 (password_protection_service_->GetAccountInfo())
992 .hosted_domain));
Joe DeBlasioc7187e62019-04-25 21:14:15993 } else {
994 safe_browsing::LogWarningAction(
995 safe_browsing::WarningUIType::PAGE_INFO,
996 safe_browsing::WarningAction::SHOWN,
Bettina29c22cb52019-06-28 17:41:51997 password_protection_service_
998 ->GetPasswordProtectionReusedPasswordAccountType(
999 PasswordType::ENTERPRISE_PASSWORD,
1000 (password_protection_service_->GetAccountInfo())
1001 .hosted_domain));
Joe DeBlasioc7187e62019-04-25 21:14:151002 }
1003}
1004#endif
1005
Patti7f21c4b2017-11-28 03:37:171006std::vector<ContentSettingsType> PageInfo::GetAllPermissionsForTesting() {
1007 std::vector<ContentSettingsType> permission_list;
Avi Drissman22f82872018-12-25 23:09:071008 for (size_t i = 0; i < base::size(kPermissionType); ++i) {
Patti7f21c4b2017-11-28 03:37:171009#if !defined(OS_ANDROID)
1010 if (kPermissionType[i] == CONTENT_SETTINGS_TYPE_AUTOPLAY)
1011 continue;
1012#endif
1013 permission_list.push_back(kPermissionType[i]);
1014 }
1015 return permission_list;
1016}
Jialiu Lin4d7c6042018-04-04 17:45:351017
Joe DeBlasioecda2b42019-06-26 22:18:401018void PageInfo::GetSafeBrowsingStatusByMaliciousContentStatus(
Jialiu Lin4d7c6042018-04-04 17:45:351019 security_state::MaliciousContentStatus malicious_content_status,
Joe DeBlasioecda2b42019-06-26 22:18:401020 PageInfo::SafeBrowsingStatus* status,
Jialiu Lin4d7c6042018-04-04 17:45:351021 base::string16* details) {
1022 switch (malicious_content_status) {
1023 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
1024 NOTREACHED();
1025 break;
1026 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
Joe DeBlasioecda2b42019-06-26 22:18:401027 *status = PageInfo::SAFE_BROWSING_STATUS_MALWARE;
Jialiu Lin4d7c6042018-04-04 17:45:351028 *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MALWARE_DETAILS);
1029 break;
1030 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
Joe DeBlasioecda2b42019-06-26 22:18:401031 *status = PageInfo::SAFE_BROWSING_STATUS_SOCIAL_ENGINEERING;
Jialiu Lin4d7c6042018-04-04 17:45:351032 *details =
1033 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SOCIAL_ENGINEERING_DETAILS);
1034 break;
1035 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
Joe DeBlasioecda2b42019-06-26 22:18:401036 *status = PageInfo::SAFE_BROWSING_STATUS_UNWANTED_SOFTWARE;
Jialiu Lin4d7c6042018-04-04 17:45:351037 *details =
1038 l10n_util::GetStringUTF16(IDS_PAGE_INFO_UNWANTED_SOFTWARE_DETAILS);
1039 break;
Jialiu Lind7defe652018-06-20 18:47:061040 case security_state::MALICIOUS_CONTENT_STATUS_SIGN_IN_PASSWORD_REUSE:
Michael Thiessen4c9e4a82019-03-08 04:39:441041#if defined(FULL_SAFE_BROWSING)
Joe DeBlasioecda2b42019-06-26 22:18:401042 *status = PageInfo::SAFE_BROWSING_STATUS_SIGN_IN_PASSWORD_REUSE;
Jialiu Lind7defe652018-06-20 18:47:061043 // |password_protection_service_| may be null in test.
1044 *details = password_protection_service_
1045 ? password_protection_service_->GetWarningDetailText(
Bettina29c22cb52019-06-28 17:41:511046 PasswordType::PRIMARY_ACCOUNT_PASSWORD)
Jialiu Lind7defe652018-06-20 18:47:061047 : base::string16();
1048#endif
1049 break;
1050 case security_state::MALICIOUS_CONTENT_STATUS_ENTERPRISE_PASSWORD_REUSE:
Michael Thiessen4c9e4a82019-03-08 04:39:441051#if defined(FULL_SAFE_BROWSING)
Joe DeBlasioecda2b42019-06-26 22:18:401052 *status = PageInfo::SAFE_BROWSING_STATUS_ENTERPRISE_PASSWORD_REUSE;
Jialiu Lind7defe652018-06-20 18:47:061053 // |password_protection_service_| maybe null in test.
1054 *details = password_protection_service_
1055 ? password_protection_service_->GetWarningDetailText(
Bettina29c22cb52019-06-28 17:41:511056 PasswordType::ENTERPRISE_PASSWORD)
Jialiu Lind7defe652018-06-20 18:47:061057 : base::string16();
Jialiu Lin4d7c6042018-04-04 17:45:351058#endif
1059 break;
spqchan6da308a2018-08-10 19:19:531060 case security_state::MALICIOUS_CONTENT_STATUS_BILLING:
Joe DeBlasioecda2b42019-06-26 22:18:401061 *status = PageInfo::SAFE_BROWSING_STATUS_BILLING;
spqchan6da308a2018-08-10 19:19:531062 *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_BILLING_DETAILS);
spqchan6da308a2018-08-10 19:19:531063 break;
Jialiu Lin4d7c6042018-04-04 17:45:351064 }
1065}