blob: 9681d8e6478d3c834d26aef04bc9686a22394b43 [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"
avi655876a2015-12-25 07:18:1517#include "base/macros.h"
[email protected]71cd5ef2014-08-13 21:22:0418#include "base/metrics/field_trial.h"
Christopher Thompson0c4e06c22018-07-11 22:29:5919#include "base/metrics/histogram_functions.h"
asvitkine75036032016-09-01 20:49:3420#include "base/metrics/histogram_macros.h"
Tommy Steimeldea90f72017-11-07 20:58:0321#include "base/metrics/user_metrics.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]6b8a3c742014-07-25 00:25:3526#include "chrome/browser/browsing_data/browsing_data_channel_id_helper.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"
Patricia Lora21a04cf2017-06-05 02:53:2949#include "chrome/common/chrome_features.h"
[email protected]71cd5ef2014-08-13 21:22:0450#include "chrome/common/chrome_switches.h"
jsbellddb849e2015-08-27 00:12:5651#include "chrome/common/url_constants.h"
reillyg85f57db2016-01-12 23:14:3852#include "chrome/grit/theme_resources.h"
Patti0601e532017-09-20 08:39:3053#include "components/content_settings/core/browser/content_settings_registry.h"
mukai8eaec822014-10-25 17:53:1654#include "components/content_settings/core/browser/content_settings_utils.h"
55#include "components/content_settings/core/browser/host_content_settings_map.h"
palmer0da10b32015-02-11 00:42:1956#include "components/content_settings/core/common/content_settings.h"
vasiliif62dbf92014-09-05 10:23:1357#include "components/content_settings/core/common/content_settings_pattern.h"
tbansal08a0e3e2017-06-30 21:30:0858#include "components/content_settings/core/common/content_settings_utils.h"
nzolghadrd87a308d2016-12-07 15:45:5659#include "components/rappor/public/rappor_utils.h"
60#include "components/rappor/rappor_service_impl.h"
felt2493b4452015-09-17 20:33:5961#include "components/ssl_errors/error_info.h"
thestig4a2e88e2016-08-27 23:23:5162#include "components/strings/grit/components_chromium_strings.h"
63#include "components/strings/grit/components_strings.h"
melandory7be36d312017-03-29 15:51:1264#include "components/subresource_filter/core/browser/subresource_filter_features.h"
palmer153af982015-09-15 02:04:1965#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3366#include "content/public/browser/browser_thread.h"
[email protected]eb2140c2013-07-29 12:37:3467#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2068#include "content/public/common/url_constants.h"
[email protected]6e7845ae2013-03-29 21:48:1169#include "net/cert/cert_status_flags.h"
70#include "net/cert/x509_certificate.h"
[email protected]536fd0b2013-03-14 17:41:5771#include "net/ssl/ssl_cipher_suite_names.h"
72#include "net/ssl/ssl_connection_status_flags.h"
tfarina29a3a1742016-10-28 18:47:3373#include "third_party/boringssl/src/include/openssl/ssl.h"
[email protected]03ef4b2a2012-03-06 15:04:2074#include "ui/base/l10n/l10n_util.h"
Patricia Lora21a04cf2017-06-05 02:53:2975#include "url/origin.h"
[email protected]03ef4b2a2012-03-06 15:04:2076
[email protected]24a9f1c92013-11-13 12:33:3777#if defined(OS_CHROMEOS)
78#include "chrome/browser/chromeos/policy/policy_cert_service.h"
79#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
80#endif
81
estade3feb83f2015-09-01 23:00:4982#if !defined(OS_ANDROID)
Christopher Lam0dbac2b2017-11-14 07:12:1083#include "chrome/browser/ui/browser_finder.h"
84#include "chrome/browser/ui/chrome_pages.h"
mgiucaa319f212016-01-14 03:30:1185#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
lgarron617a30f32017-03-24 21:42:0786#include "chrome/browser/ui/page_info/page_info_infobar_delegate.h"
estade3feb83f2015-09-01 23:00:4987#endif
88
Jialiu Lin11e18542017-08-14 18:16:2689#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin0d8cc722017-09-19 01:01:5190#include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
Jialiu Lin11e18542017-08-14 18:16:2691#endif
92
[email protected]ab6df3b12013-12-24 23:32:2693using base::ASCIIToUTF16;
94using base::UTF8ToUTF16;
[email protected]f729d7a2013-12-26 07:07:5695using base::UTF16ToUTF8;
[email protected]0b9fdd72012-04-04 10:00:3396using content::BrowserThread;
Jialiu Lind7defe652018-06-20 18:47:0697#if defined(SAFE_BROWSING_DB_LOCAL)
98using PasswordReuseEvent =
99 safe_browsing::LoginReputationClientRequest::PasswordReuseEvent;
100#endif // SAFE_BROWSING_DB_LOCAL
[email protected]0b9fdd72012-04-04 10:00:33101
102namespace {
103
lgarron617a30f32017-03-24 21:42:07104// The list of content settings types to display on the Page Info UI. THE
csharrisonad1eaa6c2017-05-11 17:14:38105// ORDER OF THESE ITEMS IS IMPORTANT and comes from https://crbug.com/610358. To
106// propose changing it, email [email protected].
[email protected]0b9fdd72012-04-04 10:00:33107ContentSettingsType kPermissionType[] = {
sashab2b2a314f2015-01-17 06:42:21108 CONTENT_SETTINGS_TYPE_GEOLOCATION,
sashab2b2a314f2015-01-17 06:42:21109 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
110 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
Alexander Shalamovce5aab52018-02-07 11:45:15111 CONTENT_SETTINGS_TYPE_SENSORS,
palmer0da10b32015-02-11 00:42:19112 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
palmer7715e332016-05-27 00:41:19113 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
lshange085f202016-06-14 01:25:08114#if !defined(OS_ANDROID)
palmer7715e332016-05-27 00:41:19115 CONTENT_SETTINGS_TYPE_PLUGINS,
116 CONTENT_SETTINGS_TYPE_IMAGES,
lshange085f202016-06-14 01:25:08117#endif
palmer7715e332016-05-27 00:41:19118 CONTENT_SETTINGS_TYPE_POPUPS,
Charles Harrison239d47982017-06-13 02:42:31119 CONTENT_SETTINGS_TYPE_ADS,
nsatragno670fe922016-04-08 14:10:50120 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
Tommy Steimela8c3757e2017-08-24 00:15:46121 CONTENT_SETTINGS_TYPE_SOUND,
palmer7715e332016-05-27 00:41:19122 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
finnur46cafd42016-09-22 10:27:17123 CONTENT_SETTINGS_TYPE_AUTOPLAY,
palmer7715e332016-05-27 00:41:19124 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
Gary Kacmarcik10533cf2017-11-22 03:31:28125 CONTENT_SETTINGS_TYPE_CLIPBOARD_READ,
Reilly Granta69ab672018-04-06 18:26:07126 CONTENT_SETTINGS_TYPE_USB_GUARD,
[email protected]0b9fdd72012-04-04 10:00:33127};
128
Patti0601e532017-09-20 08:39:30129// Checks whether this permission is currently the factory default, as set by
130// Chrome. Specifically, that the following three conditions are true:
131// - The current active setting comes from the default or pref provider.
132// - The setting is the factory default setting (as opposed to a global
133// default setting set by the user).
134// - The setting is a wildcard setting applying to all origins (which can only
135// be set from the default provider).
136bool IsPermissionFactoryDefault(HostContentSettingsMap* content_settings,
137 const PageInfoUI::PermissionInfo& info) {
138 const ContentSetting factory_default_setting =
139 content_settings::ContentSettingsRegistry::GetInstance()
140 ->Get(info.type)
141 ->GetInitialDefaultSetting();
142 return (info.source == content_settings::SETTING_SOURCE_USER &&
143 factory_default_setting == info.default_setting &&
144 info.setting == CONTENT_SETTING_DEFAULT);
145}
146
lgarron617a30f32017-03-24 21:42:07147// Determines whether to show permission |type| in the Page Info UI. Only
mgiucaa319f212016-01-14 03:30:11148// applies to permissions listed in |kPermissionType|.
shahriar rostamia9c769d2017-12-06 04:54:08149bool ShouldShowPermission(
150 const PageInfoUI::PermissionInfo& info,
151 const GURL& site_url,
152 HostContentSettingsMap* content_settings,
153 content::WebContents* web_contents,
154 TabSpecificContentSettings* tab_specific_content_settings) {
Patti0601e532017-09-20 08:39:30155 // Note |CONTENT_SETTINGS_TYPE_ADS| will show up regardless of its default
156 // value when it has been activated on the current origin.
157 if (info.type == CONTENT_SETTINGS_TYPE_ADS) {
csharrisonad1eaa6c2017-05-11 17:14:38158 if (!base::FeatureList::IsEnabled(
Charlie Harrisonb73f7622018-06-01 14:24:34159 subresource_filter::kSafeBrowsingSubresourceFilter)) {
csharrisonad1eaa6c2017-05-11 17:14:38160 return false;
161 }
162
163 // The setting for subresource filtering should not show up if the site is
164 // not activated, both on android and desktop platforms.
165 return content_settings->GetWebsiteSetting(
Charles Harrison239d47982017-06-13 02:42:31166 site_url, GURL(), CONTENT_SETTINGS_TYPE_ADS_DATA, std::string(),
167 nullptr) != nullptr;
melandory7be36d312017-03-29 15:51:12168 }
169
Tommy Steimelc9f6c932017-10-13 23:33:04170 if (info.type == CONTENT_SETTINGS_TYPE_SOUND) {
171 if (!base::FeatureList::IsEnabled(features::kSoundContentSetting))
172 return false;
173
Tommy Steimel18360512017-11-01 00:38:19174 // The sound content setting should always show up when the tab has played
175 // audio.
176 if (web_contents && web_contents->WasEverAudible())
Tommy Steimelc9f6c932017-10-13 23:33:04177 return true;
178 }
179
Gary Kacmarcik10533cf2017-11-22 03:31:28180 if (info.type == CONTENT_SETTINGS_TYPE_CLIPBOARD_READ) {
181 if (!base::FeatureList::IsEnabled(features::kClipboardContentSetting))
182 return false;
183 }
184
Patti749d4d12017-10-11 06:20:30185#if defined(OS_ANDROID)
186 // Special geolocation DSE settings apply only on Android, so make sure it
187 // gets checked there regardless of default setting on Desktop.
188 if (info.type == CONTENT_SETTINGS_TYPE_GEOLOCATION)
189 return true;
Pattid7c4d542017-12-07 00:54:14190#else
Patti8c57f37d2018-01-31 04:33:21191 // Flash is shown if the user has ever changed its setting for |site_url|.
192 if (info.type == CONTENT_SETTINGS_TYPE_PLUGINS &&
193 content_settings->GetWebsiteSetting(site_url, site_url,
194 CONTENT_SETTINGS_TYPE_PLUGINS_DATA,
195 std::string(), nullptr) != nullptr) {
Pattid7c4d542017-12-07 00:54:14196 return true;
Patti8c57f37d2018-01-31 04:33:21197 }
Patti749d4d12017-10-11 06:20:30198#endif
199
Patti0601e532017-09-20 08:39:30200#if !defined(OS_ANDROID)
201 // Autoplay is Android-only at the moment.
202 if (info.type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
203 return false;
204#endif
205
shahriar rostamia9c769d2017-12-06 04:54:08206 // Show the content setting if it has been changed by the user since the last
207 // page load.
208 if (tab_specific_content_settings->HasContentSettingChangedViaPageInfo(
209 info.type)) {
210 return true;
211 }
212
213 // Show the content setting when it has a non-default value.
214 if (!IsPermissionFactoryDefault(content_settings, info))
215 return true;
216
217 return false;
mgiucaa319f212016-01-14 03:30:11218}
219
esecklercac56b62016-11-16 13:49:44220void CheckContentStatus(security_state::ContentStatus content_status,
estark00e83f12016-08-19 18:24:04221 bool* displayed,
222 bool* ran) {
223 switch (content_status) {
esecklercac56b62016-11-16 13:49:44224 case security_state::CONTENT_STATUS_DISPLAYED:
estark00e83f12016-08-19 18:24:04225 *displayed = true;
226 break;
esecklercac56b62016-11-16 13:49:44227 case security_state::CONTENT_STATUS_RAN:
estark00e83f12016-08-19 18:24:04228 *ran = true;
229 break;
esecklercac56b62016-11-16 13:49:44230 case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN:
estark00e83f12016-08-19 18:24:04231 *displayed = true;
232 *ran = true;
233 break;
esecklercac56b62016-11-16 13:49:44234 case security_state::CONTENT_STATUS_UNKNOWN:
235 case security_state::CONTENT_STATUS_NONE:
estark00e83f12016-08-19 18:24:04236 break;
237 }
238}
239
elawrenceb2ac2a232017-03-27 21:46:25240// If the |security_info| indicates that mixed content or certificate errors
241// were present, update |connection_status| and |connection_details|.
242void ReportAnyInsecureContent(const security_state::SecurityInfo& security_info,
thestig4427f13b2017-06-20 20:42:47243 PageInfo::SiteConnectionStatus* connection_status,
244 base::string16* connection_details) {
elawrenceb2ac2a232017-03-27 21:46:25245 bool displayed_insecure_content = false;
246 bool ran_insecure_content = false;
247 CheckContentStatus(security_info.mixed_content_status,
248 &displayed_insecure_content, &ran_insecure_content);
249 // Only note subresources with certificate errors if the main resource was
250 // loaded without major certificate errors. If the main resource had a
251 // certificate error, then it would not be that useful (and could
252 // potentially be confusing) to warn about subresources that had certificate
253 // errors too.
254 if (!net::IsCertStatusError(security_info.cert_status) ||
255 net::IsCertStatusMinorError(security_info.cert_status)) {
256 CheckContentStatus(security_info.content_with_cert_errors_status,
257 &displayed_insecure_content, &ran_insecure_content);
258 }
259
260 // Only one insecure content warning is displayed; show the most severe.
261 if (ran_insecure_content) {
thestig4427f13b2017-06-20 20:42:47262 *connection_status =
elawrenceb2ac2a232017-03-27 21:46:25263 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE;
thestig4427f13b2017-06-20 20:42:47264 connection_details->assign(l10n_util::GetStringFUTF16(
265 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25266 l10n_util::GetStringUTF16(
267 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR)));
estark00e83f12016-08-19 18:24:04268 return;
269 }
elawrenceb2ac2a232017-03-27 21:46:25270 if (security_info.contained_mixed_form) {
thestig4427f13b2017-06-20 20:42:47271 *connection_status = PageInfo::SITE_CONNECTION_STATUS_INSECURE_FORM_ACTION;
272 connection_details->assign(l10n_util::GetStringFUTF16(
273 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25274 l10n_util::GetStringUTF16(
275 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_FORM_WARNING)));
276 return;
277 }
278 if (displayed_insecure_content) {
thestig4427f13b2017-06-20 20:42:47279 *connection_status =
elawrenceb2ac2a232017-03-27 21:46:25280 PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
thestig4427f13b2017-06-20 20:42:47281 connection_details->assign(l10n_util::GetStringFUTF16(
282 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25283 l10n_util::GetStringUTF16(
284 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
285 }
estark00e83f12016-08-19 18:24:04286}
287
jshin1fb76462016-04-05 22:13:03288base::string16 GetSimpleSiteName(const GURL& url) {
benwells2337b8102016-04-20 01:53:53289 return url_formatter::FormatUrlForSecurityDisplay(
290 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
palmer153af982015-09-15 02:04:19291}
292
reillyg85f57db2016-01-12 23:14:38293ChooserContextBase* GetUsbChooserContext(Profile* profile) {
294 return UsbChooserContextFactory::GetForProfile(profile);
295}
296
297// The list of chooser types that need to display entries in the Website
298// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
299// email [email protected].
Andrew Grieved1978b0e2017-07-28 15:53:41300const PageInfo::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52301 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
Patti1d8a4312018-01-19 06:36:11302 IDS_PAGE_INFO_USB_DEVICE_LABEL, IDS_PAGE_INFO_USB_DEVICE_SECONDARY_LABEL,
303 IDS_PAGE_INFO_DELETE_USB_DEVICE, "name"},
reillyg85f57db2016-01-12 23:14:38304};
305
Christopher Thompson0c4e06c22018-07-11 22:29:59306// Time open histogram prefixes.
307const char kPageInfoTimePrefix[] = "Security.PageInfo.TimeOpen";
308const char kPageInfoTimeActionPrefix[] = "Security.PageInfo.TimeOpen.Action";
309const char kPageInfoTimeNoActionPrefix[] =
310 "Security.PageInfo.TimeOpen.NoAction";
311
312std::string GetHistogramSuffixForSecurityLevel(
313 security_state::SecurityLevel level) {
314 switch (level) {
315 case security_state::EV_SECURE:
316 return "EV_SECURE";
317 case security_state::SECURE:
318 return "SECURE";
319 case security_state::NONE:
320 return "NONE";
321 case security_state::HTTP_SHOW_WARNING:
322 return "HTTP_SHOW_WARNING";
323 case security_state::SECURE_WITH_POLICY_INSTALLED_CERT:
324 return "SECURE_WITH_POLICY_INSTALLED_CERT";
325 case security_state::DANGEROUS:
326 return "DANGEROUS";
327 default:
328 return "OTHER";
329 }
330}
331
332std::string GetHistogramName(const char* prefix,
333 security_state::SecurityLevel level) {
334 return std::string(prefix) + "." + GetHistogramSuffixForSecurityLevel(level);
335}
336
[email protected]0b9fdd72012-04-04 10:00:33337} // namespace
338
lgarron617a30f32017-03-24 21:42:07339PageInfo::PageInfo(PageInfoUI* ui,
340 Profile* profile,
341 TabSpecificContentSettings* tab_specific_content_settings,
342 content::WebContents* web_contents,
343 const GURL& url,
344 const security_state::SecurityInfo& security_info)
[email protected]df818272012-04-20 13:10:50345 : TabSpecificContentSettings::SiteDataObserver(
346 tab_specific_content_settings),
dominicknbdd53b5f2016-09-28 01:08:13347 content::WebContentsObserver(web_contents),
[email protected]df818272012-04-20 13:10:50348 ui_(ui),
[email protected]66f157312012-08-01 13:50:26349 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33350 site_url_(url),
351 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]03ef4b2a2012-03-06 15:04:20352 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
alshabalin5e894c12016-10-25 06:47:46353 show_ssl_decision_revoke_button_(false),
peconn5100d432015-09-16 12:03:08354 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04355 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25356 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19357 did_revoke_user_ssl_decisions_(false),
estark8d67cd7a2016-10-24 05:06:41358 profile_(profile),
Jialiu Lin11e18542017-08-14 18:16:26359 security_level_(security_state::NONE),
Jialiu Linfeb6bb32017-08-30 00:21:36360#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin0d8cc722017-09-19 01:01:51361 password_protection_service_(
362 safe_browsing::ChromePasswordProtectionService::
363 GetPasswordProtectionService(profile_)),
Jialiu Lin11e18542017-08-14 18:16:26364#endif
Christopher Thompson0c4e06c22018-07-11 22:29:59365 show_change_password_buttons_(false),
366 did_perform_action_(false) {
estarka3121f6b2015-09-18 21:15:59367 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33368
369 PresentSitePermissions();
[email protected]24c8818c2012-04-25 09:57:41370 PresentSiteIdentity();
Pattie8c616202017-09-29 07:58:03371 PresentSiteData();
[email protected]e22d64f2012-09-10 09:03:23372
lgarron617a30f32017-03-24 21:42:07373 // Every time the Page Info UI is opened a |PageInfo| object is
374 // created. So this counts how ofter the Page Info UI is opened.
375 RecordPageInfoAction(PAGE_INFO_OPENED);
Christopher Thompson0c4e06c22018-07-11 22:29:59376
377 // Record the time when the Page Info UI is opened so the total time it is
378 // open can be measured.
379 start_time_ = base::TimeTicks::Now();
[email protected]03ef4b2a2012-03-06 15:04:20380}
381
Carlos ILe5dfda72017-09-21 02:33:05382PageInfo::~PageInfo() {
383 // Check if Re-enable warnings button was visible, if so, log on UMA whether
384 // it was clicked or not.
385 SSLCertificateDecisionsDidRevoke user_decision =
386 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
387 : USER_CERT_DECISIONS_NOT_REVOKED;
388 if (show_ssl_decision_revoke_button_) {
389 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions2",
390 user_decision,
391 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
392 }
Christopher Thompson0c4e06c22018-07-11 22:29:59393
394 // Record the total time the Page Info UI was open for all opens as well as
395 // split between whether any action was taken.
396 base::UmaHistogramCustomTimes(
397 GetHistogramName(kPageInfoTimePrefix, security_level_),
398 base::TimeTicks::Now() - start_time_,
399 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), 100);
400 if (did_perform_action_) {
401 base::UmaHistogramCustomTimes(
402 GetHistogramName(kPageInfoTimeActionPrefix, security_level_),
403 base::TimeTicks::Now() - start_time_,
404 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1),
405 100);
406 } else {
407 base::UmaHistogramCustomTimes(
408 GetHistogramName(kPageInfoTimeNoActionPrefix, security_level_),
409 base::TimeTicks::Now() - start_time_,
410 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1),
411 100);
412 }
Carlos ILe5dfda72017-09-21 02:33:05413}
[email protected]03ef4b2a2012-03-06 15:04:20414
lgarron617a30f32017-03-24 21:42:07415void PageInfo::RecordPageInfoAction(PageInfoAction action) {
Christopher Thompson0c4e06c22018-07-11 22:29:59416 if (action != PAGE_INFO_OPENED)
417 did_perform_action_ = true;
418
lgarron617a30f32017-03-24 21:42:07419 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04420
estark8d67cd7a2016-10-24 05:06:41421 std::string histogram_name;
estark8d67cd7a2016-10-24 05:06:41422 if (site_url_.SchemeIsCryptographic()) {
Carlos ILcb2321112018-02-01 18:05:23423 if (security_level_ == security_state::SECURE) {
424 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.ValidNonEV",
425 action, PAGE_INFO_COUNT);
426 } else if (security_level_ == security_state::EV_SECURE) {
427 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.ValidEV",
lgarron617a30f32017-03-24 21:42:07428 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44429 } else if (security_level_ == security_state::NONE) {
estark8d67cd7a2016-10-24 05:06:41430 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded",
lgarron617a30f32017-03-24 21:42:07431 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44432 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41433 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07434 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41435 }
436 return;
437 }
438
esecklercac56b62016-11-16 13:49:44439 if (security_level_ == security_state::HTTP_SHOW_WARNING) {
estark8d67cd7a2016-10-24 05:06:41440 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning",
lgarron617a30f32017-03-24 21:42:07441 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44442 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41443 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07444 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41445 } else {
446 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral",
lgarron617a30f32017-03-24 21:42:07447 action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04448 }
449}
450
lgarron617a30f32017-03-24 21:42:07451void PageInfo::OnSitePermissionChanged(ContentSettingsType type,
452 ContentSetting setting) {
shahriar rostamia9c769d2017-12-06 04:54:08453 tab_specific_content_settings()->ContentSettingChangedViaPageInfo(type);
454
[email protected]e22d64f2012-09-10 09:03:23455 // Count how often a permission for a specific content type is changed using
lgarron617a30f32017-03-24 21:42:07456 // the Page Info UI.
raymes4a13d432015-09-08 00:44:07457 size_t num_values;
458 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
dchengf6f4e4942017-03-30 23:55:57459 UMA_HISTOGRAM_EXACT_LINEAR("WebsiteSettings.OriginInfo.PermissionChanged",
460 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56461
462 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
dchengf6f4e4942017-03-30 23:55:57463 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56464 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07465 num_values);
tommycli34cf29bf2016-09-08 05:46:25466
467 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
468 rappor::SampleDomainAndRegistryFromGURL(
469 g_browser_process->rappor_service(),
470 "ContentSettings.Plugins.AddedAllowException", site_url_);
471 }
sashab9debecd2014-12-18 04:15:56472 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
dchengf6f4e4942017-03-30 23:55:57473 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56474 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07475 num_values);
sashab9debecd2014-12-18 04:15:56476 }
[email protected]e22d64f2012-09-10 09:03:23477
lgarron04a93502014-11-04 22:25:04478 // This is technically redundant given the histogram above, but putting the
479 // total count of permission changes in another histogram makes it easier to
lgarron026e9c42017-04-07 20:09:31480 // compare it against other kinds of actions in Page Info.
lgarron617a30f32017-03-24 21:42:07481 RecordPageInfoAction(PAGE_INFO_CHANGED_PERMISSION);
Tommy Steimeldea90f72017-11-07 20:58:03482 if (type == CONTENT_SETTINGS_TYPE_SOUND) {
483 ContentSetting default_setting =
484 content_settings_->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_SOUND,
485 nullptr);
486 bool mute = (setting == CONTENT_SETTING_BLOCK) ||
487 (setting == CONTENT_SETTING_DEFAULT &&
488 default_setting == CONTENT_SETTING_BLOCK);
489 if (mute) {
490 base::RecordAction(
491 base::UserMetricsAction("SoundContentSetting.MuteBy.PageInfo"));
492 } else {
493 base::RecordAction(
494 base::UserMetricsAction("SoundContentSetting.UnmuteBy.PageInfo"));
495 }
496 }
lgarron04a93502014-11-04 22:25:04497
stefanocs8b3490cc2016-07-28 05:32:52498 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
patricialor7131c1fe2017-04-07 01:25:52499 profile_, site_url_, site_url_, type, PermissionSourceUI::OIB);
stefanocs8b3490cc2016-07-28 05:32:52500
patricialor7131c1fe2017-04-07 01:25:52501 // The permission may have been blocked due to being under embargo, so if it
502 // was changed away from BLOCK, clear embargo status if it exists.
503 if (setting != CONTENT_SETTING_BLOCK) {
504 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveEmbargoByUrl(
505 site_url_, type);
506 }
raymesfbaaaaa2015-11-10 02:20:40507 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
508 setting);
[email protected]df818272012-04-20 13:10:50509
Tommy Steimel97ee2f82017-11-01 21:39:52510 // When the sound setting is changed, no reload is necessary.
511 if (type != CONTENT_SETTINGS_TYPE_SOUND)
512 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24513
514 // Refresh the UI to reflect the new setting.
515 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50516}
517
lgarron617a30f32017-03-24 21:42:07518void PageInfo::OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info,
519 const base::DictionaryValue& object) {
reillyg85f57db2016-01-12 23:14:38520 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
521 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10522 const GURL origin = site_url_.GetOrigin();
523 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38524 show_info_bar_ = true;
525
526 // Refresh the UI to reflect the changed settings.
527 PresentSitePermissions();
528}
529
lgarron617a30f32017-03-24 21:42:07530void PageInfo::OnSiteDataAccessed() {
[email protected]df818272012-04-20 13:10:50531 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33532}
533
lgarron617a30f32017-03-24 21:42:07534void PageInfo::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49535#if defined(OS_ANDROID)
536 NOTREACHED();
537#else
dominicknbdd53b5f2016-09-28 01:08:13538 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
palmerf2cba0d2015-08-27 23:15:06539 InfoBarService* infobar_service =
dominicknbdd53b5f2016-09-28 01:08:13540 InfoBarService::FromWebContents(web_contents());
palmerf2cba0d2015-08-27 23:15:06541 if (infobar_service)
lgarron617a30f32017-03-24 21:42:07542 PageInfoInfoBarDelegate::Create(infobar_service);
palmerf2cba0d2015-08-27 23:15:06543 }
estade3feb83f2015-09-01 23:00:49544#endif
jww1ed8ea72014-09-02 20:43:25545}
546
lgarron617a30f32017-03-24 21:42:07547void PageInfo::OnRevokeSSLErrorBypassButtonPressed() {
jww1ed8ea72014-09-02 20:43:25548 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29549 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
550 site_url().host());
jww1ed8ea72014-09-02 20:43:25551 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26552}
553
Patricia Lora21a04cf2017-06-05 02:53:29554void PageInfo::OpenSiteSettingsView() {
Christopher Lam0dbac2b2017-11-14 07:12:10555#if defined(OS_ANDROID)
556 NOTREACHED();
557#else
558 chrome::ShowSiteSettings(chrome::FindBrowserWithWebContents(web_contents()),
559 site_url());
Patricia Lora21a04cf2017-06-05 02:53:29560 RecordPageInfoAction(PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED);
Christopher Lam0dbac2b2017-11-14 07:12:10561#endif
Patricia Lora21a04cf2017-06-05 02:53:29562}
563
Jialiu Lin11e18542017-08-14 18:16:26564void PageInfo::OnChangePasswordButtonPressed(
565 content::WebContents* web_contents) {
Jialiu Linfeb6bb32017-08-30 00:21:36566#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26567 DCHECK(password_protection_service_);
Jialiu Lind7defe652018-06-20 18:47:06568 DCHECK(site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE ||
569 site_identity_status_ ==
570 SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE);
Jialiu Lin3fc7f38f2017-09-21 18:38:37571 password_protection_service_->OnUserAction(
Jialiu Lind7defe652018-06-20 18:47:06572 web_contents,
573 site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE
574 ? PasswordReuseEvent::SIGN_IN_PASSWORD
575 : PasswordReuseEvent::ENTERPRISE_PASSWORD,
576 safe_browsing::PasswordProtectionService::PAGE_INFO,
Jialiu Lin11e18542017-08-14 18:16:26577 safe_browsing::PasswordProtectionService::CHANGE_PASSWORD);
578#endif
579}
580
581void PageInfo::OnWhitelistPasswordReuseButtonPressed(
582 content::WebContents* web_contents) {
Jialiu Linfeb6bb32017-08-30 00:21:36583#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26584 DCHECK(password_protection_service_);
Jialiu Lind7defe652018-06-20 18:47:06585 DCHECK(site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE ||
586 site_identity_status_ ==
587 SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE);
Jialiu Lin3fc7f38f2017-09-21 18:38:37588 password_protection_service_->OnUserAction(
Jialiu Lind7defe652018-06-20 18:47:06589 web_contents,
590 site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE
591 ? PasswordReuseEvent::SIGN_IN_PASSWORD
592 : PasswordReuseEvent::ENTERPRISE_PASSWORD,
593 safe_browsing::PasswordProtectionService::PAGE_INFO,
Jialiu Lin11e18542017-08-14 18:16:26594 safe_browsing::PasswordProtectionService::MARK_AS_LEGITIMATE);
595#endif
596}
597
lgarron617a30f32017-03-24 21:42:07598void PageInfo::Init(const GURL& url,
599 const security_state::SecurityInfo& security_info) {
thestig0c55ee32017-06-20 22:17:51600#if !defined(OS_ANDROID)
meacerde53fcff2016-10-12 19:21:57601 // On desktop, internal URLs aren't handled by this class. Instead, a
lgarron026e9c42017-04-07 20:09:31602 // custom and simpler bubble is shown.
meacerde53fcff2016-10-12 19:21:57603 DCHECK(!url.SchemeIs(content::kChromeUIScheme) &&
604 !url.SchemeIs(content::kChromeDevToolsScheme) &&
605 !url.SchemeIs(content::kViewSourceScheme) &&
606 !url.SchemeIs(content_settings::kExtensionScheme));
607#endif
608
thestig0c55ee32017-06-20 22:17:51609 bool is_chrome_ui_native_scheme = false;
zpengdb4a58e2017-01-10 17:40:32610#if defined(OS_ANDROID)
thestig0c55ee32017-06-20 22:17:51611 is_chrome_ui_native_scheme = url.SchemeIs(chrome::kChromeUINativeScheme);
sashab97894ce2014-10-22 10:08:33612#endif
613
estark8d67cd7a2016-10-24 05:06:41614 security_level_ = security_info.security_level;
615
upendrag.gowda60886a6e2015-10-31 05:51:09616 if (url.SchemeIs(url::kAboutScheme)) {
617 // All about: URLs except about:blank are redirected.
618 DCHECK_EQ(url::kAboutBlankURL, url.spec());
619 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
620 site_identity_details_ =
621 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
622 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
623 site_connection_details_ = l10n_util::GetStringFUTF16(
624 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
625 UTF8ToUTF16(url.spec()));
626 return;
627 }
628
thestig0c55ee32017-06-20 22:17:51629 if (url.SchemeIs(content::kChromeUIScheme) || is_chrome_ui_native_scheme) {
[email protected]03ef4b2a2012-03-06 15:04:20630 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
631 site_identity_details_ =
632 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
633 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
634 return;
635 }
636
[email protected]03ef4b2a2012-03-06 15:04:20637 // Identity section.
jam8ae7cad2016-09-08 23:55:21638 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11639
estarkfcfccdb82016-11-14 02:17:29640 if (security_info.malicious_content_status !=
esecklercac56b62016-11-16 13:49:44641 security_state::MALICIOUS_CONTENT_STATUS_NONE) {
estarkfcfccdb82016-11-14 02:17:29642 // The site has been flagged by Safe Browsing as dangerous.
643 GetSiteIdentityByMaliciousContentStatus(
644 security_info.malicious_content_status, &site_identity_status_,
645 &site_identity_details_);
Jialiu Lin11e18542017-08-14 18:16:26646 show_change_password_buttons_ =
Jialiu Lind7defe652018-06-20 18:47:06647 (security_info.malicious_content_status ==
648 security_state::MALICIOUS_CONTENT_STATUS_SIGN_IN_PASSWORD_REUSE ||
649 security_info.malicious_content_status ==
650 security_state::
651 MALICIOUS_CONTENT_STATUS_ENTERPRISE_PASSWORD_REUSE);
estarkfcfccdb82016-11-14 02:17:29652 } else if (certificate_ &&
653 (!net::IsCertStatusError(security_info.cert_status) ||
654 net::IsCertStatusMinorError(security_info.cert_status))) {
655 // HTTPS with no or minor errors.
estarka3121f6b2015-09-18 21:15:59656 if (security_info.security_level ==
esecklercac56b62016-11-16 13:49:44657 security_state::SECURE_WITH_POLICY_INSTALLED_CERT) {
Eric Lawrence6758d1d2017-11-21 16:06:05658#if defined(OS_CHROMEOS)
[email protected]eaf3f322013-04-25 21:53:59659 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37660 site_identity_details_ = l10n_util::GetStringFUTF16(
661 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
Eric Lawrence6758d1d2017-11-21 16:06:05662#else
663 DCHECK(false) << "Policy certificates exist only on ChromeOS";
664#endif
estarka3121f6b2015-09-18 21:15:59665 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20666 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21667 base::string16 issuer_name(
668 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20669 if (issuer_name.empty()) {
670 issuer_name.assign(l10n_util::GetStringUTF16(
671 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
672 }
[email protected]94c74b42013-12-02 15:19:49673
[email protected]03ef4b2a2012-03-06 15:04:20674 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39675 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20676
677 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59678 if (security_info.cert_status &
679 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20680 site_identity_details_ += l10n_util::GetStringUTF16(
681 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59682 } else if (security_info.cert_status &
683 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20684 site_identity_details_ += l10n_util::GetStringUTF16(
685 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
686 } else {
687 NOTREACHED() << "Need to specify string for this warning";
688 }
[email protected]03ef4b2a2012-03-06 15:04:20689 } else {
estarkcf305562016-11-15 03:45:39690 // No major or minor errors.
estarka3121f6b2015-09-18 21:15:59691 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01692 // EV HTTPS page.
estarkcf305562016-11-15 03:45:39693 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
jam8ae7cad2016-09-08 23:55:21694 DCHECK(!certificate_->subject().organization_names.empty());
695 organization_name_ =
696 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01697 // An EV Cert is required to have a city (localityName) and country but
698 // state is "if any".
jam8ae7cad2016-09-08 23:55:21699 DCHECK(!certificate_->subject().locality_name.empty());
700 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01701 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21702 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01703 locality = l10n_util::GetStringFUTF16(
lgarronfc1d5e52017-05-03 23:15:21704 IDS_PAGE_INFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21705 UTF8ToUTF16(certificate_->subject().locality_name),
706 UTF8ToUTF16(certificate_->subject().state_or_province_name),
707 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01708 } else {
709 locality = l10n_util::GetStringFUTF16(
lgarronfc1d5e52017-05-03 23:15:21710 IDS_PAGE_INFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21711 UTF8ToUTF16(certificate_->subject().locality_name),
712 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01713 }
jam8ae7cad2016-09-08 23:55:21714 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01715 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39716 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED,
jam8ae7cad2016-09-08 23:55:21717 UTF8ToUTF16(certificate_->subject().organization_names[0]),
estarkcf305562016-11-15 03:45:39718 locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01719 } else {
720 // Non-EV OK HTTPS page.
estarkcf305562016-11-15 03:45:39721 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
rsleevi4f8012722014-09-30 01:28:01722 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21723 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01724 if (issuer_name.empty()) {
725 issuer_name.assign(l10n_util::GetStringUTF16(
726 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
727 }
[email protected]94c74b42013-12-02 15:19:49728
rsleevi4f8012722014-09-30 01:28:01729 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39730 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
rsleevi4f8012722014-09-30 01:28:01731 }
elawrencebe87bd62017-01-10 16:08:59732 if (security_info.sha1_in_chain) {
733 site_identity_status_ =
734 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM;
735 site_identity_details_ +=
736 UTF8ToUTF16("\n\n") +
737 l10n_util::GetStringUTF16(
738 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM);
rsleevi4f8012722014-09-30 01:28:01739 }
[email protected]03ef4b2a2012-03-06 15:04:20740 }
741 } else {
742 // HTTP or HTTPS with errors (not warnings).
743 site_identity_details_.assign(l10n_util::GetStringUTF16(
744 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
jam8ae7cad2016-09-08 23:55:21745 if (!security_info.scheme_is_cryptographic || !security_info.certificate)
[email protected]03ef4b2a2012-03-06 15:04:20746 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
747 else
748 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
749
[email protected]a04db822013-12-11 19:14:40750 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59751 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59752 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
jam8ae7cad2016-09-08 23:55:21753 certificate_, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20754 for (size_t i = 0; i < errors.size(); ++i) {
755 site_identity_details_ += bullet;
756 site_identity_details_ += errors[i].short_description();
757 }
758
estarka3121f6b2015-09-18 21:15:59759 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20760 site_identity_details_ += ASCIIToUTF16("\n\n");
lgarron1a6300d2017-03-18 03:33:04761 site_identity_details_ +=
762 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
[email protected]03ef4b2a2012-03-06 15:04:20763 }
764 }
765
766 // Site Connection
767 // We consider anything less than 80 bits encryption to be weak encryption.
768 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
769 // weakly encrypted connections.
770 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
771
jshin1fb76462016-04-05 22:13:03772 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19773 if (subject_name.empty()) {
774 subject_name.assign(
775 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
776 }
777
jam8ae7cad2016-09-08 23:55:21778 if (!security_info.certificate || !security_info.scheme_is_cryptographic) {
estarka3121f6b2015-09-18 21:15:59779 // Page is still loading (so SSL status is not yet available) or
780 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58781 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
782
783 site_connection_details_.assign(l10n_util::GetStringFUTF16(
784 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
785 subject_name));
estarka3121f6b2015-09-18 21:15:59786 } else if (security_info.security_bits < 0) {
787 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20788 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59789 } else if (security_info.security_bits == 0) {
esecklercac56b62016-11-16 13:49:44790 DCHECK_NE(security_info.security_level, security_state::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20791 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
792 site_connection_details_.assign(l10n_util::GetStringFUTF16(
793 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
794 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20795 } else {
796 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22797
lgarron3e2c33e2016-08-25 06:33:43798 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22799 site_connection_details_.assign(l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04800 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, subject_name));
Adam Langley71c2b59b2014-11-13 00:34:22801 } else {
802 site_connection_details_.assign(l10n_util::GetStringFUTF16(
803 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
804 subject_name));
805 }
806
thestig4427f13b2017-06-20 20:42:47807 ReportAnyInsecureContent(security_info, &site_connection_status_,
808 &site_connection_details_);
[email protected]03ef4b2a2012-03-06 15:04:20809 }
810
avi655876a2015-12-25 07:18:15811 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59812 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
813 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20814 int ssl_version =
estarka3121f6b2015-09-18 21:15:59815 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20816 const char* ssl_version_str;
817 net::SSLVersionToString(&ssl_version_str, ssl_version);
818 site_connection_details_ += ASCIIToUTF16("\n\n");
819 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04820 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, ASCIIToUTF16(ssl_version_str));
[email protected]03ef4b2a2012-03-06 15:04:20821
[email protected]03ef4b2a2012-03-06 15:04:20822 const char *key_exchange, *cipher, *mac;
davidben56a8aece2016-10-14 18:20:56823 bool is_aead, is_tls13;
824 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
825 &is_tls13, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20826
827 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57828 if (is_aead) {
davidben56a8aece2016-10-14 18:20:56829 if (is_tls13) {
830 // For TLS 1.3 ciphers, report the group (historically, curve) as the
831 // key exchange.
832 key_exchange = SSL_get_curve_name(security_info.key_exchange_group);
833 if (!key_exchange) {
834 NOTREACHED();
835 key_exchange = "";
836 }
837 }
[email protected]b6c1d9e82013-06-12 17:26:57838 site_connection_details_ += l10n_util::GetStringFUTF16(
839 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
840 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
841 } else {
842 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04843 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, ASCIIToUTF16(cipher),
844 ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
[email protected]b6c1d9e82013-06-12 17:26:57845 }
[email protected]03ef4b2a2012-03-06 15:04:20846 }
[email protected]e583f752012-08-30 13:26:21847
[email protected]71cd5ef2014-08-13 21:22:04848 // Check if a user decision has been made to allow or deny certificates with
849 // errors on this site.
850 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50851 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04852 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40853 // Only show an SSL decision revoke button if the user has chosen to bypass
854 // SSL host errors for this host in the past.
855 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]03ef4b2a2012-03-06 15:04:20856}
[email protected]0b9fdd72012-04-04 10:00:33857
lgarron617a30f32017-03-24 21:42:07858void PageInfo::PresentSitePermissions() {
[email protected]df818272012-04-20 13:10:50859 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38860 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50861
lgarron617a30f32017-03-24 21:42:07862 PageInfoUI::PermissionInfo permission_info;
[email protected]df818272012-04-20 13:10:50863 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
864 permission_info.type = kPermissionType[i];
865
866 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32867 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
868 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21869 DCHECK(value.get());
jdoerrie76cee9c2017-10-06 22:42:42870 if (value->type() == base::Value::Type::INTEGER) {
sashab2b2a314f2015-01-17 06:42:21871 permission_info.setting =
872 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26873 } else {
sashab2b2a314f2015-01-17 06:42:21874 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26875 }
876
[email protected]8bdf45c32012-08-04 00:12:55877 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28878 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50879
[email protected]b1d113d2012-06-27 21:27:34880 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21881 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34882 permission_info.default_setting = permission_info.setting;
883 permission_info.setting = CONTENT_SETTING_DEFAULT;
884 } else {
885 permission_info.default_setting =
886 content_settings_->GetDefaultContentSetting(permission_info.type,
887 NULL);
[email protected]df818272012-04-20 13:10:50888 }
palmer0da10b32015-02-11 00:42:19889
patricialor2a4f41a2017-03-08 02:52:56890 // For permissions that are still prompting the user and haven't been
891 // explicitly set by another source, check its embargo status.
892 if (PermissionUtil::IsPermission(permission_info.type) &&
893 permission_info.setting == CONTENT_SETTING_DEFAULT &&
894 permission_info.source ==
895 content_settings::SettingSource::SETTING_SOURCE_USER) {
896 // TODO(raymes): Use GetPermissionStatus() to retrieve information
897 // about *all* permissions once it has default behaviour implemented for
898 // ContentSettingTypes that aren't permissions.
899 PermissionResult permission_result =
900 PermissionManager::Get(profile_)->GetPermissionStatus(
901 permission_info.type, site_url_, site_url_);
902
903 // If under embargo, update |permission_info| to reflect that.
904 if (permission_result.content_setting == CONTENT_SETTING_BLOCK &&
Timothy Loh8fbdac52018-03-15 03:34:30905 permission_result.source ==
906 PermissionStatusSource::MULTIPLE_DISMISSALS) {
patricialor2a4f41a2017-03-08 02:52:56907 permission_info.setting = permission_result.content_setting;
Timothy Loh8fbdac52018-03-15 03:34:30908 }
patricialor2a4f41a2017-03-08 02:52:56909 }
910
Tommy Steimelc9f6c932017-10-13 23:33:04911 if (ShouldShowPermission(permission_info, site_url_, content_settings_,
shahriar rostamia9c769d2017-12-06 04:54:08912 web_contents(), tab_specific_content_settings())) {
Patti0601e532017-09-20 08:39:30913 permission_info_list.push_back(permission_info);
Tommy Steimelc9f6c932017-10-13 23:33:04914 }
[email protected]df818272012-04-20 13:10:50915 }
916
reillyg85f57db2016-01-12 23:14:38917 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
918 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10919 const GURL origin = site_url_.GetOrigin();
Reilly Granta69ab672018-04-06 18:26:07920
921 // Hide individual object permissions because when the chooser is blocked
922 // previously granted device permissions are also ignored.
923 if (!context->CanRequestObjectPermission(origin, origin))
924 continue;
925
reillyg36a7fab32016-01-28 19:15:10926 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32927 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38928 chosen_object_info_list.push_back(
Jinho Bangcc280792018-01-17 23:33:55929 std::make_unique<PageInfoUI::ChosenObjectInfo>(ui_info,
lgarron617a30f32017-03-24 21:42:07930 std::move(object)));
reillyg85f57db2016-01-12 23:14:38931 }
932 }
933
avi09dd4d02016-10-14 20:40:09934 ui_->SetPermissionInfo(permission_info_list,
935 std::move(chosen_object_info_list));
[email protected]0b9fdd72012-04-04 10:00:33936}
937
lgarron617a30f32017-03-24 21:42:07938void PageInfo::PresentSiteData() {
[email protected]df818272012-04-20 13:10:50939 CookieInfoList cookie_info_list;
vabrbab3ffcb2016-10-04 10:08:10940 const LocalSharedObjectsContainer& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34941 tab_specific_content_settings()->allowed_local_shared_objects();
vabrbab3ffcb2016-10-04 10:08:10942 const LocalSharedObjectsContainer& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34943 tab_specific_content_settings()->blocked_local_shared_objects();
944
945 // Add first party cookie and site data counts.
lgarron617a30f32017-03-24 21:42:07946 PageInfoUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34947 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
948 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15949 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34950 cookie_info_list.push_back(cookie_info);
951
952 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34953 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
954 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15955 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50956 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33957
[email protected]df818272012-04-20 13:10:50958 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33959}
[email protected]16de6de2012-04-04 12:24:14960
lgarron617a30f32017-03-24 21:42:07961void PageInfo::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04962 // After initialization the status about the site's connection and its
963 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41964 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
965 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
lgarron617a30f32017-03-24 21:42:07966 PageInfoUI::IdentityInfo info;
[email protected]24c8818c2012-04-25 09:57:41967 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
968 info.site_identity = UTF16ToUTF8(organization_name());
969 else
jshin1fb76462016-04-05 22:13:03970 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41971
972 info.connection_status = site_connection_status_;
lgarron1a6300d2017-03-18 03:33:04973 info.connection_status_description = UTF16ToUTF8(site_connection_details_);
[email protected]24c8818c2012-04-25 09:57:41974 info.identity_status = site_identity_status_;
lgarron1a6300d2017-03-18 03:33:04975 info.identity_status_description = UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21976 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04977 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
Jialiu Lin11e18542017-08-14 18:16:26978 info.show_change_password_buttons = show_change_password_buttons_;
[email protected]24c8818c2012-04-25 09:57:41979 ui_->SetIdentityInfo(info);
Jialiu Linfeb6bb32017-08-30 00:21:36980#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lin11e18542017-08-14 18:16:26981 if (password_protection_service_ && show_change_password_buttons_) {
Jialiu Lind7defe652018-06-20 18:47:06982 if (site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE) {
983 password_protection_service_->RecordWarningAction(
984 safe_browsing::PasswordProtectionService::PAGE_INFO,
985 safe_browsing::PasswordProtectionService::SHOWN,
986 safe_browsing::LoginReputationClientRequest::PasswordReuseEvent::
987 SIGN_IN_PASSWORD);
988 } else {
989 password_protection_service_->RecordWarningAction(
990 safe_browsing::PasswordProtectionService::PAGE_INFO,
991 safe_browsing::PasswordProtectionService::SHOWN,
992 safe_browsing::LoginReputationClientRequest::PasswordReuseEvent::
993 ENTERPRISE_PASSWORD);
994 }
Jialiu Lin11e18542017-08-14 18:16:26995 }
996#endif
[email protected]24c8818c2012-04-25 09:57:41997}
Patti7f21c4b2017-11-28 03:37:17998
999std::vector<ContentSettingsType> PageInfo::GetAllPermissionsForTesting() {
1000 std::vector<ContentSettingsType> permission_list;
1001 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
1002#if !defined(OS_ANDROID)
1003 if (kPermissionType[i] == CONTENT_SETTINGS_TYPE_AUTOPLAY)
1004 continue;
1005#endif
1006 permission_list.push_back(kPermissionType[i]);
1007 }
1008 return permission_list;
1009}
Jialiu Lin4d7c6042018-04-04 17:45:351010
1011void PageInfo::GetSiteIdentityByMaliciousContentStatus(
1012 security_state::MaliciousContentStatus malicious_content_status,
1013 PageInfo::SiteIdentityStatus* status,
1014 base::string16* details) {
1015 switch (malicious_content_status) {
1016 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
1017 NOTREACHED();
1018 break;
1019 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
1020 *status = PageInfo::SITE_IDENTITY_STATUS_MALWARE;
1021 *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MALWARE_DETAILS);
1022 break;
1023 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
1024 *status = PageInfo::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
1025 *details =
1026 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SOCIAL_ENGINEERING_DETAILS);
1027 break;
1028 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
1029 *status = PageInfo::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
1030 *details =
1031 l10n_util::GetStringUTF16(IDS_PAGE_INFO_UNWANTED_SOFTWARE_DETAILS);
1032 break;
Jialiu Lind7defe652018-06-20 18:47:061033 case security_state::MALICIOUS_CONTENT_STATUS_SIGN_IN_PASSWORD_REUSE:
Jialiu Lin4d7c6042018-04-04 17:45:351034#if defined(SAFE_BROWSING_DB_LOCAL)
Jialiu Lind7defe652018-06-20 18:47:061035 *status = PageInfo::SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE;
1036 // |password_protection_service_| may be null in test.
1037 *details = password_protection_service_
1038 ? password_protection_service_->GetWarningDetailText(
1039 PasswordReuseEvent::SIGN_IN_PASSWORD)
1040 : base::string16();
1041#endif
1042 break;
1043 case security_state::MALICIOUS_CONTENT_STATUS_ENTERPRISE_PASSWORD_REUSE:
1044#if defined(SAFE_BROWSING_DB_LOCAL)
1045 *status = PageInfo::SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE;
1046 // |password_protection_service_| maybe null in test.
1047 *details = password_protection_service_
1048 ? password_protection_service_->GetWarningDetailText(
1049 PasswordReuseEvent::ENTERPRISE_PASSWORD)
1050 : base::string16();
Jialiu Lin4d7c6042018-04-04 17:45:351051#endif
1052 break;
1053 }
1054}