blob: 75bb90ad3003cd6ed47aa4c36b4aad7de86b2e26 [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"
jialiul02aad2d2015-04-01 18:56:0325#include "chrome/browser/browser_process.h"
[email protected]b0cb5e82012-07-19 19:22:4726#include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
27#include "chrome/browser/browsing_data/browsing_data_database_helper.h"
28#include "chrome/browser/browsing_data/browsing_data_file_system_helper.h"
29#include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
30#include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
peconn5100d432015-09-16 12:03:0831#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
vabrbab3ffcb2016-10-04 10:08:1032#include "chrome/browser/content_settings/local_shared_objects_container.h"
[email protected]77a91c72012-08-13 16:19:3433#include "chrome/browser/history/history_service_factory.h"
palmerf2cba0d2015-08-27 23:15:0634#include "chrome/browser/infobars/infobar_service.h"
reillyg85f57db2016-01-12 23:14:3835#include "chrome/browser/permissions/chooser_context_base.h"
patricialor7131c1fe2017-04-07 01:25:5236#include "chrome/browser/permissions/permission_decision_auto_blocker.h"
patricialor2a4f41a2017-03-08 02:52:5637#include "chrome/browser/permissions/permission_manager.h"
38#include "chrome/browser/permissions/permission_result.h"
tsergeantf1e89352016-01-15 20:34:5439#include "chrome/browser/permissions/permission_uma_util.h"
40#include "chrome/browser/permissions/permission_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2041#include "chrome/browser/profiles/profile.h"
Jialiu Lin11e18542017-08-14 18:16:2642#include "chrome/browser/safe_browsing/safe_browsing_service.h"
[email protected]71cd5ef2014-08-13 21:22:0443#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
44#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
lgarron617a30f32017-03-24 21:42:0745#include "chrome/browser/ui/page_info/page_info_ui.h"
reillyg85f57db2016-01-12 23:14:3846#include "chrome/browser/usb/usb_chooser_context.h"
47#include "chrome/browser/usb/usb_chooser_context_factory.h"
Patricia Lora21a04cf2017-06-05 02:53:2948#include "chrome/common/chrome_features.h"
[email protected]71cd5ef2014-08-13 21:22:0449#include "chrome/common/chrome_switches.h"
jsbellddb849e2015-08-27 00:12:5650#include "chrome/common/url_constants.h"
reillyg85f57db2016-01-12 23:14:3851#include "chrome/grit/theme_resources.h"
Patti0601e532017-09-20 08:39:3052#include "components/content_settings/core/browser/content_settings_registry.h"
mukai8eaec822014-10-25 17:53:1653#include "components/content_settings/core/browser/content_settings_utils.h"
54#include "components/content_settings/core/browser/host_content_settings_map.h"
palmer0da10b32015-02-11 00:42:1955#include "components/content_settings/core/common/content_settings.h"
vasiliif62dbf92014-09-05 10:23:1356#include "components/content_settings/core/common/content_settings_pattern.h"
tbansal08a0e3e2017-06-30 21:30:0857#include "components/content_settings/core/common/content_settings_utils.h"
nzolghadrd87a308d2016-12-07 15:45:5658#include "components/rappor/public/rappor_utils.h"
59#include "components/rappor/rappor_service_impl.h"
felt2493b4452015-09-17 20:33:5960#include "components/ssl_errors/error_info.h"
thestig4a2e88e2016-08-27 23:23:5161#include "components/strings/grit/components_chromium_strings.h"
62#include "components/strings/grit/components_strings.h"
melandory7be36d312017-03-29 15:51:1263#include "components/subresource_filter/core/browser/subresource_filter_features.h"
palmer153af982015-09-15 02:04:1964#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3365#include "content/public/browser/browser_thread.h"
[email protected]eb2140c2013-07-29 12:37:3466#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2067#include "content/public/common/url_constants.h"
[email protected]6e7845ae2013-03-29 21:48:1168#include "net/cert/cert_status_flags.h"
69#include "net/cert/x509_certificate.h"
[email protected]536fd0b2013-03-14 17:41:5770#include "net/ssl/ssl_cipher_suite_names.h"
71#include "net/ssl/ssl_connection_status_flags.h"
tfarina29a3a1742016-10-28 18:47:3372#include "third_party/boringssl/src/include/openssl/ssl.h"
[email protected]03ef4b2a2012-03-06 15:04:2073#include "ui/base/l10n/l10n_util.h"
Patricia Lora21a04cf2017-06-05 02:53:2974#include "url/origin.h"
[email protected]03ef4b2a2012-03-06 15:04:2075
[email protected]24a9f1c92013-11-13 12:33:3776#if defined(OS_CHROMEOS)
77#include "chrome/browser/chromeos/policy/policy_cert_service.h"
78#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
79#endif
80
estade3feb83f2015-09-01 23:00:4981#if !defined(OS_ANDROID)
Christopher Lam0dbac2b2017-11-14 07:12:1082#include "chrome/browser/ui/browser_finder.h"
83#include "chrome/browser/ui/chrome_pages.h"
mgiucaa319f212016-01-14 03:30:1184#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
lgarron617a30f32017-03-24 21:42:0785#include "chrome/browser/ui/page_info/page_info_infobar_delegate.h"
estade3feb83f2015-09-01 23:00:4986#endif
87
Jialiu Lin11e18542017-08-14 18:16:2688#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin0d8cc722017-09-19 01:01:5189#include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
Jialiu Lin11e18542017-08-14 18:16:2690#endif
91
[email protected]ab6df3b12013-12-24 23:32:2692using base::ASCIIToUTF16;
93using base::UTF8ToUTF16;
[email protected]f729d7a2013-12-26 07:07:5694using base::UTF16ToUTF8;
[email protected]0b9fdd72012-04-04 10:00:3395using content::BrowserThread;
Jialiu Lind7defe652018-06-20 18:47:0696#if defined(SAFE_BROWSING_DB_LOCAL)
97using PasswordReuseEvent =
98 safe_browsing::LoginReputationClientRequest::PasswordReuseEvent;
99#endif // SAFE_BROWSING_DB_LOCAL
[email protected]0b9fdd72012-04-04 10:00:33100
101namespace {
102
lgarron617a30f32017-03-24 21:42:07103// The list of content settings types to display on the Page Info UI. THE
csharrisonad1eaa6c2017-05-11 17:14:38104// ORDER OF THESE ITEMS IS IMPORTANT and comes from https://crbug.com/610358. To
105// propose changing it, email [email protected].
[email protected]0b9fdd72012-04-04 10:00:33106ContentSettingsType kPermissionType[] = {
sashab2b2a314f2015-01-17 06:42:21107 CONTENT_SETTINGS_TYPE_GEOLOCATION,
sashab2b2a314f2015-01-17 06:42:21108 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
109 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
Alexander Shalamovce5aab52018-02-07 11:45:15110 CONTENT_SETTINGS_TYPE_SENSORS,
palmer0da10b32015-02-11 00:42:19111 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
palmer7715e332016-05-27 00:41:19112 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
lshange085f202016-06-14 01:25:08113#if !defined(OS_ANDROID)
palmer7715e332016-05-27 00:41:19114 CONTENT_SETTINGS_TYPE_PLUGINS,
115 CONTENT_SETTINGS_TYPE_IMAGES,
lshange085f202016-06-14 01:25:08116#endif
palmer7715e332016-05-27 00:41:19117 CONTENT_SETTINGS_TYPE_POPUPS,
Charles Harrison239d47982017-06-13 02:42:31118 CONTENT_SETTINGS_TYPE_ADS,
nsatragno670fe922016-04-08 14:10:50119 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
Tommy Steimela8c3757e2017-08-24 00:15:46120 CONTENT_SETTINGS_TYPE_SOUND,
palmer7715e332016-05-27 00:41:19121 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
finnur46cafd42016-09-22 10:27:17122 CONTENT_SETTINGS_TYPE_AUTOPLAY,
palmer7715e332016-05-27 00:41:19123 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
Gary Kacmarcik10533cf2017-11-22 03:31:28124 CONTENT_SETTINGS_TYPE_CLIPBOARD_READ,
Reilly Granta69ab672018-04-06 18:26:07125 CONTENT_SETTINGS_TYPE_USB_GUARD,
[email protected]0b9fdd72012-04-04 10:00:33126};
127
Patti0601e532017-09-20 08:39:30128// Checks whether this permission is currently the factory default, as set by
129// Chrome. Specifically, that the following three conditions are true:
130// - The current active setting comes from the default or pref provider.
131// - The setting is the factory default setting (as opposed to a global
132// default setting set by the user).
133// - The setting is a wildcard setting applying to all origins (which can only
134// be set from the default provider).
135bool IsPermissionFactoryDefault(HostContentSettingsMap* content_settings,
136 const PageInfoUI::PermissionInfo& info) {
137 const ContentSetting factory_default_setting =
138 content_settings::ContentSettingsRegistry::GetInstance()
139 ->Get(info.type)
140 ->GetInitialDefaultSetting();
141 return (info.source == content_settings::SETTING_SOURCE_USER &&
142 factory_default_setting == info.default_setting &&
143 info.setting == CONTENT_SETTING_DEFAULT);
144}
145
lgarron617a30f32017-03-24 21:42:07146// Determines whether to show permission |type| in the Page Info UI. Only
mgiucaa319f212016-01-14 03:30:11147// applies to permissions listed in |kPermissionType|.
shahriar rostamia9c769d2017-12-06 04:54:08148bool ShouldShowPermission(
149 const PageInfoUI::PermissionInfo& info,
150 const GURL& site_url,
151 HostContentSettingsMap* content_settings,
152 content::WebContents* web_contents,
153 TabSpecificContentSettings* tab_specific_content_settings) {
Patti0601e532017-09-20 08:39:30154 // Note |CONTENT_SETTINGS_TYPE_ADS| will show up regardless of its default
155 // value when it has been activated on the current origin.
156 if (info.type == CONTENT_SETTINGS_TYPE_ADS) {
csharrisonad1eaa6c2017-05-11 17:14:38157 if (!base::FeatureList::IsEnabled(
Charlie Harrisonb73f7622018-06-01 14:24:34158 subresource_filter::kSafeBrowsingSubresourceFilter)) {
csharrisonad1eaa6c2017-05-11 17:14:38159 return false;
160 }
161
162 // The setting for subresource filtering should not show up if the site is
163 // not activated, both on android and desktop platforms.
164 return content_settings->GetWebsiteSetting(
Charles Harrison239d47982017-06-13 02:42:31165 site_url, GURL(), CONTENT_SETTINGS_TYPE_ADS_DATA, std::string(),
166 nullptr) != nullptr;
melandory7be36d312017-03-29 15:51:12167 }
168
Tommy Steimelc9f6c932017-10-13 23:33:04169 if (info.type == CONTENT_SETTINGS_TYPE_SOUND) {
170 if (!base::FeatureList::IsEnabled(features::kSoundContentSetting))
171 return false;
172
Tommy Steimel18360512017-11-01 00:38:19173 // The sound content setting should always show up when the tab has played
174 // audio.
175 if (web_contents && web_contents->WasEverAudible())
Tommy Steimelc9f6c932017-10-13 23:33:04176 return true;
177 }
178
Gary Kacmarcik10533cf2017-11-22 03:31:28179 if (info.type == CONTENT_SETTINGS_TYPE_CLIPBOARD_READ) {
180 if (!base::FeatureList::IsEnabled(features::kClipboardContentSetting))
181 return false;
182 }
183
Patti749d4d12017-10-11 06:20:30184#if defined(OS_ANDROID)
185 // Special geolocation DSE settings apply only on Android, so make sure it
186 // gets checked there regardless of default setting on Desktop.
187 if (info.type == CONTENT_SETTINGS_TYPE_GEOLOCATION)
188 return true;
Pattid7c4d542017-12-07 00:54:14189#else
Patti8c57f37d2018-01-31 04:33:21190 // Flash is shown if the user has ever changed its setting for |site_url|.
191 if (info.type == CONTENT_SETTINGS_TYPE_PLUGINS &&
192 content_settings->GetWebsiteSetting(site_url, site_url,
193 CONTENT_SETTINGS_TYPE_PLUGINS_DATA,
194 std::string(), nullptr) != nullptr) {
Pattid7c4d542017-12-07 00:54:14195 return true;
Patti8c57f37d2018-01-31 04:33:21196 }
Patti749d4d12017-10-11 06:20:30197#endif
198
Patti0601e532017-09-20 08:39:30199#if !defined(OS_ANDROID)
200 // Autoplay is Android-only at the moment.
201 if (info.type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
202 return false;
203#endif
204
shahriar rostamia9c769d2017-12-06 04:54:08205 // Show the content setting if it has been changed by the user since the last
206 // page load.
207 if (tab_specific_content_settings->HasContentSettingChangedViaPageInfo(
208 info.type)) {
209 return true;
210 }
211
212 // Show the content setting when it has a non-default value.
213 if (!IsPermissionFactoryDefault(content_settings, info))
214 return true;
215
216 return false;
mgiucaa319f212016-01-14 03:30:11217}
218
esecklercac56b62016-11-16 13:49:44219void CheckContentStatus(security_state::ContentStatus content_status,
estark00e83f12016-08-19 18:24:04220 bool* displayed,
221 bool* ran) {
222 switch (content_status) {
esecklercac56b62016-11-16 13:49:44223 case security_state::CONTENT_STATUS_DISPLAYED:
estark00e83f12016-08-19 18:24:04224 *displayed = true;
225 break;
esecklercac56b62016-11-16 13:49:44226 case security_state::CONTENT_STATUS_RAN:
estark00e83f12016-08-19 18:24:04227 *ran = true;
228 break;
esecklercac56b62016-11-16 13:49:44229 case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN:
estark00e83f12016-08-19 18:24:04230 *displayed = true;
231 *ran = true;
232 break;
esecklercac56b62016-11-16 13:49:44233 case security_state::CONTENT_STATUS_UNKNOWN:
234 case security_state::CONTENT_STATUS_NONE:
estark00e83f12016-08-19 18:24:04235 break;
236 }
237}
238
elawrenceb2ac2a232017-03-27 21:46:25239// If the |security_info| indicates that mixed content or certificate errors
240// were present, update |connection_status| and |connection_details|.
241void ReportAnyInsecureContent(const security_state::SecurityInfo& security_info,
thestig4427f13b2017-06-20 20:42:47242 PageInfo::SiteConnectionStatus* connection_status,
243 base::string16* connection_details) {
elawrenceb2ac2a232017-03-27 21:46:25244 bool displayed_insecure_content = false;
245 bool ran_insecure_content = false;
246 CheckContentStatus(security_info.mixed_content_status,
247 &displayed_insecure_content, &ran_insecure_content);
248 // Only note subresources with certificate errors if the main resource was
249 // loaded without major certificate errors. If the main resource had a
250 // certificate error, then it would not be that useful (and could
251 // potentially be confusing) to warn about subresources that had certificate
252 // errors too.
253 if (!net::IsCertStatusError(security_info.cert_status) ||
254 net::IsCertStatusMinorError(security_info.cert_status)) {
255 CheckContentStatus(security_info.content_with_cert_errors_status,
256 &displayed_insecure_content, &ran_insecure_content);
257 }
258
259 // Only one insecure content warning is displayed; show the most severe.
260 if (ran_insecure_content) {
thestig4427f13b2017-06-20 20:42:47261 *connection_status =
elawrenceb2ac2a232017-03-27 21:46:25262 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE;
thestig4427f13b2017-06-20 20:42:47263 connection_details->assign(l10n_util::GetStringFUTF16(
264 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25265 l10n_util::GetStringUTF16(
266 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR)));
estark00e83f12016-08-19 18:24:04267 return;
268 }
elawrenceb2ac2a232017-03-27 21:46:25269 if (security_info.contained_mixed_form) {
thestig4427f13b2017-06-20 20:42:47270 *connection_status = PageInfo::SITE_CONNECTION_STATUS_INSECURE_FORM_ACTION;
271 connection_details->assign(l10n_util::GetStringFUTF16(
272 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25273 l10n_util::GetStringUTF16(
274 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_FORM_WARNING)));
275 return;
276 }
277 if (displayed_insecure_content) {
thestig4427f13b2017-06-20 20:42:47278 *connection_status =
elawrenceb2ac2a232017-03-27 21:46:25279 PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
thestig4427f13b2017-06-20 20:42:47280 connection_details->assign(l10n_util::GetStringFUTF16(
281 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25282 l10n_util::GetStringUTF16(
283 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
284 }
estark00e83f12016-08-19 18:24:04285}
286
jshin1fb76462016-04-05 22:13:03287base::string16 GetSimpleSiteName(const GURL& url) {
benwells2337b8102016-04-20 01:53:53288 return url_formatter::FormatUrlForSecurityDisplay(
289 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
palmer153af982015-09-15 02:04:19290}
291
reillyg85f57db2016-01-12 23:14:38292ChooserContextBase* GetUsbChooserContext(Profile* profile) {
293 return UsbChooserContextFactory::GetForProfile(profile);
294}
295
296// The list of chooser types that need to display entries in the Website
297// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
298// email [email protected].
Andrew Grieved1978b0e2017-07-28 15:53:41299const PageInfo::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52300 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
Patti1d8a4312018-01-19 06:36:11301 IDS_PAGE_INFO_USB_DEVICE_LABEL, IDS_PAGE_INFO_USB_DEVICE_SECONDARY_LABEL,
302 IDS_PAGE_INFO_DELETE_USB_DEVICE, "name"},
reillyg85f57db2016-01-12 23:14:38303};
304
Christopher Thompson0c4e06c22018-07-11 22:29:59305// Time open histogram prefixes.
306const char kPageInfoTimePrefix[] = "Security.PageInfo.TimeOpen";
307const char kPageInfoTimeActionPrefix[] = "Security.PageInfo.TimeOpen.Action";
308const char kPageInfoTimeNoActionPrefix[] =
309 "Security.PageInfo.TimeOpen.NoAction";
310
[email protected]0b9fdd72012-04-04 10:00:33311} // namespace
312
lgarron617a30f32017-03-24 21:42:07313PageInfo::PageInfo(PageInfoUI* ui,
314 Profile* profile,
315 TabSpecificContentSettings* tab_specific_content_settings,
316 content::WebContents* web_contents,
317 const GURL& url,
318 const security_state::SecurityInfo& security_info)
[email protected]df818272012-04-20 13:10:50319 : TabSpecificContentSettings::SiteDataObserver(
320 tab_specific_content_settings),
dominicknbdd53b5f2016-09-28 01:08:13321 content::WebContentsObserver(web_contents),
[email protected]df818272012-04-20 13:10:50322 ui_(ui),
[email protected]66f157312012-08-01 13:50:26323 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33324 site_url_(url),
325 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]03ef4b2a2012-03-06 15:04:20326 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
alshabalin5e894c12016-10-25 06:47:46327 show_ssl_decision_revoke_button_(false),
peconn5100d432015-09-16 12:03:08328 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04329 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25330 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19331 did_revoke_user_ssl_decisions_(false),
estark8d67cd7a2016-10-24 05:06:41332 profile_(profile),
Jialiu Lin11e18542017-08-14 18:16:26333 security_level_(security_state::NONE),
Jialiu Linfeb6bb32017-08-30 00:21:36334#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin0d8cc722017-09-19 01:01:51335 password_protection_service_(
336 safe_browsing::ChromePasswordProtectionService::
337 GetPasswordProtectionService(profile_)),
Jialiu Lin11e18542017-08-14 18:16:26338#endif
Christopher Thompson0c4e06c22018-07-11 22:29:59339 show_change_password_buttons_(false),
340 did_perform_action_(false) {
estarka3121f6b2015-09-18 21:15:59341 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33342
343 PresentSitePermissions();
[email protected]24c8818c2012-04-25 09:57:41344 PresentSiteIdentity();
Pattie8c616202017-09-29 07:58:03345 PresentSiteData();
[email protected]e22d64f2012-09-10 09:03:23346
lgarron617a30f32017-03-24 21:42:07347 // Every time the Page Info UI is opened a |PageInfo| object is
348 // created. So this counts how ofter the Page Info UI is opened.
349 RecordPageInfoAction(PAGE_INFO_OPENED);
Christopher Thompson0c4e06c22018-07-11 22:29:59350
351 // Record the time when the Page Info UI is opened so the total time it is
352 // open can be measured.
353 start_time_ = base::TimeTicks::Now();
[email protected]03ef4b2a2012-03-06 15:04:20354}
355
Carlos ILe5dfda72017-09-21 02:33:05356PageInfo::~PageInfo() {
357 // Check if Re-enable warnings button was visible, if so, log on UMA whether
358 // it was clicked or not.
359 SSLCertificateDecisionsDidRevoke user_decision =
360 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
361 : USER_CERT_DECISIONS_NOT_REVOKED;
362 if (show_ssl_decision_revoke_button_) {
363 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions2",
364 user_decision,
365 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
366 }
Christopher Thompson0c4e06c22018-07-11 22:29:59367
368 // Record the total time the Page Info UI was open for all opens as well as
369 // split between whether any action was taken.
370 base::UmaHistogramCustomTimes(
Joe DeBlasioc7b95282018-11-08 18:41:37371 security_state::GetSecurityLevelHistogramName(
372 kPageInfoTimePrefix, security_level_),
Christopher Thompson0c4e06c22018-07-11 22:29:59373 base::TimeTicks::Now() - start_time_,
374 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), 100);
375 if (did_perform_action_) {
376 base::UmaHistogramCustomTimes(
Joe DeBlasioc7b95282018-11-08 18:41:37377 security_state::GetSecurityLevelHistogramName(
378 kPageInfoTimeActionPrefix, security_level_),
Christopher Thompson0c4e06c22018-07-11 22:29:59379 base::TimeTicks::Now() - start_time_,
380 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1),
381 100);
382 } else {
383 base::UmaHistogramCustomTimes(
Joe DeBlasioc7b95282018-11-08 18:41:37384 security_state::GetSecurityLevelHistogramName(
385 kPageInfoTimeNoActionPrefix, security_level_),
Christopher Thompson0c4e06c22018-07-11 22:29:59386 base::TimeTicks::Now() - start_time_,
387 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1),
388 100);
389 }
Carlos ILe5dfda72017-09-21 02:33:05390}
[email protected]03ef4b2a2012-03-06 15:04:20391
lgarron617a30f32017-03-24 21:42:07392void PageInfo::RecordPageInfoAction(PageInfoAction action) {
Christopher Thompson0c4e06c22018-07-11 22:29:59393 if (action != PAGE_INFO_OPENED)
394 did_perform_action_ = true;
395
lgarron617a30f32017-03-24 21:42:07396 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04397
estark8d67cd7a2016-10-24 05:06:41398 std::string histogram_name;
estark8d67cd7a2016-10-24 05:06:41399 if (site_url_.SchemeIsCryptographic()) {
Carlos ILcb2321112018-02-01 18:05:23400 if (security_level_ == security_state::SECURE) {
401 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.ValidNonEV",
402 action, PAGE_INFO_COUNT);
403 } else if (security_level_ == security_state::EV_SECURE) {
404 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.ValidEV",
lgarron617a30f32017-03-24 21:42:07405 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44406 } else if (security_level_ == security_state::NONE) {
estark8d67cd7a2016-10-24 05:06:41407 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded",
lgarron617a30f32017-03-24 21:42:07408 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44409 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41410 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07411 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41412 }
413 return;
414 }
415
esecklercac56b62016-11-16 13:49:44416 if (security_level_ == security_state::HTTP_SHOW_WARNING) {
estark8d67cd7a2016-10-24 05:06:41417 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning",
lgarron617a30f32017-03-24 21:42:07418 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44419 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41420 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07421 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41422 } else {
423 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral",
lgarron617a30f32017-03-24 21:42:07424 action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04425 }
426}
427
lgarron617a30f32017-03-24 21:42:07428void PageInfo::OnSitePermissionChanged(ContentSettingsType type,
429 ContentSetting setting) {
shahriar rostamia9c769d2017-12-06 04:54:08430 tab_specific_content_settings()->ContentSettingChangedViaPageInfo(type);
431
[email protected]e22d64f2012-09-10 09:03:23432 // Count how often a permission for a specific content type is changed using
lgarron617a30f32017-03-24 21:42:07433 // the Page Info UI.
raymes4a13d432015-09-08 00:44:07434 size_t num_values;
435 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
dchengf6f4e4942017-03-30 23:55:57436 UMA_HISTOGRAM_EXACT_LINEAR("WebsiteSettings.OriginInfo.PermissionChanged",
437 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56438
439 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
dchengf6f4e4942017-03-30 23:55:57440 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56441 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07442 num_values);
tommycli34cf29bf2016-09-08 05:46:25443
444 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
445 rappor::SampleDomainAndRegistryFromGURL(
446 g_browser_process->rappor_service(),
447 "ContentSettings.Plugins.AddedAllowException", site_url_);
448 }
sashab9debecd2014-12-18 04:15:56449 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
dchengf6f4e4942017-03-30 23:55:57450 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56451 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07452 num_values);
sashab9debecd2014-12-18 04:15:56453 }
[email protected]e22d64f2012-09-10 09:03:23454
lgarron04a93502014-11-04 22:25:04455 // This is technically redundant given the histogram above, but putting the
456 // total count of permission changes in another histogram makes it easier to
lgarron026e9c42017-04-07 20:09:31457 // compare it against other kinds of actions in Page Info.
lgarron617a30f32017-03-24 21:42:07458 RecordPageInfoAction(PAGE_INFO_CHANGED_PERMISSION);
Tommy Steimeldea90f72017-11-07 20:58:03459 if (type == CONTENT_SETTINGS_TYPE_SOUND) {
460 ContentSetting default_setting =
461 content_settings_->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_SOUND,
462 nullptr);
463 bool mute = (setting == CONTENT_SETTING_BLOCK) ||
464 (setting == CONTENT_SETTING_DEFAULT &&
465 default_setting == CONTENT_SETTING_BLOCK);
466 if (mute) {
467 base::RecordAction(
468 base::UserMetricsAction("SoundContentSetting.MuteBy.PageInfo"));
469 } else {
470 base::RecordAction(
471 base::UserMetricsAction("SoundContentSetting.UnmuteBy.PageInfo"));
472 }
473 }
lgarron04a93502014-11-04 22:25:04474
stefanocs8b3490cc2016-07-28 05:32:52475 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
patricialor7131c1fe2017-04-07 01:25:52476 profile_, site_url_, site_url_, type, PermissionSourceUI::OIB);
stefanocs8b3490cc2016-07-28 05:32:52477
patricialor7131c1fe2017-04-07 01:25:52478 // The permission may have been blocked due to being under embargo, so if it
479 // was changed away from BLOCK, clear embargo status if it exists.
480 if (setting != CONTENT_SETTING_BLOCK) {
481 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveEmbargoByUrl(
482 site_url_, type);
483 }
raymesfbaaaaa2015-11-10 02:20:40484 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
485 setting);
[email protected]df818272012-04-20 13:10:50486
Tommy Steimel97ee2f82017-11-01 21:39:52487 // When the sound setting is changed, no reload is necessary.
488 if (type != CONTENT_SETTINGS_TYPE_SOUND)
489 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24490
491 // Refresh the UI to reflect the new setting.
492 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50493}
494
lgarron617a30f32017-03-24 21:42:07495void PageInfo::OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info,
496 const base::DictionaryValue& object) {
reillyg85f57db2016-01-12 23:14:38497 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
498 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10499 const GURL origin = site_url_.GetOrigin();
500 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38501 show_info_bar_ = true;
502
503 // Refresh the UI to reflect the changed settings.
504 PresentSitePermissions();
505}
506
lgarron617a30f32017-03-24 21:42:07507void PageInfo::OnSiteDataAccessed() {
[email protected]df818272012-04-20 13:10:50508 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33509}
510
lgarron617a30f32017-03-24 21:42:07511void PageInfo::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49512#if defined(OS_ANDROID)
513 NOTREACHED();
514#else
dominicknbdd53b5f2016-09-28 01:08:13515 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
palmerf2cba0d2015-08-27 23:15:06516 InfoBarService* infobar_service =
dominicknbdd53b5f2016-09-28 01:08:13517 InfoBarService::FromWebContents(web_contents());
palmerf2cba0d2015-08-27 23:15:06518 if (infobar_service)
lgarron617a30f32017-03-24 21:42:07519 PageInfoInfoBarDelegate::Create(infobar_service);
palmerf2cba0d2015-08-27 23:15:06520 }
estade3feb83f2015-09-01 23:00:49521#endif
jww1ed8ea72014-09-02 20:43:25522}
523
lgarron617a30f32017-03-24 21:42:07524void PageInfo::OnRevokeSSLErrorBypassButtonPressed() {
jww1ed8ea72014-09-02 20:43:25525 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29526 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
527 site_url().host());
jww1ed8ea72014-09-02 20:43:25528 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26529}
530
Patricia Lora21a04cf2017-06-05 02:53:29531void PageInfo::OpenSiteSettingsView() {
Christopher Lam0dbac2b2017-11-14 07:12:10532#if defined(OS_ANDROID)
533 NOTREACHED();
534#else
535 chrome::ShowSiteSettings(chrome::FindBrowserWithWebContents(web_contents()),
536 site_url());
Patricia Lora21a04cf2017-06-05 02:53:29537 RecordPageInfoAction(PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED);
Christopher Lam0dbac2b2017-11-14 07:12:10538#endif
Patricia Lora21a04cf2017-06-05 02:53:29539}
540
Jialiu Lin11e18542017-08-14 18:16:26541void PageInfo::OnChangePasswordButtonPressed(
542 content::WebContents* web_contents) {
Jialiu Linfeb6bb32017-08-30 00:21:36543#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26544 DCHECK(password_protection_service_);
Jialiu Lind7defe652018-06-20 18:47:06545 DCHECK(site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE ||
546 site_identity_status_ ==
547 SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE);
Jialiu Lin3fc7f38f2017-09-21 18:38:37548 password_protection_service_->OnUserAction(
Jialiu Lind7defe652018-06-20 18:47:06549 web_contents,
550 site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE
551 ? PasswordReuseEvent::SIGN_IN_PASSWORD
552 : PasswordReuseEvent::ENTERPRISE_PASSWORD,
Jialiu Lina97fe522018-07-26 16:47:26553 safe_browsing::WarningUIType::PAGE_INFO,
554 safe_browsing::WarningAction::CHANGE_PASSWORD);
Jialiu Lin11e18542017-08-14 18:16:26555#endif
556}
557
558void PageInfo::OnWhitelistPasswordReuseButtonPressed(
559 content::WebContents* web_contents) {
Jialiu Linfeb6bb32017-08-30 00:21:36560#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26561 DCHECK(password_protection_service_);
Jialiu Lind7defe652018-06-20 18:47:06562 DCHECK(site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE ||
563 site_identity_status_ ==
564 SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE);
Jialiu Lin3fc7f38f2017-09-21 18:38:37565 password_protection_service_->OnUserAction(
Jialiu Lind7defe652018-06-20 18:47:06566 web_contents,
567 site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE
568 ? PasswordReuseEvent::SIGN_IN_PASSWORD
569 : PasswordReuseEvent::ENTERPRISE_PASSWORD,
Jialiu Lina97fe522018-07-26 16:47:26570 safe_browsing::WarningUIType::PAGE_INFO,
571 safe_browsing::WarningAction::MARK_AS_LEGITIMATE);
Jialiu Lin11e18542017-08-14 18:16:26572#endif
573}
574
lgarron617a30f32017-03-24 21:42:07575void PageInfo::Init(const GURL& url,
576 const security_state::SecurityInfo& security_info) {
thestig0c55ee32017-06-20 22:17:51577#if !defined(OS_ANDROID)
meacerde53fcff2016-10-12 19:21:57578 // On desktop, internal URLs aren't handled by this class. Instead, a
lgarron026e9c42017-04-07 20:09:31579 // custom and simpler bubble is shown.
meacerde53fcff2016-10-12 19:21:57580 DCHECK(!url.SchemeIs(content::kChromeUIScheme) &&
581 !url.SchemeIs(content::kChromeDevToolsScheme) &&
582 !url.SchemeIs(content::kViewSourceScheme) &&
583 !url.SchemeIs(content_settings::kExtensionScheme));
584#endif
585
thestig0c55ee32017-06-20 22:17:51586 bool is_chrome_ui_native_scheme = false;
zpengdb4a58e2017-01-10 17:40:32587#if defined(OS_ANDROID)
thestig0c55ee32017-06-20 22:17:51588 is_chrome_ui_native_scheme = url.SchemeIs(chrome::kChromeUINativeScheme);
sashab97894ce2014-10-22 10:08:33589#endif
590
estark8d67cd7a2016-10-24 05:06:41591 security_level_ = security_info.security_level;
592
upendrag.gowda60886a6e2015-10-31 05:51:09593 if (url.SchemeIs(url::kAboutScheme)) {
594 // All about: URLs except about:blank are redirected.
595 DCHECK_EQ(url::kAboutBlankURL, url.spec());
596 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
597 site_identity_details_ =
598 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
599 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
600 site_connection_details_ = l10n_util::GetStringFUTF16(
601 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
602 UTF8ToUTF16(url.spec()));
603 return;
604 }
605
thestig0c55ee32017-06-20 22:17:51606 if (url.SchemeIs(content::kChromeUIScheme) || is_chrome_ui_native_scheme) {
[email protected]03ef4b2a2012-03-06 15:04:20607 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
608 site_identity_details_ =
609 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
610 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
611 return;
612 }
613
[email protected]03ef4b2a2012-03-06 15:04:20614 // Identity section.
jam8ae7cad2016-09-08 23:55:21615 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11616
estarkfcfccdb82016-11-14 02:17:29617 if (security_info.malicious_content_status !=
esecklercac56b62016-11-16 13:49:44618 security_state::MALICIOUS_CONTENT_STATUS_NONE) {
estarkfcfccdb82016-11-14 02:17:29619 // The site has been flagged by Safe Browsing as dangerous.
620 GetSiteIdentityByMaliciousContentStatus(
621 security_info.malicious_content_status, &site_identity_status_,
622 &site_identity_details_);
Jialiu Lin11e18542017-08-14 18:16:26623 show_change_password_buttons_ =
Jialiu Lind7defe652018-06-20 18:47:06624 (security_info.malicious_content_status ==
625 security_state::MALICIOUS_CONTENT_STATUS_SIGN_IN_PASSWORD_REUSE ||
626 security_info.malicious_content_status ==
627 security_state::
628 MALICIOUS_CONTENT_STATUS_ENTERPRISE_PASSWORD_REUSE);
estarkfcfccdb82016-11-14 02:17:29629 } else if (certificate_ &&
630 (!net::IsCertStatusError(security_info.cert_status) ||
631 net::IsCertStatusMinorError(security_info.cert_status))) {
632 // HTTPS with no or minor errors.
estarka3121f6b2015-09-18 21:15:59633 if (security_info.security_level ==
esecklercac56b62016-11-16 13:49:44634 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;
[email protected]24a9f1c92013-11-13 12:33:37637 site_identity_details_ = l10n_util::GetStringFUTF16(
638 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
estarka3121f6b2015-09-18 21:15:59642 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20643 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21644 base::string16 issuer_name(
645 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20646 if (issuer_name.empty()) {
647 issuer_name.assign(l10n_util::GetStringUTF16(
648 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
649 }
[email protected]94c74b42013-12-02 15:19:49650
[email protected]03ef4b2a2012-03-06 15:04:20651 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39652 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20653
654 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59655 if (security_info.cert_status &
656 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20657 site_identity_details_ += l10n_util::GetStringUTF16(
658 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59659 } else if (security_info.cert_status &
660 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20661 site_identity_details_ += l10n_util::GetStringUTF16(
662 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
663 } else {
664 NOTREACHED() << "Need to specify string for this warning";
665 }
[email protected]03ef4b2a2012-03-06 15:04:20666 } else {
estarkcf305562016-11-15 03:45:39667 // No major or minor errors.
estarka3121f6b2015-09-18 21:15:59668 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01669 // EV HTTPS page.
estarkcf305562016-11-15 03:45:39670 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
jam8ae7cad2016-09-08 23:55:21671 DCHECK(!certificate_->subject().organization_names.empty());
672 organization_name_ =
673 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01674 // An EV Cert is required to have a city (localityName) and country but
675 // state is "if any".
jam8ae7cad2016-09-08 23:55:21676 DCHECK(!certificate_->subject().locality_name.empty());
677 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01678 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21679 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01680 locality = l10n_util::GetStringFUTF16(
lgarronfc1d5e52017-05-03 23:15:21681 IDS_PAGE_INFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21682 UTF8ToUTF16(certificate_->subject().locality_name),
683 UTF8ToUTF16(certificate_->subject().state_or_province_name),
684 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01685 } else {
686 locality = l10n_util::GetStringFUTF16(
lgarronfc1d5e52017-05-03 23:15:21687 IDS_PAGE_INFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21688 UTF8ToUTF16(certificate_->subject().locality_name),
689 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01690 }
jam8ae7cad2016-09-08 23:55:21691 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01692 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39693 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED,
jam8ae7cad2016-09-08 23:55:21694 UTF8ToUTF16(certificate_->subject().organization_names[0]),
estarkcf305562016-11-15 03:45:39695 locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01696 } else {
697 // Non-EV OK HTTPS page.
estarkcf305562016-11-15 03:45:39698 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
rsleevi4f8012722014-09-30 01:28:01699 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21700 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01701 if (issuer_name.empty()) {
702 issuer_name.assign(l10n_util::GetStringUTF16(
703 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
704 }
[email protected]94c74b42013-12-02 15:19:49705
rsleevi4f8012722014-09-30 01:28:01706 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39707 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
rsleevi4f8012722014-09-30 01:28:01708 }
elawrencebe87bd62017-01-10 16:08:59709 if (security_info.sha1_in_chain) {
710 site_identity_status_ =
711 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM;
712 site_identity_details_ +=
713 UTF8ToUTF16("\n\n") +
714 l10n_util::GetStringUTF16(
715 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM);
rsleevi4f8012722014-09-30 01:28:01716 }
[email protected]03ef4b2a2012-03-06 15:04:20717 }
718 } else {
719 // HTTP or HTTPS with errors (not warnings).
720 site_identity_details_.assign(l10n_util::GetStringUTF16(
721 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
jam8ae7cad2016-09-08 23:55:21722 if (!security_info.scheme_is_cryptographic || !security_info.certificate)
[email protected]03ef4b2a2012-03-06 15:04:20723 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
724 else
725 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
726
[email protected]a04db822013-12-11 19:14:40727 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59728 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59729 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
jam8ae7cad2016-09-08 23:55:21730 certificate_, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20731 for (size_t i = 0; i < errors.size(); ++i) {
732 site_identity_details_ += bullet;
733 site_identity_details_ += errors[i].short_description();
734 }
735
estarka3121f6b2015-09-18 21:15:59736 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20737 site_identity_details_ += ASCIIToUTF16("\n\n");
lgarron1a6300d2017-03-18 03:33:04738 site_identity_details_ +=
739 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
[email protected]03ef4b2a2012-03-06 15:04:20740 }
741 }
742
743 // Site Connection
744 // We consider anything less than 80 bits encryption to be weak encryption.
745 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
746 // weakly encrypted connections.
747 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
748
jshin1fb76462016-04-05 22:13:03749 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19750 if (subject_name.empty()) {
751 subject_name.assign(
752 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
753 }
754
jam8ae7cad2016-09-08 23:55:21755 if (!security_info.certificate || !security_info.scheme_is_cryptographic) {
estarka3121f6b2015-09-18 21:15:59756 // Page is still loading (so SSL status is not yet available) or
757 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58758 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
759
760 site_connection_details_.assign(l10n_util::GetStringFUTF16(
761 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
762 subject_name));
Daniel McArdle2bd4fd82018-11-28 20:58:08763 } else if (!security_info.connection_info_initialized) {
esecklercac56b62016-11-16 13:49:44764 DCHECK_NE(security_info.security_level, security_state::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20765 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
[email protected]03ef4b2a2012-03-06 15:04:20766 } else {
767 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22768
lgarron3e2c33e2016-08-25 06:33:43769 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22770 site_connection_details_.assign(l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04771 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, subject_name));
Adam Langley71c2b59b2014-11-13 00:34:22772 } else {
773 site_connection_details_.assign(l10n_util::GetStringFUTF16(
774 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
775 subject_name));
776 }
777
thestig4427f13b2017-06-20 20:42:47778 ReportAnyInsecureContent(security_info, &site_connection_status_,
779 &site_connection_details_);
[email protected]03ef4b2a2012-03-06 15:04:20780 }
781
avi655876a2015-12-25 07:18:15782 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59783 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
Daniel McArdle2bd4fd82018-11-28 20:58:08784 if (security_info.connection_info_initialized && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20785 int ssl_version =
estarka3121f6b2015-09-18 21:15:59786 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20787 const char* ssl_version_str;
788 net::SSLVersionToString(&ssl_version_str, ssl_version);
789 site_connection_details_ += ASCIIToUTF16("\n\n");
790 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04791 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, ASCIIToUTF16(ssl_version_str));
[email protected]03ef4b2a2012-03-06 15:04:20792
[email protected]03ef4b2a2012-03-06 15:04:20793 const char *key_exchange, *cipher, *mac;
davidben56a8aece2016-10-14 18:20:56794 bool is_aead, is_tls13;
795 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
796 &is_tls13, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20797
798 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57799 if (is_aead) {
davidben56a8aece2016-10-14 18:20:56800 if (is_tls13) {
801 // For TLS 1.3 ciphers, report the group (historically, curve) as the
802 // key exchange.
803 key_exchange = SSL_get_curve_name(security_info.key_exchange_group);
804 if (!key_exchange) {
805 NOTREACHED();
806 key_exchange = "";
807 }
808 }
[email protected]b6c1d9e82013-06-12 17:26:57809 site_connection_details_ += l10n_util::GetStringFUTF16(
810 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
811 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
812 } else {
813 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04814 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, ASCIIToUTF16(cipher),
815 ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
[email protected]b6c1d9e82013-06-12 17:26:57816 }
[email protected]03ef4b2a2012-03-06 15:04:20817 }
[email protected]e583f752012-08-30 13:26:21818
[email protected]71cd5ef2014-08-13 21:22:04819 // Check if a user decision has been made to allow or deny certificates with
820 // errors on this site.
821 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50822 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04823 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40824 // Only show an SSL decision revoke button if the user has chosen to bypass
825 // SSL host errors for this host in the past.
826 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]03ef4b2a2012-03-06 15:04:20827}
[email protected]0b9fdd72012-04-04 10:00:33828
lgarron617a30f32017-03-24 21:42:07829void PageInfo::PresentSitePermissions() {
[email protected]df818272012-04-20 13:10:50830 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38831 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50832
lgarron617a30f32017-03-24 21:42:07833 PageInfoUI::PermissionInfo permission_info;
Avi Drissman22f82872018-12-25 23:09:07834 for (size_t i = 0; i < base::size(kPermissionType); ++i) {
[email protected]df818272012-04-20 13:10:50835 permission_info.type = kPermissionType[i];
836
837 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32838 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
839 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21840 DCHECK(value.get());
jdoerrie76cee9c2017-10-06 22:42:42841 if (value->type() == base::Value::Type::INTEGER) {
sashab2b2a314f2015-01-17 06:42:21842 permission_info.setting =
843 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26844 } else {
sashab2b2a314f2015-01-17 06:42:21845 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26846 }
847
[email protected]8bdf45c32012-08-04 00:12:55848 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28849 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50850
[email protected]b1d113d2012-06-27 21:27:34851 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21852 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34853 permission_info.default_setting = permission_info.setting;
854 permission_info.setting = CONTENT_SETTING_DEFAULT;
855 } else {
856 permission_info.default_setting =
857 content_settings_->GetDefaultContentSetting(permission_info.type,
858 NULL);
[email protected]df818272012-04-20 13:10:50859 }
palmer0da10b32015-02-11 00:42:19860
patricialor2a4f41a2017-03-08 02:52:56861 // For permissions that are still prompting the user and haven't been
862 // explicitly set by another source, check its embargo status.
863 if (PermissionUtil::IsPermission(permission_info.type) &&
864 permission_info.setting == CONTENT_SETTING_DEFAULT &&
865 permission_info.source ==
866 content_settings::SettingSource::SETTING_SOURCE_USER) {
867 // TODO(raymes): Use GetPermissionStatus() to retrieve information
868 // about *all* permissions once it has default behaviour implemented for
869 // ContentSettingTypes that aren't permissions.
870 PermissionResult permission_result =
871 PermissionManager::Get(profile_)->GetPermissionStatus(
872 permission_info.type, site_url_, site_url_);
873
874 // If under embargo, update |permission_info| to reflect that.
875 if (permission_result.content_setting == CONTENT_SETTING_BLOCK &&
Timothy Loh8fbdac52018-03-15 03:34:30876 permission_result.source ==
877 PermissionStatusSource::MULTIPLE_DISMISSALS) {
patricialor2a4f41a2017-03-08 02:52:56878 permission_info.setting = permission_result.content_setting;
Timothy Loh8fbdac52018-03-15 03:34:30879 }
patricialor2a4f41a2017-03-08 02:52:56880 }
881
Tommy Steimelc9f6c932017-10-13 23:33:04882 if (ShouldShowPermission(permission_info, site_url_, content_settings_,
shahriar rostamia9c769d2017-12-06 04:54:08883 web_contents(), tab_specific_content_settings())) {
Patti0601e532017-09-20 08:39:30884 permission_info_list.push_back(permission_info);
Tommy Steimelc9f6c932017-10-13 23:33:04885 }
[email protected]df818272012-04-20 13:10:50886 }
887
reillyg85f57db2016-01-12 23:14:38888 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
889 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10890 const GURL origin = site_url_.GetOrigin();
Reilly Granta69ab672018-04-06 18:26:07891
892 // Hide individual object permissions because when the chooser is blocked
893 // previously granted device permissions are also ignored.
894 if (!context->CanRequestObjectPermission(origin, origin))
895 continue;
896
reillyg36a7fab32016-01-28 19:15:10897 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32898 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38899 chosen_object_info_list.push_back(
Jinho Bangcc280792018-01-17 23:33:55900 std::make_unique<PageInfoUI::ChosenObjectInfo>(ui_info,
lgarron617a30f32017-03-24 21:42:07901 std::move(object)));
reillyg85f57db2016-01-12 23:14:38902 }
903 }
904
avi09dd4d02016-10-14 20:40:09905 ui_->SetPermissionInfo(permission_info_list,
906 std::move(chosen_object_info_list));
[email protected]0b9fdd72012-04-04 10:00:33907}
908
lgarron617a30f32017-03-24 21:42:07909void PageInfo::PresentSiteData() {
[email protected]df818272012-04-20 13:10:50910 CookieInfoList cookie_info_list;
vabrbab3ffcb2016-10-04 10:08:10911 const LocalSharedObjectsContainer& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34912 tab_specific_content_settings()->allowed_local_shared_objects();
vabrbab3ffcb2016-10-04 10:08:10913 const LocalSharedObjectsContainer& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34914 tab_specific_content_settings()->blocked_local_shared_objects();
915
916 // Add first party cookie and site data counts.
lgarron617a30f32017-03-24 21:42:07917 PageInfoUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34918 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
919 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15920 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34921 cookie_info_list.push_back(cookie_info);
922
923 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34924 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
925 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15926 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50927 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33928
[email protected]df818272012-04-20 13:10:50929 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33930}
[email protected]16de6de2012-04-04 12:24:14931
lgarron617a30f32017-03-24 21:42:07932void PageInfo::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04933 // After initialization the status about the site's connection and its
934 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41935 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
936 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
lgarron617a30f32017-03-24 21:42:07937 PageInfoUI::IdentityInfo info;
[email protected]24c8818c2012-04-25 09:57:41938 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
939 info.site_identity = UTF16ToUTF8(organization_name());
940 else
jshin1fb76462016-04-05 22:13:03941 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41942
943 info.connection_status = site_connection_status_;
lgarron1a6300d2017-03-18 03:33:04944 info.connection_status_description = UTF16ToUTF8(site_connection_details_);
[email protected]24c8818c2012-04-25 09:57:41945 info.identity_status = site_identity_status_;
lgarron1a6300d2017-03-18 03:33:04946 info.identity_status_description = UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21947 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04948 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
Jialiu Lin11e18542017-08-14 18:16:26949 info.show_change_password_buttons = show_change_password_buttons_;
[email protected]24c8818c2012-04-25 09:57:41950 ui_->SetIdentityInfo(info);
Jialiu Linfeb6bb32017-08-30 00:21:36951#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26952 if (password_protection_service_ && show_change_password_buttons_) {
Jialiu Lind7defe652018-06-20 18:47:06953 if (site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE) {
Jialiu Lina97fe522018-07-26 16:47:26954 safe_browsing::LogWarningAction(
955 safe_browsing::WarningUIType::PAGE_INFO,
956 safe_browsing::WarningAction::SHOWN,
Jialiu Lind7defe652018-06-20 18:47:06957 safe_browsing::LoginReputationClientRequest::PasswordReuseEvent::
Jialiu Lina97fe522018-07-26 16:47:26958 SIGN_IN_PASSWORD,
959 password_protection_service_->GetSyncAccountType());
Jialiu Lind7defe652018-06-20 18:47:06960 } else {
Jialiu Lina97fe522018-07-26 16:47:26961 safe_browsing::LogWarningAction(
962 safe_browsing::WarningUIType::PAGE_INFO,
963 safe_browsing::WarningAction::SHOWN,
Jialiu Lind7defe652018-06-20 18:47:06964 safe_browsing::LoginReputationClientRequest::PasswordReuseEvent::
Jialiu Lina97fe522018-07-26 16:47:26965 ENTERPRISE_PASSWORD,
966 password_protection_service_->GetSyncAccountType());
Jialiu Lind7defe652018-06-20 18:47:06967 }
Jialiu Lin11e18542017-08-14 18:16:26968 }
969#endif
[email protected]24c8818c2012-04-25 09:57:41970}
Patti7f21c4b2017-11-28 03:37:17971
972std::vector<ContentSettingsType> PageInfo::GetAllPermissionsForTesting() {
973 std::vector<ContentSettingsType> permission_list;
Avi Drissman22f82872018-12-25 23:09:07974 for (size_t i = 0; i < base::size(kPermissionType); ++i) {
Patti7f21c4b2017-11-28 03:37:17975#if !defined(OS_ANDROID)
976 if (kPermissionType[i] == CONTENT_SETTINGS_TYPE_AUTOPLAY)
977 continue;
978#endif
979 permission_list.push_back(kPermissionType[i]);
980 }
981 return permission_list;
982}
Jialiu Lin4d7c6042018-04-04 17:45:35983
984void PageInfo::GetSiteIdentityByMaliciousContentStatus(
985 security_state::MaliciousContentStatus malicious_content_status,
986 PageInfo::SiteIdentityStatus* status,
987 base::string16* details) {
988 switch (malicious_content_status) {
989 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
990 NOTREACHED();
991 break;
992 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
993 *status = PageInfo::SITE_IDENTITY_STATUS_MALWARE;
994 *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MALWARE_DETAILS);
995 break;
996 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
997 *status = PageInfo::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
998 *details =
999 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SOCIAL_ENGINEERING_DETAILS);
1000 break;
1001 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
1002 *status = PageInfo::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
1003 *details =
1004 l10n_util::GetStringUTF16(IDS_PAGE_INFO_UNWANTED_SOFTWARE_DETAILS);
1005 break;
Jialiu Lind7defe652018-06-20 18:47:061006 case security_state::MALICIOUS_CONTENT_STATUS_SIGN_IN_PASSWORD_REUSE:
Jialiu Lin4d7c6042018-04-04 17:45:351007#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lind7defe652018-06-20 18:47:061008 *status = PageInfo::SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE;
1009 // |password_protection_service_| may be null in test.
1010 *details = password_protection_service_
1011 ? password_protection_service_->GetWarningDetailText(
1012 PasswordReuseEvent::SIGN_IN_PASSWORD)
1013 : base::string16();
1014#endif
1015 break;
1016 case security_state::MALICIOUS_CONTENT_STATUS_ENTERPRISE_PASSWORD_REUSE:
1017#if defined(SAFE_BROWSING_DB_LOCAL)
1018 *status = PageInfo::SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE;
1019 // |password_protection_service_| maybe null in test.
1020 *details = password_protection_service_
1021 ? password_protection_service_->GetWarningDetailText(
1022 PasswordReuseEvent::ENTERPRISE_PASSWORD)
1023 : base::string16();
Jialiu Lin4d7c6042018-04-04 17:45:351024#endif
1025 break;
spqchan6da308a2018-08-10 19:19:531026 case security_state::MALICIOUS_CONTENT_STATUS_BILLING:
spqchan6da308a2018-08-10 19:19:531027 *status = PageInfo::SITE_IDENTITY_STATUS_BILLING;
1028 *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_BILLING_DETAILS);
spqchan6da308a2018-08-10 19:19:531029 break;
Jialiu Lin4d7c6042018-04-04 17:45:351030 }
1031}