blob: bfcf8101d369d36d435339f799c962a1247a3075 [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"
nzolghadrd87a308d2016-12-07 15:45:5660#include "components/rappor/public/rappor_utils.h"
61#include "components/rappor/rappor_service_impl.h"
felt2493b4452015-09-17 20:33:5962#include "components/ssl_errors/error_info.h"
thestig4a2e88e2016-08-27 23:23:5163#include "components/strings/grit/components_chromium_strings.h"
64#include "components/strings/grit/components_strings.h"
melandory7be36d312017-03-29 15:51:1265#include "components/subresource_filter/core/browser/subresource_filter_features.h"
palmer153af982015-09-15 02:04:1966#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3367#include "content/public/browser/browser_thread.h"
[email protected]eb2140c2013-07-29 12:37:3468#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2069#include "content/public/common/url_constants.h"
[email protected]6e7845ae2013-03-29 21:48:1170#include "net/cert/cert_status_flags.h"
71#include "net/cert/x509_certificate.h"
[email protected]536fd0b2013-03-14 17:41:5772#include "net/ssl/ssl_cipher_suite_names.h"
73#include "net/ssl/ssl_connection_status_flags.h"
tfarina29a3a1742016-10-28 18:47:3374#include "third_party/boringssl/src/include/openssl/ssl.h"
[email protected]03ef4b2a2012-03-06 15:04:2075#include "ui/base/l10n/l10n_util.h"
Patricia Lora21a04cf2017-06-05 02:53:2976#include "url/origin.h"
[email protected]03ef4b2a2012-03-06 15:04:2077
[email protected]24a9f1c92013-11-13 12:33:3778#if defined(OS_CHROMEOS)
79#include "chrome/browser/chromeos/policy/policy_cert_service.h"
80#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
81#endif
82
estade3feb83f2015-09-01 23:00:4983#if !defined(OS_ANDROID)
Reilly Grant4e9d4f22019-02-13 17:17:3084#include "chrome/browser/serial/serial_chooser_context.h"
85#include "chrome/browser/serial/serial_chooser_context_factory.h"
Christopher Lam0dbac2b2017-11-14 07:12:1086#include "chrome/browser/ui/browser_finder.h"
87#include "chrome/browser/ui/chrome_pages.h"
mgiucaa319f212016-01-14 03:30:1188#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
lgarron617a30f32017-03-24 21:42:0789#include "chrome/browser/ui/page_info/page_info_infobar_delegate.h"
estade3feb83f2015-09-01 23:00:4990#endif
91
Jialiu Lin11e18542017-08-14 18:16:2692#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin0d8cc722017-09-19 01:01:5193#include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
Jialiu Lin11e18542017-08-14 18:16:2694#endif
95
[email protected]ab6df3b12013-12-24 23:32:2696using base::ASCIIToUTF16;
97using base::UTF8ToUTF16;
[email protected]f729d7a2013-12-26 07:07:5698using base::UTF16ToUTF8;
[email protected]0b9fdd72012-04-04 10:00:3399using content::BrowserThread;
Jialiu Lind7defe652018-06-20 18:47:06100#if defined(SAFE_BROWSING_DB_LOCAL)
101using PasswordReuseEvent =
102 safe_browsing::LoginReputationClientRequest::PasswordReuseEvent;
103#endif // SAFE_BROWSING_DB_LOCAL
[email protected]0b9fdd72012-04-04 10:00:33104
105namespace {
106
lgarron617a30f32017-03-24 21:42:07107// The list of content settings types to display on the Page Info UI. THE
csharrisonad1eaa6c2017-05-11 17:14:38108// ORDER OF THESE ITEMS IS IMPORTANT and comes from https://crbug.com/610358. To
109// propose changing it, email [email protected].
[email protected]0b9fdd72012-04-04 10:00:33110ContentSettingsType kPermissionType[] = {
sashab2b2a314f2015-01-17 06:42:21111 CONTENT_SETTINGS_TYPE_GEOLOCATION,
sashab2b2a314f2015-01-17 06:42:21112 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
113 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
Alexander Shalamovce5aab52018-02-07 11:45:15114 CONTENT_SETTINGS_TYPE_SENSORS,
palmer0da10b32015-02-11 00:42:19115 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
palmer7715e332016-05-27 00:41:19116 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
lshange085f202016-06-14 01:25:08117#if !defined(OS_ANDROID)
palmer7715e332016-05-27 00:41:19118 CONTENT_SETTINGS_TYPE_PLUGINS,
119 CONTENT_SETTINGS_TYPE_IMAGES,
lshange085f202016-06-14 01:25:08120#endif
palmer7715e332016-05-27 00:41:19121 CONTENT_SETTINGS_TYPE_POPUPS,
Charles Harrison239d47982017-06-13 02:42:31122 CONTENT_SETTINGS_TYPE_ADS,
nsatragno670fe922016-04-08 14:10:50123 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
Tommy Steimela8c3757e2017-08-24 00:15:46124 CONTENT_SETTINGS_TYPE_SOUND,
palmer7715e332016-05-27 00:41:19125 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
finnur46cafd42016-09-22 10:27:17126 CONTENT_SETTINGS_TYPE_AUTOPLAY,
palmer7715e332016-05-27 00:41:19127 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
Gary Kacmarcik10533cf2017-11-22 03:31:28128 CONTENT_SETTINGS_TYPE_CLIPBOARD_READ,
Reilly Granta69ab672018-04-06 18:26:07129 CONTENT_SETTINGS_TYPE_USB_GUARD,
[email protected]0b9fdd72012-04-04 10:00:33130};
131
Patti0601e532017-09-20 08:39:30132// Checks whether this permission is currently the factory default, as set by
133// Chrome. Specifically, that the following three conditions are true:
134// - The current active setting comes from the default or pref provider.
135// - The setting is the factory default setting (as opposed to a global
136// default setting set by the user).
137// - The setting is a wildcard setting applying to all origins (which can only
138// be set from the default provider).
139bool IsPermissionFactoryDefault(HostContentSettingsMap* content_settings,
140 const PageInfoUI::PermissionInfo& info) {
141 const ContentSetting factory_default_setting =
142 content_settings::ContentSettingsRegistry::GetInstance()
143 ->Get(info.type)
144 ->GetInitialDefaultSetting();
145 return (info.source == content_settings::SETTING_SOURCE_USER &&
146 factory_default_setting == info.default_setting &&
147 info.setting == CONTENT_SETTING_DEFAULT);
148}
149
lgarron617a30f32017-03-24 21:42:07150// Determines whether to show permission |type| in the Page Info UI. Only
mgiucaa319f212016-01-14 03:30:11151// applies to permissions listed in |kPermissionType|.
shahriar rostamia9c769d2017-12-06 04:54:08152bool ShouldShowPermission(
153 const PageInfoUI::PermissionInfo& info,
154 const GURL& site_url,
155 HostContentSettingsMap* content_settings,
156 content::WebContents* web_contents,
157 TabSpecificContentSettings* tab_specific_content_settings) {
Patti0601e532017-09-20 08:39:30158 // Note |CONTENT_SETTINGS_TYPE_ADS| will show up regardless of its default
159 // value when it has been activated on the current origin.
160 if (info.type == CONTENT_SETTINGS_TYPE_ADS) {
csharrisonad1eaa6c2017-05-11 17:14:38161 if (!base::FeatureList::IsEnabled(
Charlie Harrisonb73f7622018-06-01 14:24:34162 subresource_filter::kSafeBrowsingSubresourceFilter)) {
csharrisonad1eaa6c2017-05-11 17:14:38163 return false;
164 }
165
166 // The setting for subresource filtering should not show up if the site is
167 // not activated, both on android and desktop platforms.
168 return content_settings->GetWebsiteSetting(
Charles Harrison239d47982017-06-13 02:42:31169 site_url, GURL(), CONTENT_SETTINGS_TYPE_ADS_DATA, std::string(),
170 nullptr) != nullptr;
melandory7be36d312017-03-29 15:51:12171 }
172
Tommy Steimelc9f6c932017-10-13 23:33:04173 if (info.type == CONTENT_SETTINGS_TYPE_SOUND) {
174 if (!base::FeatureList::IsEnabled(features::kSoundContentSetting))
175 return false;
176
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
Gary Kacmarcik10533cf2017-11-22 03:31:28183 if (info.type == CONTENT_SETTINGS_TYPE_CLIPBOARD_READ) {
184 if (!base::FeatureList::IsEnabled(features::kClipboardContentSetting))
185 return false;
186 }
187
Patti749d4d12017-10-11 06:20:30188#if defined(OS_ANDROID)
189 // Special geolocation DSE settings apply only on Android, so make sure it
190 // gets checked there regardless of default setting on Desktop.
191 if (info.type == CONTENT_SETTINGS_TYPE_GEOLOCATION)
192 return true;
Pattid7c4d542017-12-07 00:54:14193#else
Patti8c57f37d2018-01-31 04:33:21194 // Flash is shown if the user has ever changed its setting for |site_url|.
195 if (info.type == CONTENT_SETTINGS_TYPE_PLUGINS &&
196 content_settings->GetWebsiteSetting(site_url, site_url,
197 CONTENT_SETTINGS_TYPE_PLUGINS_DATA,
198 std::string(), nullptr) != nullptr) {
Pattid7c4d542017-12-07 00:54:14199 return true;
Patti8c57f37d2018-01-31 04:33:21200 }
Patti749d4d12017-10-11 06:20:30201#endif
202
Patti0601e532017-09-20 08:39:30203#if !defined(OS_ANDROID)
204 // Autoplay is Android-only at the moment.
205 if (info.type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
206 return false;
207#endif
208
shahriar rostamia9c769d2017-12-06 04:54:08209 // Show the content setting if it has been changed by the user since the last
210 // page load.
211 if (tab_specific_content_settings->HasContentSettingChangedViaPageInfo(
212 info.type)) {
213 return true;
214 }
215
216 // Show the content setting when it has a non-default value.
217 if (!IsPermissionFactoryDefault(content_settings, info))
218 return true;
219
220 return false;
mgiucaa319f212016-01-14 03:30:11221}
222
esecklercac56b62016-11-16 13:49:44223void CheckContentStatus(security_state::ContentStatus content_status,
estark00e83f12016-08-19 18:24:04224 bool* displayed,
225 bool* ran) {
226 switch (content_status) {
esecklercac56b62016-11-16 13:49:44227 case security_state::CONTENT_STATUS_DISPLAYED:
estark00e83f12016-08-19 18:24:04228 *displayed = true;
229 break;
esecklercac56b62016-11-16 13:49:44230 case security_state::CONTENT_STATUS_RAN:
estark00e83f12016-08-19 18:24:04231 *ran = true;
232 break;
esecklercac56b62016-11-16 13:49:44233 case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN:
estark00e83f12016-08-19 18:24:04234 *displayed = true;
235 *ran = true;
236 break;
esecklercac56b62016-11-16 13:49:44237 case security_state::CONTENT_STATUS_UNKNOWN:
238 case security_state::CONTENT_STATUS_NONE:
estark00e83f12016-08-19 18:24:04239 break;
240 }
241}
242
elawrenceb2ac2a232017-03-27 21:46:25243// If the |security_info| indicates that mixed content or certificate errors
244// were present, update |connection_status| and |connection_details|.
245void ReportAnyInsecureContent(const security_state::SecurityInfo& security_info,
thestig4427f13b2017-06-20 20:42:47246 PageInfo::SiteConnectionStatus* connection_status,
247 base::string16* connection_details) {
elawrenceb2ac2a232017-03-27 21:46:25248 bool displayed_insecure_content = false;
249 bool ran_insecure_content = false;
250 CheckContentStatus(security_info.mixed_content_status,
251 &displayed_insecure_content, &ran_insecure_content);
252 // Only note subresources with certificate errors if the main resource was
253 // loaded without major certificate errors. If the main resource had a
254 // certificate error, then it would not be that useful (and could
255 // potentially be confusing) to warn about subresources that had certificate
256 // errors too.
257 if (!net::IsCertStatusError(security_info.cert_status) ||
258 net::IsCertStatusMinorError(security_info.cert_status)) {
259 CheckContentStatus(security_info.content_with_cert_errors_status,
260 &displayed_insecure_content, &ran_insecure_content);
261 }
262
263 // Only one insecure content warning is displayed; show the most severe.
264 if (ran_insecure_content) {
thestig4427f13b2017-06-20 20:42:47265 *connection_status =
elawrenceb2ac2a232017-03-27 21:46:25266 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE;
thestig4427f13b2017-06-20 20:42:47267 connection_details->assign(l10n_util::GetStringFUTF16(
268 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25269 l10n_util::GetStringUTF16(
270 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR)));
estark00e83f12016-08-19 18:24:04271 return;
272 }
elawrenceb2ac2a232017-03-27 21:46:25273 if (security_info.contained_mixed_form) {
thestig4427f13b2017-06-20 20:42:47274 *connection_status = PageInfo::SITE_CONNECTION_STATUS_INSECURE_FORM_ACTION;
275 connection_details->assign(l10n_util::GetStringFUTF16(
276 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25277 l10n_util::GetStringUTF16(
278 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_FORM_WARNING)));
279 return;
280 }
281 if (displayed_insecure_content) {
thestig4427f13b2017-06-20 20:42:47282 *connection_status =
elawrenceb2ac2a232017-03-27 21:46:25283 PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
thestig4427f13b2017-06-20 20:42:47284 connection_details->assign(l10n_util::GetStringFUTF16(
285 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25286 l10n_util::GetStringUTF16(
287 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
288 }
estark00e83f12016-08-19 18:24:04289}
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
Reilly Grant4e9d4f22019-02-13 17:17:30300#if !defined(OS_ANDROID)
301ChooserContextBase* GetSerialChooserContext(Profile* profile) {
302 return SerialChooserContextFactory::GetForProfile(profile);
303}
304#endif
305
reillyg85f57db2016-01-12 23:14:38306// The list of chooser types that need to display entries in the Website
307// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
308// email [email protected].
Andrew Grieved1978b0e2017-07-28 15:53:41309const PageInfo::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52310 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
Reilly Grant4e9d4f22019-02-13 17:17:30311 IDS_PAGE_INFO_USB_DEVICE_SECONDARY_LABEL,
Ovidio Henriquez017d3b8f2019-02-01 18:51:24312 IDS_PAGE_INFO_USB_DEVICE_ALLOWED_BY_POLICY_LABEL,
Patti1d8a4312018-01-19 06:36:11313 IDS_PAGE_INFO_DELETE_USB_DEVICE, "name"},
Reilly Grant4e9d4f22019-02-13 17:17:30314#if !defined(OS_ANDROID)
315 {CONTENT_SETTINGS_TYPE_SERIAL_CHOOSER_DATA, &GetSerialChooserContext,
316 IDS_PAGE_INFO_SERIAL_PORT_SECONDARY_LABEL,
317 /*allowed_by_policy_description_string_id=*/-1,
318 IDS_PAGE_INFO_DELETE_SERIAL_PORT, "name"},
319#endif
reillyg85f57db2016-01-12 23:14:38320};
321
Christopher Thompson0c4e06c22018-07-11 22:29:59322// Time open histogram prefixes.
323const char kPageInfoTimePrefix[] = "Security.PageInfo.TimeOpen";
324const char kPageInfoTimeActionPrefix[] = "Security.PageInfo.TimeOpen.Action";
325const char kPageInfoTimeNoActionPrefix[] =
326 "Security.PageInfo.TimeOpen.NoAction";
327
[email protected]0b9fdd72012-04-04 10:00:33328} // namespace
329
lgarron617a30f32017-03-24 21:42:07330PageInfo::PageInfo(PageInfoUI* ui,
331 Profile* profile,
332 TabSpecificContentSettings* tab_specific_content_settings,
333 content::WebContents* web_contents,
334 const GURL& url,
335 const security_state::SecurityInfo& security_info)
[email protected]df818272012-04-20 13:10:50336 : TabSpecificContentSettings::SiteDataObserver(
337 tab_specific_content_settings),
dominicknbdd53b5f2016-09-28 01:08:13338 content::WebContentsObserver(web_contents),
[email protected]df818272012-04-20 13:10:50339 ui_(ui),
[email protected]66f157312012-08-01 13:50:26340 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33341 site_url_(url),
342 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]03ef4b2a2012-03-06 15:04:20343 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
alshabalin5e894c12016-10-25 06:47:46344 show_ssl_decision_revoke_button_(false),
peconn5100d432015-09-16 12:03:08345 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04346 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25347 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19348 did_revoke_user_ssl_decisions_(false),
estark8d67cd7a2016-10-24 05:06:41349 profile_(profile),
Jialiu Lin11e18542017-08-14 18:16:26350 security_level_(security_state::NONE),
Jialiu Linfeb6bb32017-08-30 00:21:36351#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin0d8cc722017-09-19 01:01:51352 password_protection_service_(
353 safe_browsing::ChromePasswordProtectionService::
354 GetPasswordProtectionService(profile_)),
Jialiu Lin11e18542017-08-14 18:16:26355#endif
Christopher Thompson0c4e06c22018-07-11 22:29:59356 show_change_password_buttons_(false),
357 did_perform_action_(false) {
estarka3121f6b2015-09-18 21:15:59358 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33359
360 PresentSitePermissions();
[email protected]24c8818c2012-04-25 09:57:41361 PresentSiteIdentity();
Pattie8c616202017-09-29 07:58:03362 PresentSiteData();
Suman Kancherlad54a6e5b2019-01-29 22:17:49363 PresentPageFeatureInfo();
[email protected]e22d64f2012-09-10 09:03:23364
lgarron617a30f32017-03-24 21:42:07365 // Every time the Page Info UI is opened a |PageInfo| object is
366 // created. So this counts how ofter the Page Info UI is opened.
367 RecordPageInfoAction(PAGE_INFO_OPENED);
Christopher Thompson0c4e06c22018-07-11 22:29:59368
369 // Record the time when the Page Info UI is opened so the total time it is
370 // open can be measured.
371 start_time_ = base::TimeTicks::Now();
[email protected]03ef4b2a2012-03-06 15:04:20372}
373
Carlos ILe5dfda72017-09-21 02:33:05374PageInfo::~PageInfo() {
375 // Check if Re-enable warnings button was visible, if so, log on UMA whether
376 // it was clicked or not.
377 SSLCertificateDecisionsDidRevoke user_decision =
378 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
379 : USER_CERT_DECISIONS_NOT_REVOKED;
380 if (show_ssl_decision_revoke_button_) {
381 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions2",
382 user_decision,
383 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
384 }
Christopher Thompson0c4e06c22018-07-11 22:29:59385
386 // Record the total time the Page Info UI was open for all opens as well as
387 // split between whether any action was taken.
388 base::UmaHistogramCustomTimes(
Joe DeBlasioc7b95282018-11-08 18:41:37389 security_state::GetSecurityLevelHistogramName(
390 kPageInfoTimePrefix, security_level_),
Christopher Thompson0c4e06c22018-07-11 22:29:59391 base::TimeTicks::Now() - start_time_,
392 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), 100);
393 if (did_perform_action_) {
394 base::UmaHistogramCustomTimes(
Joe DeBlasioc7b95282018-11-08 18:41:37395 security_state::GetSecurityLevelHistogramName(
396 kPageInfoTimeActionPrefix, security_level_),
Christopher Thompson0c4e06c22018-07-11 22:29:59397 base::TimeTicks::Now() - start_time_,
398 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1),
399 100);
400 } else {
401 base::UmaHistogramCustomTimes(
Joe DeBlasioc7b95282018-11-08 18:41:37402 security_state::GetSecurityLevelHistogramName(
403 kPageInfoTimeNoActionPrefix, security_level_),
Christopher Thompson0c4e06c22018-07-11 22:29:59404 base::TimeTicks::Now() - start_time_,
405 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1),
406 100);
407 }
Carlos ILe5dfda72017-09-21 02:33:05408}
[email protected]03ef4b2a2012-03-06 15:04:20409
lgarron617a30f32017-03-24 21:42:07410void PageInfo::RecordPageInfoAction(PageInfoAction action) {
Christopher Thompson0c4e06c22018-07-11 22:29:59411 if (action != PAGE_INFO_OPENED)
412 did_perform_action_ = true;
413
lgarron617a30f32017-03-24 21:42:07414 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04415
estark8d67cd7a2016-10-24 05:06:41416 std::string histogram_name;
estark8d67cd7a2016-10-24 05:06:41417 if (site_url_.SchemeIsCryptographic()) {
Carlos ILcb2321112018-02-01 18:05:23418 if (security_level_ == security_state::SECURE) {
419 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.ValidNonEV",
420 action, PAGE_INFO_COUNT);
421 } else if (security_level_ == security_state::EV_SECURE) {
422 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.ValidEV",
lgarron617a30f32017-03-24 21:42:07423 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44424 } else if (security_level_ == security_state::NONE) {
estark8d67cd7a2016-10-24 05:06:41425 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded",
lgarron617a30f32017-03-24 21:42:07426 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44427 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41428 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07429 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41430 }
431 return;
432 }
433
esecklercac56b62016-11-16 13:49:44434 if (security_level_ == security_state::HTTP_SHOW_WARNING) {
estark8d67cd7a2016-10-24 05:06:41435 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning",
lgarron617a30f32017-03-24 21:42:07436 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44437 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41438 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07439 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41440 } else {
441 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral",
lgarron617a30f32017-03-24 21:42:07442 action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04443 }
444}
445
lgarron617a30f32017-03-24 21:42:07446void PageInfo::OnSitePermissionChanged(ContentSettingsType type,
447 ContentSetting setting) {
shahriar rostamia9c769d2017-12-06 04:54:08448 tab_specific_content_settings()->ContentSettingChangedViaPageInfo(type);
449
[email protected]e22d64f2012-09-10 09:03:23450 // Count how often a permission for a specific content type is changed using
lgarron617a30f32017-03-24 21:42:07451 // the Page Info UI.
raymes4a13d432015-09-08 00:44:07452 size_t num_values;
453 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
dchengf6f4e4942017-03-30 23:55:57454 UMA_HISTOGRAM_EXACT_LINEAR("WebsiteSettings.OriginInfo.PermissionChanged",
455 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56456
457 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
dchengf6f4e4942017-03-30 23:55:57458 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56459 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07460 num_values);
tommycli34cf29bf2016-09-08 05:46:25461
462 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
463 rappor::SampleDomainAndRegistryFromGURL(
464 g_browser_process->rappor_service(),
465 "ContentSettings.Plugins.AddedAllowException", site_url_);
466 }
sashab9debecd2014-12-18 04:15:56467 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
dchengf6f4e4942017-03-30 23:55:57468 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56469 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07470 num_values);
sashab9debecd2014-12-18 04:15:56471 }
[email protected]e22d64f2012-09-10 09:03:23472
lgarron04a93502014-11-04 22:25:04473 // This is technically redundant given the histogram above, but putting the
474 // total count of permission changes in another histogram makes it easier to
lgarron026e9c42017-04-07 20:09:31475 // compare it against other kinds of actions in Page Info.
lgarron617a30f32017-03-24 21:42:07476 RecordPageInfoAction(PAGE_INFO_CHANGED_PERMISSION);
Tommy Steimeldea90f72017-11-07 20:58:03477 if (type == CONTENT_SETTINGS_TYPE_SOUND) {
478 ContentSetting default_setting =
479 content_settings_->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_SOUND,
480 nullptr);
481 bool mute = (setting == CONTENT_SETTING_BLOCK) ||
482 (setting == CONTENT_SETTING_DEFAULT &&
483 default_setting == CONTENT_SETTING_BLOCK);
484 if (mute) {
485 base::RecordAction(
486 base::UserMetricsAction("SoundContentSetting.MuteBy.PageInfo"));
487 } else {
488 base::RecordAction(
489 base::UserMetricsAction("SoundContentSetting.UnmuteBy.PageInfo"));
490 }
491 }
lgarron04a93502014-11-04 22:25:04492
stefanocs8b3490cc2016-07-28 05:32:52493 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
patricialor7131c1fe2017-04-07 01:25:52494 profile_, site_url_, site_url_, type, PermissionSourceUI::OIB);
stefanocs8b3490cc2016-07-28 05:32:52495
patricialor7131c1fe2017-04-07 01:25:52496 // The permission may have been blocked due to being under embargo, so if it
497 // was changed away from BLOCK, clear embargo status if it exists.
498 if (setting != CONTENT_SETTING_BLOCK) {
499 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveEmbargoByUrl(
500 site_url_, type);
501 }
raymesfbaaaaa2015-11-10 02:20:40502 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
503 setting);
[email protected]df818272012-04-20 13:10:50504
Tommy Steimel97ee2f82017-11-01 21:39:52505 // When the sound setting is changed, no reload is necessary.
506 if (type != CONTENT_SETTINGS_TYPE_SOUND)
507 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24508
509 // Refresh the UI to reflect the new setting.
510 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50511}
512
lgarron617a30f32017-03-24 21:42:07513void PageInfo::OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info,
514 const base::DictionaryValue& object) {
reillyg85f57db2016-01-12 23:14:38515 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
516 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10517 const GURL origin = site_url_.GetOrigin();
518 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38519 show_info_bar_ = true;
520
521 // Refresh the UI to reflect the changed settings.
522 PresentSitePermissions();
523}
524
lgarron617a30f32017-03-24 21:42:07525void PageInfo::OnSiteDataAccessed() {
[email protected]df818272012-04-20 13:10:50526 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33527}
528
lgarron617a30f32017-03-24 21:42:07529void PageInfo::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49530#if defined(OS_ANDROID)
531 NOTREACHED();
532#else
dominicknbdd53b5f2016-09-28 01:08:13533 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
palmerf2cba0d2015-08-27 23:15:06534 InfoBarService* infobar_service =
dominicknbdd53b5f2016-09-28 01:08:13535 InfoBarService::FromWebContents(web_contents());
palmerf2cba0d2015-08-27 23:15:06536 if (infobar_service)
lgarron617a30f32017-03-24 21:42:07537 PageInfoInfoBarDelegate::Create(infobar_service);
palmerf2cba0d2015-08-27 23:15:06538 }
estade3feb83f2015-09-01 23:00:49539#endif
jww1ed8ea72014-09-02 20:43:25540}
541
lgarron617a30f32017-03-24 21:42:07542void PageInfo::OnRevokeSSLErrorBypassButtonPressed() {
jww1ed8ea72014-09-02 20:43:25543 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29544 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
545 site_url().host());
jww1ed8ea72014-09-02 20:43:25546 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26547}
548
Patricia Lora21a04cf2017-06-05 02:53:29549void PageInfo::OpenSiteSettingsView() {
Christopher Lam0dbac2b2017-11-14 07:12:10550#if defined(OS_ANDROID)
551 NOTREACHED();
552#else
553 chrome::ShowSiteSettings(chrome::FindBrowserWithWebContents(web_contents()),
554 site_url());
Patricia Lora21a04cf2017-06-05 02:53:29555 RecordPageInfoAction(PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED);
Christopher Lam0dbac2b2017-11-14 07:12:10556#endif
Patricia Lora21a04cf2017-06-05 02:53:29557}
558
Jialiu Lin11e18542017-08-14 18:16:26559void PageInfo::OnChangePasswordButtonPressed(
560 content::WebContents* web_contents) {
Jialiu Linfeb6bb32017-08-30 00:21:36561#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26562 DCHECK(password_protection_service_);
Jialiu Lind7defe652018-06-20 18:47:06563 DCHECK(site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE ||
564 site_identity_status_ ==
565 SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE);
Jialiu Lin3fc7f38f2017-09-21 18:38:37566 password_protection_service_->OnUserAction(
Jialiu Lind7defe652018-06-20 18:47:06567 web_contents,
568 site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE
569 ? PasswordReuseEvent::SIGN_IN_PASSWORD
570 : PasswordReuseEvent::ENTERPRISE_PASSWORD,
Jialiu Lina97fe522018-07-26 16:47:26571 safe_browsing::WarningUIType::PAGE_INFO,
572 safe_browsing::WarningAction::CHANGE_PASSWORD);
Jialiu Lin11e18542017-08-14 18:16:26573#endif
574}
575
576void PageInfo::OnWhitelistPasswordReuseButtonPressed(
577 content::WebContents* web_contents) {
Jialiu Linfeb6bb32017-08-30 00:21:36578#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26579 DCHECK(password_protection_service_);
Jialiu Lind7defe652018-06-20 18:47:06580 DCHECK(site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE ||
581 site_identity_status_ ==
582 SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE);
Jialiu Lin3fc7f38f2017-09-21 18:38:37583 password_protection_service_->OnUserAction(
Jialiu Lind7defe652018-06-20 18:47:06584 web_contents,
585 site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE
586 ? PasswordReuseEvent::SIGN_IN_PASSWORD
587 : PasswordReuseEvent::ENTERPRISE_PASSWORD,
Jialiu Lina97fe522018-07-26 16:47:26588 safe_browsing::WarningUIType::PAGE_INFO,
589 safe_browsing::WarningAction::MARK_AS_LEGITIMATE);
Jialiu Lin11e18542017-08-14 18:16:26590#endif
591}
592
lgarron617a30f32017-03-24 21:42:07593void PageInfo::Init(const GURL& url,
594 const security_state::SecurityInfo& security_info) {
thestig0c55ee32017-06-20 22:17:51595#if !defined(OS_ANDROID)
meacerde53fcff2016-10-12 19:21:57596 // On desktop, internal URLs aren't handled by this class. Instead, a
lgarron026e9c42017-04-07 20:09:31597 // custom and simpler bubble is shown.
meacerde53fcff2016-10-12 19:21:57598 DCHECK(!url.SchemeIs(content::kChromeUIScheme) &&
599 !url.SchemeIs(content::kChromeDevToolsScheme) &&
600 !url.SchemeIs(content::kViewSourceScheme) &&
601 !url.SchemeIs(content_settings::kExtensionScheme));
602#endif
603
thestig0c55ee32017-06-20 22:17:51604 bool is_chrome_ui_native_scheme = false;
zpengdb4a58e2017-01-10 17:40:32605#if defined(OS_ANDROID)
thestig0c55ee32017-06-20 22:17:51606 is_chrome_ui_native_scheme = url.SchemeIs(chrome::kChromeUINativeScheme);
sashab97894ce2014-10-22 10:08:33607#endif
608
estark8d67cd7a2016-10-24 05:06:41609 security_level_ = security_info.security_level;
610
upendrag.gowda60886a6e2015-10-31 05:51:09611 if (url.SchemeIs(url::kAboutScheme)) {
612 // All about: URLs except about:blank are redirected.
613 DCHECK_EQ(url::kAboutBlankURL, url.spec());
614 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
615 site_identity_details_ =
616 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
617 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
618 site_connection_details_ = l10n_util::GetStringFUTF16(
619 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
620 UTF8ToUTF16(url.spec()));
621 return;
622 }
623
thestig0c55ee32017-06-20 22:17:51624 if (url.SchemeIs(content::kChromeUIScheme) || is_chrome_ui_native_scheme) {
[email protected]03ef4b2a2012-03-06 15:04:20625 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
626 site_identity_details_ =
627 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
628 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
629 return;
630 }
631
[email protected]03ef4b2a2012-03-06 15:04:20632 // Identity section.
jam8ae7cad2016-09-08 23:55:21633 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11634
estarkfcfccdb82016-11-14 02:17:29635 if (security_info.malicious_content_status !=
esecklercac56b62016-11-16 13:49:44636 security_state::MALICIOUS_CONTENT_STATUS_NONE) {
estarkfcfccdb82016-11-14 02:17:29637 // The site has been flagged by Safe Browsing as dangerous.
638 GetSiteIdentityByMaliciousContentStatus(
639 security_info.malicious_content_status, &site_identity_status_,
640 &site_identity_details_);
Jialiu Lin11e18542017-08-14 18:16:26641 show_change_password_buttons_ =
Jialiu Lind7defe652018-06-20 18:47:06642 (security_info.malicious_content_status ==
643 security_state::MALICIOUS_CONTENT_STATUS_SIGN_IN_PASSWORD_REUSE ||
644 security_info.malicious_content_status ==
645 security_state::
646 MALICIOUS_CONTENT_STATUS_ENTERPRISE_PASSWORD_REUSE);
estarkfcfccdb82016-11-14 02:17:29647 } else if (certificate_ &&
648 (!net::IsCertStatusError(security_info.cert_status) ||
649 net::IsCertStatusMinorError(security_info.cert_status))) {
650 // HTTPS with no or minor errors.
estarka3121f6b2015-09-18 21:15:59651 if (security_info.security_level ==
esecklercac56b62016-11-16 13:49:44652 security_state::SECURE_WITH_POLICY_INSTALLED_CERT) {
Eric Lawrence6758d1d2017-11-21 16:06:05653#if defined(OS_CHROMEOS)
[email protected]eaf3f322013-04-25 21:53:59654 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37655 site_identity_details_ = l10n_util::GetStringFUTF16(
656 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
Eric Lawrence6758d1d2017-11-21 16:06:05657#else
658 DCHECK(false) << "Policy certificates exist only on ChromeOS";
659#endif
estarka3121f6b2015-09-18 21:15:59660 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20661 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21662 base::string16 issuer_name(
663 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20664 if (issuer_name.empty()) {
665 issuer_name.assign(l10n_util::GetStringUTF16(
666 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
667 }
[email protected]94c74b42013-12-02 15:19:49668
[email protected]03ef4b2a2012-03-06 15:04:20669 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39670 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20671
672 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59673 if (security_info.cert_status &
674 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20675 site_identity_details_ += l10n_util::GetStringUTF16(
676 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59677 } else if (security_info.cert_status &
678 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20679 site_identity_details_ += l10n_util::GetStringUTF16(
680 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
681 } else {
682 NOTREACHED() << "Need to specify string for this warning";
683 }
[email protected]03ef4b2a2012-03-06 15:04:20684 } else {
estarkcf305562016-11-15 03:45:39685 // No major or minor errors.
estarka3121f6b2015-09-18 21:15:59686 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01687 // EV HTTPS page.
estarkcf305562016-11-15 03:45:39688 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
jam8ae7cad2016-09-08 23:55:21689 DCHECK(!certificate_->subject().organization_names.empty());
690 organization_name_ =
691 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01692 // An EV Cert is required to have a city (localityName) and country but
693 // state is "if any".
jam8ae7cad2016-09-08 23:55:21694 DCHECK(!certificate_->subject().locality_name.empty());
695 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01696 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21697 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01698 locality = l10n_util::GetStringFUTF16(
lgarronfc1d5e52017-05-03 23:15:21699 IDS_PAGE_INFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21700 UTF8ToUTF16(certificate_->subject().locality_name),
701 UTF8ToUTF16(certificate_->subject().state_or_province_name),
702 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01703 } else {
704 locality = l10n_util::GetStringFUTF16(
lgarronfc1d5e52017-05-03 23:15:21705 IDS_PAGE_INFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21706 UTF8ToUTF16(certificate_->subject().locality_name),
707 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01708 }
jam8ae7cad2016-09-08 23:55:21709 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01710 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39711 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED,
jam8ae7cad2016-09-08 23:55:21712 UTF8ToUTF16(certificate_->subject().organization_names[0]),
estarkcf305562016-11-15 03:45:39713 locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01714 } else {
715 // Non-EV OK HTTPS page.
estarkcf305562016-11-15 03:45:39716 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
rsleevi4f8012722014-09-30 01:28:01717 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21718 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01719 if (issuer_name.empty()) {
720 issuer_name.assign(l10n_util::GetStringUTF16(
721 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
722 }
[email protected]94c74b42013-12-02 15:19:49723
rsleevi4f8012722014-09-30 01:28:01724 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39725 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
rsleevi4f8012722014-09-30 01:28:01726 }
elawrencebe87bd62017-01-10 16:08:59727 if (security_info.sha1_in_chain) {
728 site_identity_status_ =
729 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM;
730 site_identity_details_ +=
731 UTF8ToUTF16("\n\n") +
732 l10n_util::GetStringUTF16(
733 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM);
rsleevi4f8012722014-09-30 01:28:01734 }
[email protected]03ef4b2a2012-03-06 15:04:20735 }
736 } else {
737 // HTTP or HTTPS with errors (not warnings).
738 site_identity_details_.assign(l10n_util::GetStringUTF16(
739 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
jam8ae7cad2016-09-08 23:55:21740 if (!security_info.scheme_is_cryptographic || !security_info.certificate)
[email protected]03ef4b2a2012-03-06 15:04:20741 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
742 else
743 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
744
[email protected]a04db822013-12-11 19:14:40745 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59746 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59747 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
jam8ae7cad2016-09-08 23:55:21748 certificate_, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20749 for (size_t i = 0; i < errors.size(); ++i) {
750 site_identity_details_ += bullet;
751 site_identity_details_ += errors[i].short_description();
752 }
753
estarka3121f6b2015-09-18 21:15:59754 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20755 site_identity_details_ += ASCIIToUTF16("\n\n");
lgarron1a6300d2017-03-18 03:33:04756 site_identity_details_ +=
757 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
[email protected]03ef4b2a2012-03-06 15:04:20758 }
759 }
760
761 // Site Connection
762 // We consider anything less than 80 bits encryption to be weak encryption.
763 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
764 // weakly encrypted connections.
765 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
766
jshin1fb76462016-04-05 22:13:03767 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19768 if (subject_name.empty()) {
769 subject_name.assign(
770 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
771 }
772
jam8ae7cad2016-09-08 23:55:21773 if (!security_info.certificate || !security_info.scheme_is_cryptographic) {
estarka3121f6b2015-09-18 21:15:59774 // Page is still loading (so SSL status is not yet available) or
775 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58776 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
777
778 site_connection_details_.assign(l10n_util::GetStringFUTF16(
779 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
780 subject_name));
Daniel McArdle2bd4fd82018-11-28 20:58:08781 } else if (!security_info.connection_info_initialized) {
esecklercac56b62016-11-16 13:49:44782 DCHECK_NE(security_info.security_level, security_state::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20783 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
[email protected]03ef4b2a2012-03-06 15:04:20784 } else {
785 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22786
lgarron3e2c33e2016-08-25 06:33:43787 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22788 site_connection_details_.assign(l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04789 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, subject_name));
Adam Langley71c2b59b2014-11-13 00:34:22790 } else {
791 site_connection_details_.assign(l10n_util::GetStringFUTF16(
792 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
793 subject_name));
794 }
795
thestig4427f13b2017-06-20 20:42:47796 ReportAnyInsecureContent(security_info, &site_connection_status_,
797 &site_connection_details_);
[email protected]03ef4b2a2012-03-06 15:04:20798 }
799
avi655876a2015-12-25 07:18:15800 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59801 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
Daniel McArdle2bd4fd82018-11-28 20:58:08802 if (security_info.connection_info_initialized && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20803 int ssl_version =
estarka3121f6b2015-09-18 21:15:59804 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20805 const char* ssl_version_str;
806 net::SSLVersionToString(&ssl_version_str, ssl_version);
807 site_connection_details_ += ASCIIToUTF16("\n\n");
808 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04809 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, ASCIIToUTF16(ssl_version_str));
[email protected]03ef4b2a2012-03-06 15:04:20810
[email protected]03ef4b2a2012-03-06 15:04:20811 const char *key_exchange, *cipher, *mac;
davidben56a8aece2016-10-14 18:20:56812 bool is_aead, is_tls13;
813 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
814 &is_tls13, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20815
816 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57817 if (is_aead) {
davidben56a8aece2016-10-14 18:20:56818 if (is_tls13) {
819 // For TLS 1.3 ciphers, report the group (historically, curve) as the
820 // key exchange.
821 key_exchange = SSL_get_curve_name(security_info.key_exchange_group);
822 if (!key_exchange) {
823 NOTREACHED();
824 key_exchange = "";
825 }
826 }
[email protected]b6c1d9e82013-06-12 17:26:57827 site_connection_details_ += l10n_util::GetStringFUTF16(
828 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
829 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
830 } else {
831 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04832 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, ASCIIToUTF16(cipher),
833 ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
[email protected]b6c1d9e82013-06-12 17:26:57834 }
[email protected]03ef4b2a2012-03-06 15:04:20835 }
[email protected]e583f752012-08-30 13:26:21836
[email protected]71cd5ef2014-08-13 21:22:04837 // Check if a user decision has been made to allow or deny certificates with
838 // errors on this site.
839 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50840 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04841 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40842 // Only show an SSL decision revoke button if the user has chosen to bypass
843 // SSL host errors for this host in the past.
844 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]03ef4b2a2012-03-06 15:04:20845}
[email protected]0b9fdd72012-04-04 10:00:33846
lgarron617a30f32017-03-24 21:42:07847void PageInfo::PresentSitePermissions() {
[email protected]df818272012-04-20 13:10:50848 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38849 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50850
lgarron617a30f32017-03-24 21:42:07851 PageInfoUI::PermissionInfo permission_info;
Avi Drissman22f82872018-12-25 23:09:07852 for (size_t i = 0; i < base::size(kPermissionType); ++i) {
[email protected]df818272012-04-20 13:10:50853 permission_info.type = kPermissionType[i];
854
855 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32856 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
857 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21858 DCHECK(value.get());
jdoerrie76cee9c2017-10-06 22:42:42859 if (value->type() == base::Value::Type::INTEGER) {
sashab2b2a314f2015-01-17 06:42:21860 permission_info.setting =
861 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26862 } else {
sashab2b2a314f2015-01-17 06:42:21863 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26864 }
865
[email protected]8bdf45c32012-08-04 00:12:55866 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28867 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50868
[email protected]b1d113d2012-06-27 21:27:34869 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21870 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34871 permission_info.default_setting = permission_info.setting;
872 permission_info.setting = CONTENT_SETTING_DEFAULT;
873 } else {
874 permission_info.default_setting =
875 content_settings_->GetDefaultContentSetting(permission_info.type,
876 NULL);
[email protected]df818272012-04-20 13:10:50877 }
palmer0da10b32015-02-11 00:42:19878
patricialor2a4f41a2017-03-08 02:52:56879 // For permissions that are still prompting the user and haven't been
880 // explicitly set by another source, check its embargo status.
881 if (PermissionUtil::IsPermission(permission_info.type) &&
882 permission_info.setting == CONTENT_SETTING_DEFAULT &&
883 permission_info.source ==
884 content_settings::SettingSource::SETTING_SOURCE_USER) {
885 // TODO(raymes): Use GetPermissionStatus() to retrieve information
886 // about *all* permissions once it has default behaviour implemented for
887 // ContentSettingTypes that aren't permissions.
888 PermissionResult permission_result =
889 PermissionManager::Get(profile_)->GetPermissionStatus(
890 permission_info.type, site_url_, site_url_);
891
892 // If under embargo, update |permission_info| to reflect that.
893 if (permission_result.content_setting == CONTENT_SETTING_BLOCK &&
Timothy Loh8fbdac52018-03-15 03:34:30894 permission_result.source ==
895 PermissionStatusSource::MULTIPLE_DISMISSALS) {
patricialor2a4f41a2017-03-08 02:52:56896 permission_info.setting = permission_result.content_setting;
Timothy Loh8fbdac52018-03-15 03:34:30897 }
patricialor2a4f41a2017-03-08 02:52:56898 }
899
Tommy Steimelc9f6c932017-10-13 23:33:04900 if (ShouldShowPermission(permission_info, site_url_, content_settings_,
shahriar rostamia9c769d2017-12-06 04:54:08901 web_contents(), tab_specific_content_settings())) {
Patti0601e532017-09-20 08:39:30902 permission_info_list.push_back(permission_info);
Tommy Steimelc9f6c932017-10-13 23:33:04903 }
[email protected]df818272012-04-20 13:10:50904 }
905
reillyg85f57db2016-01-12 23:14:38906 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
907 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10908 const GURL origin = site_url_.GetOrigin();
Reilly Granta69ab672018-04-06 18:26:07909
910 // Hide individual object permissions because when the chooser is blocked
911 // previously granted device permissions are also ignored.
912 if (!context->CanRequestObjectPermission(origin, origin))
913 continue;
914
reillyg36a7fab32016-01-28 19:15:10915 auto chosen_objects = context->GetGrantedObjects(origin, origin);
Ovidio Henriquez0e7c32a2019-01-16 03:15:29916 for (std::unique_ptr<ChooserContextBase::Object>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38917 chosen_object_info_list.push_back(
Jinho Bangcc280792018-01-17 23:33:55918 std::make_unique<PageInfoUI::ChosenObjectInfo>(ui_info,
lgarron617a30f32017-03-24 21:42:07919 std::move(object)));
reillyg85f57db2016-01-12 23:14:38920 }
921 }
922
avi09dd4d02016-10-14 20:40:09923 ui_->SetPermissionInfo(permission_info_list,
924 std::move(chosen_object_info_list));
[email protected]0b9fdd72012-04-04 10:00:33925}
926
lgarron617a30f32017-03-24 21:42:07927void PageInfo::PresentSiteData() {
[email protected]df818272012-04-20 13:10:50928 CookieInfoList cookie_info_list;
vabrbab3ffcb2016-10-04 10:08:10929 const LocalSharedObjectsContainer& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34930 tab_specific_content_settings()->allowed_local_shared_objects();
vabrbab3ffcb2016-10-04 10:08:10931 const LocalSharedObjectsContainer& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34932 tab_specific_content_settings()->blocked_local_shared_objects();
933
934 // Add first party cookie and site data counts.
lgarron617a30f32017-03-24 21:42:07935 PageInfoUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34936 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
937 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15938 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34939 cookie_info_list.push_back(cookie_info);
940
941 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34942 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
943 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15944 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50945 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33946
[email protected]df818272012-04-20 13:10:50947 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33948}
[email protected]16de6de2012-04-04 12:24:14949
lgarron617a30f32017-03-24 21:42:07950void PageInfo::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04951 // After initialization the status about the site's connection and its
952 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41953 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
954 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
lgarron617a30f32017-03-24 21:42:07955 PageInfoUI::IdentityInfo info;
[email protected]24c8818c2012-04-25 09:57:41956 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
957 info.site_identity = UTF16ToUTF8(organization_name());
958 else
jshin1fb76462016-04-05 22:13:03959 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41960
961 info.connection_status = site_connection_status_;
lgarron1a6300d2017-03-18 03:33:04962 info.connection_status_description = UTF16ToUTF8(site_connection_details_);
[email protected]24c8818c2012-04-25 09:57:41963 info.identity_status = site_identity_status_;
lgarron1a6300d2017-03-18 03:33:04964 info.identity_status_description = UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21965 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04966 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
Jialiu Lin11e18542017-08-14 18:16:26967 info.show_change_password_buttons = show_change_password_buttons_;
[email protected]24c8818c2012-04-25 09:57:41968 ui_->SetIdentityInfo(info);
Jialiu Linfeb6bb32017-08-30 00:21:36969#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26970 if (password_protection_service_ && show_change_password_buttons_) {
Jialiu Lind7defe652018-06-20 18:47:06971 if (site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE) {
Jialiu Lina97fe522018-07-26 16:47:26972 safe_browsing::LogWarningAction(
973 safe_browsing::WarningUIType::PAGE_INFO,
974 safe_browsing::WarningAction::SHOWN,
Jialiu Lind7defe652018-06-20 18:47:06975 safe_browsing::LoginReputationClientRequest::PasswordReuseEvent::
Jialiu Lina97fe522018-07-26 16:47:26976 SIGN_IN_PASSWORD,
977 password_protection_service_->GetSyncAccountType());
Jialiu Lind7defe652018-06-20 18:47:06978 } else {
Jialiu Lina97fe522018-07-26 16:47:26979 safe_browsing::LogWarningAction(
980 safe_browsing::WarningUIType::PAGE_INFO,
981 safe_browsing::WarningAction::SHOWN,
Jialiu Lind7defe652018-06-20 18:47:06982 safe_browsing::LoginReputationClientRequest::PasswordReuseEvent::
Jialiu Lina97fe522018-07-26 16:47:26983 ENTERPRISE_PASSWORD,
984 password_protection_service_->GetSyncAccountType());
Jialiu Lind7defe652018-06-20 18:47:06985 }
Jialiu Lin11e18542017-08-14 18:16:26986 }
987#endif
[email protected]24c8818c2012-04-25 09:57:41988}
Patti7f21c4b2017-11-28 03:37:17989
Suman Kancherlad54a6e5b2019-01-29 22:17:49990void PageInfo::PresentPageFeatureInfo() {
991 PageInfoUI::PageFeatureInfo info;
992 info.is_vr_presentation_in_headset =
993 vr::VrTabHelper::IsContentDisplayedInHeadset(web_contents());
994
995 ui_->SetPageFeatureInfo(info);
996}
997
Patti7f21c4b2017-11-28 03:37:17998std::vector<ContentSettingsType> PageInfo::GetAllPermissionsForTesting() {
999 std::vector<ContentSettingsType> permission_list;
Avi Drissman22f82872018-12-25 23:09:071000 for (size_t i = 0; i < base::size(kPermissionType); ++i) {
Patti7f21c4b2017-11-28 03:37:171001#if !defined(OS_ANDROID)
1002 if (kPermissionType[i] == CONTENT_SETTINGS_TYPE_AUTOPLAY)
1003 continue;
1004#endif
1005 permission_list.push_back(kPermissionType[i]);
1006 }
1007 return permission_list;
1008}
Jialiu Lin4d7c6042018-04-04 17:45:351009
1010void PageInfo::GetSiteIdentityByMaliciousContentStatus(
1011 security_state::MaliciousContentStatus malicious_content_status,
1012 PageInfo::SiteIdentityStatus* status,
1013 base::string16* details) {
1014 switch (malicious_content_status) {
1015 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
1016 NOTREACHED();
1017 break;
1018 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
1019 *status = PageInfo::SITE_IDENTITY_STATUS_MALWARE;
1020 *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MALWARE_DETAILS);
1021 break;
1022 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
1023 *status = PageInfo::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
1024 *details =
1025 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SOCIAL_ENGINEERING_DETAILS);
1026 break;
1027 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
1028 *status = PageInfo::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
1029 *details =
1030 l10n_util::GetStringUTF16(IDS_PAGE_INFO_UNWANTED_SOFTWARE_DETAILS);
1031 break;
Jialiu Lind7defe652018-06-20 18:47:061032 case security_state::MALICIOUS_CONTENT_STATUS_SIGN_IN_PASSWORD_REUSE:
Jialiu Lin4d7c6042018-04-04 17:45:351033#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lind7defe652018-06-20 18:47:061034 *status = PageInfo::SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE;
1035 // |password_protection_service_| may be null in test.
1036 *details = password_protection_service_
1037 ? password_protection_service_->GetWarningDetailText(
1038 PasswordReuseEvent::SIGN_IN_PASSWORD)
1039 : base::string16();
1040#endif
1041 break;
1042 case security_state::MALICIOUS_CONTENT_STATUS_ENTERPRISE_PASSWORD_REUSE:
1043#if defined(SAFE_BROWSING_DB_LOCAL)
1044 *status = PageInfo::SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE;
1045 // |password_protection_service_| maybe null in test.
1046 *details = password_protection_service_
1047 ? password_protection_service_->GetWarningDetailText(
1048 PasswordReuseEvent::ENTERPRISE_PASSWORD)
1049 : base::string16();
Jialiu Lin4d7c6042018-04-04 17:45:351050#endif
1051 break;
spqchan6da308a2018-08-10 19:19:531052 case security_state::MALICIOUS_CONTENT_STATUS_BILLING:
spqchan6da308a2018-08-10 19:19:531053 *status = PageInfo::SITE_IDENTITY_STATUS_BILLING;
1054 *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_BILLING_DETAILS);
spqchan6da308a2018-08-10 19:19:531055 break;
Jialiu Lin4d7c6042018-04-04 17:45:351056 }
1057}