[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 1 | // 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 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 5 | #include "chrome/browser/ui/page_info/page_info.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 6 | |
avi | 655876a | 2015-12-25 07:18:15 | [diff] [blame] | 7 | #include <stddef.h> |
| 8 | #include <stdint.h> |
| 9 | |
Eric Lawrence | 6758d1d | 2017-11-21 16:06:05 | [diff] [blame] | 10 | #include <memory> |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 11 | #include <string> |
Eric Lawrence | 6758d1d | 2017-11-21 16:06:05 | [diff] [blame] | 12 | #include <utility> |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 13 | #include <vector> |
| 14 | |
[email protected] | eb2140c | 2013-07-29 12:37:34 | [diff] [blame] | 15 | #include "base/command_line.h" |
[email protected] | 15b09254 | 2012-05-16 13:08:14 | [diff] [blame] | 16 | #include "base/i18n/time_formatting.h" |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 17 | #include "base/metrics/field_trial.h" |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 18 | #include "base/metrics/histogram_functions.h" |
asvitkine | 7503603 | 2016-09-01 20:49:34 | [diff] [blame] | 19 | #include "base/metrics/histogram_macros.h" |
Tommy Steimel | dea90f7 | 2017-11-07 20:58:03 | [diff] [blame] | 20 | #include "base/metrics/user_metrics.h" |
Avi Drissman | 22f8287 | 2018-12-25 23:09:07 | [diff] [blame^] | 21 | #include "base/stl_util.h" |
[email protected] | 3ea1b18 | 2013-02-08 22:38:41 | [diff] [blame] | 22 | #include "base/strings/string_number_conversions.h" |
[email protected] | 774cc3c | 2013-06-07 20:26:45 | [diff] [blame] | 23 | #include "base/strings/utf_string_conversions.h" |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 24 | #include "base/values.h" |
jialiul | 02aad2d | 2015-04-01 18:56:03 | [diff] [blame] | 25 | #include "chrome/browser/browser_process.h" |
[email protected] | b0cb5e8 | 2012-07-19 19:22:47 | [diff] [blame] | 26 | #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" |
peconn | 5100d43 | 2015-09-16 12:03:08 | [diff] [blame] | 31 | #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
vabr | bab3ffcb | 2016-10-04 10:08:10 | [diff] [blame] | 32 | #include "chrome/browser/content_settings/local_shared_objects_container.h" |
[email protected] | 77a91c7 | 2012-08-13 16:19:34 | [diff] [blame] | 33 | #include "chrome/browser/history/history_service_factory.h" |
palmer | f2cba0d | 2015-08-27 23:15:06 | [diff] [blame] | 34 | #include "chrome/browser/infobars/infobar_service.h" |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 35 | #include "chrome/browser/permissions/chooser_context_base.h" |
patricialor | 7131c1fe | 2017-04-07 01:25:52 | [diff] [blame] | 36 | #include "chrome/browser/permissions/permission_decision_auto_blocker.h" |
patricialor | 2a4f41a | 2017-03-08 02:52:56 | [diff] [blame] | 37 | #include "chrome/browser/permissions/permission_manager.h" |
| 38 | #include "chrome/browser/permissions/permission_result.h" |
tsergeant | f1e8935 | 2016-01-15 20:34:54 | [diff] [blame] | 39 | #include "chrome/browser/permissions/permission_uma_util.h" |
| 40 | #include "chrome/browser/permissions/permission_util.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 41 | #include "chrome/browser/profiles/profile.h" |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 42 | #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 43 | #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" |
| 44 | #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 45 | #include "chrome/browser/ui/page_info/page_info_ui.h" |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 46 | #include "chrome/browser/usb/usb_chooser_context.h" |
| 47 | #include "chrome/browser/usb/usb_chooser_context_factory.h" |
Patricia Lor | a21a04cf | 2017-06-05 02:53:29 | [diff] [blame] | 48 | #include "chrome/common/chrome_features.h" |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 49 | #include "chrome/common/chrome_switches.h" |
jsbell | ddb849e | 2015-08-27 00:12:56 | [diff] [blame] | 50 | #include "chrome/common/url_constants.h" |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 51 | #include "chrome/grit/theme_resources.h" |
Patti | 0601e53 | 2017-09-20 08:39:30 | [diff] [blame] | 52 | #include "components/content_settings/core/browser/content_settings_registry.h" |
mukai | 8eaec82 | 2014-10-25 17:53:16 | [diff] [blame] | 53 | #include "components/content_settings/core/browser/content_settings_utils.h" |
| 54 | #include "components/content_settings/core/browser/host_content_settings_map.h" |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 55 | #include "components/content_settings/core/common/content_settings.h" |
vasilii | f62dbf9 | 2014-09-05 10:23:13 | [diff] [blame] | 56 | #include "components/content_settings/core/common/content_settings_pattern.h" |
tbansal | 08a0e3e | 2017-06-30 21:30:08 | [diff] [blame] | 57 | #include "components/content_settings/core/common/content_settings_utils.h" |
nzolghadr | d87a308d | 2016-12-07 15:45:56 | [diff] [blame] | 58 | #include "components/rappor/public/rappor_utils.h" |
| 59 | #include "components/rappor/rappor_service_impl.h" |
felt | 2493b445 | 2015-09-17 20:33:59 | [diff] [blame] | 60 | #include "components/ssl_errors/error_info.h" |
thestig | 4a2e88e | 2016-08-27 23:23:51 | [diff] [blame] | 61 | #include "components/strings/grit/components_chromium_strings.h" |
| 62 | #include "components/strings/grit/components_strings.h" |
melandory | 7be36d31 | 2017-03-29 15:51:12 | [diff] [blame] | 63 | #include "components/subresource_filter/core/browser/subresource_filter_features.h" |
palmer | 153af98 | 2015-09-15 02:04:19 | [diff] [blame] | 64 | #include "components/url_formatter/elide_url.h" |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 65 | #include "content/public/browser/browser_thread.h" |
[email protected] | eb2140c | 2013-07-29 12:37:34 | [diff] [blame] | 66 | #include "content/public/common/content_switches.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 67 | #include "content/public/common/url_constants.h" |
[email protected] | 6e7845ae | 2013-03-29 21:48:11 | [diff] [blame] | 68 | #include "net/cert/cert_status_flags.h" |
| 69 | #include "net/cert/x509_certificate.h" |
[email protected] | 536fd0b | 2013-03-14 17:41:57 | [diff] [blame] | 70 | #include "net/ssl/ssl_cipher_suite_names.h" |
| 71 | #include "net/ssl/ssl_connection_status_flags.h" |
tfarina | 29a3a174 | 2016-10-28 18:47:33 | [diff] [blame] | 72 | #include "third_party/boringssl/src/include/openssl/ssl.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 73 | #include "ui/base/l10n/l10n_util.h" |
Patricia Lor | a21a04cf | 2017-06-05 02:53:29 | [diff] [blame] | 74 | #include "url/origin.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 75 | |
[email protected] | 24a9f1c9 | 2013-11-13 12:33:37 | [diff] [blame] | 76 | #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 | |
estade | 3feb83f | 2015-09-01 23:00:49 | [diff] [blame] | 81 | #if !defined(OS_ANDROID) |
Christopher Lam | 0dbac2b | 2017-11-14 07:12:10 | [diff] [blame] | 82 | #include "chrome/browser/ui/browser_finder.h" |
| 83 | #include "chrome/browser/ui/chrome_pages.h" |
mgiuca | a319f21 | 2016-01-14 03:30:11 | [diff] [blame] | 84 | #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 85 | #include "chrome/browser/ui/page_info/page_info_infobar_delegate.h" |
estade | 3feb83f | 2015-09-01 23:00:49 | [diff] [blame] | 86 | #endif |
| 87 | |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 88 | #if defined(SAFE_BROWSING_DB_LOCAL) |
Jialiu Lin | 0d8cc72 | 2017-09-19 01:01:51 | [diff] [blame] | 89 | #include "chrome/browser/safe_browsing/chrome_password_protection_service.h" |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 90 | #endif |
| 91 | |
[email protected] | ab6df3b1 | 2013-12-24 23:32:26 | [diff] [blame] | 92 | using base::ASCIIToUTF16; |
| 93 | using base::UTF8ToUTF16; |
[email protected] | f729d7a | 2013-12-26 07:07:56 | [diff] [blame] | 94 | using base::UTF16ToUTF8; |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 95 | using content::BrowserThread; |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 96 | #if defined(SAFE_BROWSING_DB_LOCAL) |
| 97 | using PasswordReuseEvent = |
| 98 | safe_browsing::LoginReputationClientRequest::PasswordReuseEvent; |
| 99 | #endif // SAFE_BROWSING_DB_LOCAL |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 100 | |
| 101 | namespace { |
| 102 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 103 | // The list of content settings types to display on the Page Info UI. THE |
csharrison | ad1eaa6c | 2017-05-11 17:14:38 | [diff] [blame] | 104 | // ORDER OF THESE ITEMS IS IMPORTANT and comes from https://crbug.com/610358. To |
| 105 | // propose changing it, email [email protected]. |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 106 | ContentSettingsType kPermissionType[] = { |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 107 | CONTENT_SETTINGS_TYPE_GEOLOCATION, |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 108 | CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
| 109 | CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
Alexander Shalamov | ce5aab5 | 2018-02-07 11:45:15 | [diff] [blame] | 110 | CONTENT_SETTINGS_TYPE_SENSORS, |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 111 | CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 112 | CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
lshang | e085f20 | 2016-06-14 01:25:08 | [diff] [blame] | 113 | #if !defined(OS_ANDROID) |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 114 | CONTENT_SETTINGS_TYPE_PLUGINS, |
| 115 | CONTENT_SETTINGS_TYPE_IMAGES, |
lshang | e085f20 | 2016-06-14 01:25:08 | [diff] [blame] | 116 | #endif |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 117 | CONTENT_SETTINGS_TYPE_POPUPS, |
Charles Harrison | 239d4798 | 2017-06-13 02:42:31 | [diff] [blame] | 118 | CONTENT_SETTINGS_TYPE_ADS, |
nsatragno | 670fe92 | 2016-04-08 14:10:50 | [diff] [blame] | 119 | CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, |
Tommy Steimel | a8c3757e | 2017-08-24 00:15:46 | [diff] [blame] | 120 | CONTENT_SETTINGS_TYPE_SOUND, |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 121 | CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, |
finnur | 46cafd4 | 2016-09-22 10:27:17 | [diff] [blame] | 122 | CONTENT_SETTINGS_TYPE_AUTOPLAY, |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 123 | CONTENT_SETTINGS_TYPE_MIDI_SYSEX, |
Gary Kacmarcik | 10533cf | 2017-11-22 03:31:28 | [diff] [blame] | 124 | CONTENT_SETTINGS_TYPE_CLIPBOARD_READ, |
Reilly Grant | a69ab67 | 2018-04-06 18:26:07 | [diff] [blame] | 125 | CONTENT_SETTINGS_TYPE_USB_GUARD, |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 126 | }; |
| 127 | |
Patti | 0601e53 | 2017-09-20 08:39:30 | [diff] [blame] | 128 | // 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). |
| 135 | bool 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 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 146 | // Determines whether to show permission |type| in the Page Info UI. Only |
mgiuca | a319f21 | 2016-01-14 03:30:11 | [diff] [blame] | 147 | // applies to permissions listed in |kPermissionType|. |
shahriar rostami | a9c769d | 2017-12-06 04:54:08 | [diff] [blame] | 148 | bool 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) { |
Patti | 0601e53 | 2017-09-20 08:39:30 | [diff] [blame] | 154 | // 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) { |
csharrison | ad1eaa6c | 2017-05-11 17:14:38 | [diff] [blame] | 157 | if (!base::FeatureList::IsEnabled( |
Charlie Harrison | b73f762 | 2018-06-01 14:24:34 | [diff] [blame] | 158 | subresource_filter::kSafeBrowsingSubresourceFilter)) { |
csharrison | ad1eaa6c | 2017-05-11 17:14:38 | [diff] [blame] | 159 | 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 Harrison | 239d4798 | 2017-06-13 02:42:31 | [diff] [blame] | 165 | site_url, GURL(), CONTENT_SETTINGS_TYPE_ADS_DATA, std::string(), |
| 166 | nullptr) != nullptr; |
melandory | 7be36d31 | 2017-03-29 15:51:12 | [diff] [blame] | 167 | } |
| 168 | |
Tommy Steimel | c9f6c93 | 2017-10-13 23:33:04 | [diff] [blame] | 169 | if (info.type == CONTENT_SETTINGS_TYPE_SOUND) { |
| 170 | if (!base::FeatureList::IsEnabled(features::kSoundContentSetting)) |
| 171 | return false; |
| 172 | |
Tommy Steimel | 1836051 | 2017-11-01 00:38:19 | [diff] [blame] | 173 | // The sound content setting should always show up when the tab has played |
| 174 | // audio. |
| 175 | if (web_contents && web_contents->WasEverAudible()) |
Tommy Steimel | c9f6c93 | 2017-10-13 23:33:04 | [diff] [blame] | 176 | return true; |
| 177 | } |
| 178 | |
Gary Kacmarcik | 10533cf | 2017-11-22 03:31:28 | [diff] [blame] | 179 | if (info.type == CONTENT_SETTINGS_TYPE_CLIPBOARD_READ) { |
| 180 | if (!base::FeatureList::IsEnabled(features::kClipboardContentSetting)) |
| 181 | return false; |
| 182 | } |
| 183 | |
Patti | 749d4d1 | 2017-10-11 06:20:30 | [diff] [blame] | 184 | #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; |
Patti | d7c4d54 | 2017-12-07 00:54:14 | [diff] [blame] | 189 | #else |
Patti | 8c57f37d | 2018-01-31 04:33:21 | [diff] [blame] | 190 | // 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) { |
Patti | d7c4d54 | 2017-12-07 00:54:14 | [diff] [blame] | 195 | return true; |
Patti | 8c57f37d | 2018-01-31 04:33:21 | [diff] [blame] | 196 | } |
Patti | 749d4d1 | 2017-10-11 06:20:30 | [diff] [blame] | 197 | #endif |
| 198 | |
Patti | 0601e53 | 2017-09-20 08:39:30 | [diff] [blame] | 199 | #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 rostami | a9c769d | 2017-12-06 04:54:08 | [diff] [blame] | 205 | // 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; |
mgiuca | a319f21 | 2016-01-14 03:30:11 | [diff] [blame] | 217 | } |
| 218 | |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 219 | void CheckContentStatus(security_state::ContentStatus content_status, |
estark | 00e83f1 | 2016-08-19 18:24:04 | [diff] [blame] | 220 | bool* displayed, |
| 221 | bool* ran) { |
| 222 | switch (content_status) { |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 223 | case security_state::CONTENT_STATUS_DISPLAYED: |
estark | 00e83f1 | 2016-08-19 18:24:04 | [diff] [blame] | 224 | *displayed = true; |
| 225 | break; |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 226 | case security_state::CONTENT_STATUS_RAN: |
estark | 00e83f1 | 2016-08-19 18:24:04 | [diff] [blame] | 227 | *ran = true; |
| 228 | break; |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 229 | case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN: |
estark | 00e83f1 | 2016-08-19 18:24:04 | [diff] [blame] | 230 | *displayed = true; |
| 231 | *ran = true; |
| 232 | break; |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 233 | case security_state::CONTENT_STATUS_UNKNOWN: |
| 234 | case security_state::CONTENT_STATUS_NONE: |
estark | 00e83f1 | 2016-08-19 18:24:04 | [diff] [blame] | 235 | break; |
| 236 | } |
| 237 | } |
| 238 | |
elawrence | b2ac2a23 | 2017-03-27 21:46:25 | [diff] [blame] | 239 | // If the |security_info| indicates that mixed content or certificate errors |
| 240 | // were present, update |connection_status| and |connection_details|. |
| 241 | void ReportAnyInsecureContent(const security_state::SecurityInfo& security_info, |
thestig | 4427f13b | 2017-06-20 20:42:47 | [diff] [blame] | 242 | PageInfo::SiteConnectionStatus* connection_status, |
| 243 | base::string16* connection_details) { |
elawrence | b2ac2a23 | 2017-03-27 21:46:25 | [diff] [blame] | 244 | 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) { |
thestig | 4427f13b | 2017-06-20 20:42:47 | [diff] [blame] | 261 | *connection_status = |
elawrence | b2ac2a23 | 2017-03-27 21:46:25 | [diff] [blame] | 262 | PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE; |
thestig | 4427f13b | 2017-06-20 20:42:47 | [diff] [blame] | 263 | connection_details->assign(l10n_util::GetStringFUTF16( |
| 264 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details, |
elawrence | b2ac2a23 | 2017-03-27 21:46:25 | [diff] [blame] | 265 | l10n_util::GetStringUTF16( |
| 266 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR))); |
estark | 00e83f1 | 2016-08-19 18:24:04 | [diff] [blame] | 267 | return; |
| 268 | } |
elawrence | b2ac2a23 | 2017-03-27 21:46:25 | [diff] [blame] | 269 | if (security_info.contained_mixed_form) { |
thestig | 4427f13b | 2017-06-20 20:42:47 | [diff] [blame] | 270 | *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, |
elawrence | b2ac2a23 | 2017-03-27 21:46:25 | [diff] [blame] | 273 | l10n_util::GetStringUTF16( |
| 274 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_FORM_WARNING))); |
| 275 | return; |
| 276 | } |
| 277 | if (displayed_insecure_content) { |
thestig | 4427f13b | 2017-06-20 20:42:47 | [diff] [blame] | 278 | *connection_status = |
elawrence | b2ac2a23 | 2017-03-27 21:46:25 | [diff] [blame] | 279 | PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE; |
thestig | 4427f13b | 2017-06-20 20:42:47 | [diff] [blame] | 280 | connection_details->assign(l10n_util::GetStringFUTF16( |
| 281 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details, |
elawrence | b2ac2a23 | 2017-03-27 21:46:25 | [diff] [blame] | 282 | l10n_util::GetStringUTF16( |
| 283 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING))); |
| 284 | } |
estark | 00e83f1 | 2016-08-19 18:24:04 | [diff] [blame] | 285 | } |
| 286 | |
jshin | 1fb7646 | 2016-04-05 22:13:03 | [diff] [blame] | 287 | base::string16 GetSimpleSiteName(const GURL& url) { |
benwells | 2337b810 | 2016-04-20 01:53:53 | [diff] [blame] | 288 | return url_formatter::FormatUrlForSecurityDisplay( |
| 289 | url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS); |
palmer | 153af98 | 2015-09-15 02:04:19 | [diff] [blame] | 290 | } |
| 291 | |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 292 | ChooserContextBase* 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 Grieve | d1978b0e | 2017-07-28 15:53:41 | [diff] [blame] | 299 | const PageInfo::ChooserUIInfo kChooserUIInfo[] = { |
reillyg | 58f82ab | 2016-08-03 01:49:52 | [diff] [blame] | 300 | {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext, |
Patti | 1d8a431 | 2018-01-19 06:36:11 | [diff] [blame] | 301 | IDS_PAGE_INFO_USB_DEVICE_LABEL, IDS_PAGE_INFO_USB_DEVICE_SECONDARY_LABEL, |
| 302 | IDS_PAGE_INFO_DELETE_USB_DEVICE, "name"}, |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 303 | }; |
| 304 | |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 305 | // Time open histogram prefixes. |
| 306 | const char kPageInfoTimePrefix[] = "Security.PageInfo.TimeOpen"; |
| 307 | const char kPageInfoTimeActionPrefix[] = "Security.PageInfo.TimeOpen.Action"; |
| 308 | const char kPageInfoTimeNoActionPrefix[] = |
| 309 | "Security.PageInfo.TimeOpen.NoAction"; |
| 310 | |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 311 | } // namespace |
| 312 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 313 | PageInfo::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] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 319 | : TabSpecificContentSettings::SiteDataObserver( |
| 320 | tab_specific_content_settings), |
dominickn | bdd53b5f | 2016-09-28 01:08:13 | [diff] [blame] | 321 | content::WebContentsObserver(web_contents), |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 322 | ui_(ui), |
[email protected] | 66f15731 | 2012-08-01 13:50:26 | [diff] [blame] | 323 | show_info_bar_(false), |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 324 | site_url_(url), |
| 325 | site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN), |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 326 | site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN), |
alshabalin | 5e894c1 | 2016-10-25 06:47:46 | [diff] [blame] | 327 | show_ssl_decision_revoke_button_(false), |
peconn | 5100d43 | 2015-09-16 12:03:08 | [diff] [blame] | 328 | content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)), |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 329 | chrome_ssl_host_state_delegate_( |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 330 | ChromeSSLHostStateDelegateFactory::GetForProfile(profile)), |
palmer | 153af98 | 2015-09-15 02:04:19 | [diff] [blame] | 331 | did_revoke_user_ssl_decisions_(false), |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 332 | profile_(profile), |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 333 | security_level_(security_state::NONE), |
Jialiu Lin | feb6bb3 | 2017-08-30 00:21:36 | [diff] [blame] | 334 | #if defined(SAFE_BROWSING_DB_LOCAL) |
Jialiu Lin | 0d8cc72 | 2017-09-19 01:01:51 | [diff] [blame] | 335 | password_protection_service_( |
| 336 | safe_browsing::ChromePasswordProtectionService:: |
| 337 | GetPasswordProtectionService(profile_)), |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 338 | #endif |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 339 | show_change_password_buttons_(false), |
| 340 | did_perform_action_(false) { |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 341 | Init(url, security_info); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 342 | |
| 343 | PresentSitePermissions(); |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 344 | PresentSiteIdentity(); |
Patti | e8c61620 | 2017-09-29 07:58:03 | [diff] [blame] | 345 | PresentSiteData(); |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 346 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 347 | // 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 Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 350 | |
| 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] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 354 | } |
| 355 | |
Carlos IL | e5dfda7 | 2017-09-21 02:33:05 | [diff] [blame] | 356 | PageInfo::~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 Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 367 | |
| 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 DeBlasio | c7b9528 | 2018-11-08 18:41:37 | [diff] [blame] | 371 | security_state::GetSecurityLevelHistogramName( |
| 372 | kPageInfoTimePrefix, security_level_), |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 373 | base::TimeTicks::Now() - start_time_, |
| 374 | base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), 100); |
| 375 | if (did_perform_action_) { |
| 376 | base::UmaHistogramCustomTimes( |
Joe DeBlasio | c7b9528 | 2018-11-08 18:41:37 | [diff] [blame] | 377 | security_state::GetSecurityLevelHistogramName( |
| 378 | kPageInfoTimeActionPrefix, security_level_), |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 379 | base::TimeTicks::Now() - start_time_, |
| 380 | base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), |
| 381 | 100); |
| 382 | } else { |
| 383 | base::UmaHistogramCustomTimes( |
Joe DeBlasio | c7b9528 | 2018-11-08 18:41:37 | [diff] [blame] | 384 | security_state::GetSecurityLevelHistogramName( |
| 385 | kPageInfoTimeNoActionPrefix, security_level_), |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 386 | base::TimeTicks::Now() - start_time_, |
| 387 | base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), |
| 388 | 100); |
| 389 | } |
Carlos IL | e5dfda7 | 2017-09-21 02:33:05 | [diff] [blame] | 390 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 391 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 392 | void PageInfo::RecordPageInfoAction(PageInfoAction action) { |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 393 | if (action != PAGE_INFO_OPENED) |
| 394 | did_perform_action_ = true; |
| 395 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 396 | UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action, PAGE_INFO_COUNT); |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 397 | |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 398 | std::string histogram_name; |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 399 | if (site_url_.SchemeIsCryptographic()) { |
Carlos IL | cb232111 | 2018-02-01 18:05:23 | [diff] [blame] | 400 | 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", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 405 | action, PAGE_INFO_COUNT); |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 406 | } else if (security_level_ == security_state::NONE) { |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 407 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 408 | action, PAGE_INFO_COUNT); |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 409 | } else if (security_level_ == security_state::DANGEROUS) { |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 410 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 411 | action, PAGE_INFO_COUNT); |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 412 | } |
| 413 | return; |
| 414 | } |
| 415 | |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 416 | if (security_level_ == security_state::HTTP_SHOW_WARNING) { |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 417 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 418 | action, PAGE_INFO_COUNT); |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 419 | } else if (security_level_ == security_state::DANGEROUS) { |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 420 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 421 | action, PAGE_INFO_COUNT); |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 422 | } else { |
| 423 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 424 | action, PAGE_INFO_COUNT); |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 425 | } |
| 426 | } |
| 427 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 428 | void PageInfo::OnSitePermissionChanged(ContentSettingsType type, |
| 429 | ContentSetting setting) { |
shahriar rostami | a9c769d | 2017-12-06 04:54:08 | [diff] [blame] | 430 | tab_specific_content_settings()->ContentSettingChangedViaPageInfo(type); |
| 431 | |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 432 | // Count how often a permission for a specific content type is changed using |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 433 | // the Page Info UI. |
raymes | 4a13d43 | 2015-09-08 00:44:07 | [diff] [blame] | 434 | size_t num_values; |
| 435 | int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values); |
dcheng | f6f4e494 | 2017-03-30 23:55:57 | [diff] [blame] | 436 | UMA_HISTOGRAM_EXACT_LINEAR("WebsiteSettings.OriginInfo.PermissionChanged", |
| 437 | histogram_value, num_values); |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 438 | |
| 439 | if (setting == ContentSetting::CONTENT_SETTING_ALLOW) { |
dcheng | f6f4e494 | 2017-03-30 23:55:57 | [diff] [blame] | 440 | UMA_HISTOGRAM_EXACT_LINEAR( |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 441 | "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value, |
raymes | 4a13d43 | 2015-09-08 00:44:07 | [diff] [blame] | 442 | num_values); |
tommycli | 34cf29bf | 2016-09-08 05:46:25 | [diff] [blame] | 443 | |
| 444 | if (type == CONTENT_SETTINGS_TYPE_PLUGINS) { |
| 445 | rappor::SampleDomainAndRegistryFromGURL( |
| 446 | g_browser_process->rappor_service(), |
| 447 | "ContentSettings.Plugins.AddedAllowException", site_url_); |
| 448 | } |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 449 | } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) { |
dcheng | f6f4e494 | 2017-03-30 23:55:57 | [diff] [blame] | 450 | UMA_HISTOGRAM_EXACT_LINEAR( |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 451 | "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value, |
raymes | 4a13d43 | 2015-09-08 00:44:07 | [diff] [blame] | 452 | num_values); |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 453 | } |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 454 | |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 455 | // This is technically redundant given the histogram above, but putting the |
| 456 | // total count of permission changes in another histogram makes it easier to |
lgarron | 026e9c4 | 2017-04-07 20:09:31 | [diff] [blame] | 457 | // compare it against other kinds of actions in Page Info. |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 458 | RecordPageInfoAction(PAGE_INFO_CHANGED_PERMISSION); |
Tommy Steimel | dea90f7 | 2017-11-07 20:58:03 | [diff] [blame] | 459 | 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 | } |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 474 | |
stefanocs | 8b3490cc | 2016-07-28 05:32:52 | [diff] [blame] | 475 | PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( |
patricialor | 7131c1fe | 2017-04-07 01:25:52 | [diff] [blame] | 476 | profile_, site_url_, site_url_, type, PermissionSourceUI::OIB); |
stefanocs | 8b3490cc | 2016-07-28 05:32:52 | [diff] [blame] | 477 | |
patricialor | 7131c1fe | 2017-04-07 01:25:52 | [diff] [blame] | 478 | // 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 | } |
raymes | fbaaaaa | 2015-11-10 02:20:40 | [diff] [blame] | 484 | content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type, |
| 485 | setting); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 486 | |
Tommy Steimel | 97ee2f8 | 2017-11-01 21:39:52 | [diff] [blame] | 487 | // When the sound setting is changed, no reload is necessary. |
| 488 | if (type != CONTENT_SETTINGS_TYPE_SOUND) |
| 489 | show_info_bar_ = true; |
[email protected] | 2f45d54 | 2012-08-22 08:47:24 | [diff] [blame] | 490 | |
| 491 | // Refresh the UI to reflect the new setting. |
| 492 | PresentSitePermissions(); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 493 | } |
| 494 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 495 | void PageInfo::OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info, |
| 496 | const base::DictionaryValue& object) { |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 497 | // TODO(reillyg): Create metrics for revocations. crbug.com/556845 |
| 498 | ChooserContextBase* context = ui_info.get_context(profile_); |
reillyg | 36a7fab3 | 2016-01-28 19:15:10 | [diff] [blame] | 499 | const GURL origin = site_url_.GetOrigin(); |
| 500 | context->RevokeObjectPermission(origin, origin, object); |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 501 | show_info_bar_ = true; |
| 502 | |
| 503 | // Refresh the UI to reflect the changed settings. |
| 504 | PresentSitePermissions(); |
| 505 | } |
| 506 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 507 | void PageInfo::OnSiteDataAccessed() { |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 508 | PresentSiteData(); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 509 | } |
| 510 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 511 | void PageInfo::OnUIClosing() { |
estade | 3feb83f | 2015-09-01 23:00:49 | [diff] [blame] | 512 | #if defined(OS_ANDROID) |
| 513 | NOTREACHED(); |
| 514 | #else |
dominickn | bdd53b5f | 2016-09-28 01:08:13 | [diff] [blame] | 515 | if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) { |
palmer | f2cba0d | 2015-08-27 23:15:06 | [diff] [blame] | 516 | InfoBarService* infobar_service = |
dominickn | bdd53b5f | 2016-09-28 01:08:13 | [diff] [blame] | 517 | InfoBarService::FromWebContents(web_contents()); |
palmer | f2cba0d | 2015-08-27 23:15:06 | [diff] [blame] | 518 | if (infobar_service) |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 519 | PageInfoInfoBarDelegate::Create(infobar_service); |
palmer | f2cba0d | 2015-08-27 23:15:06 | [diff] [blame] | 520 | } |
estade | 3feb83f | 2015-09-01 23:00:49 | [diff] [blame] | 521 | #endif |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 522 | } |
| 523 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 524 | void PageInfo::OnRevokeSSLErrorBypassButtonPressed() { |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 525 | DCHECK(chrome_ssl_host_state_delegate_); |
jww | 6a55df7 | 2014-09-05 19:59:29 | [diff] [blame] | 526 | chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard( |
| 527 | site_url().host()); |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 528 | did_revoke_user_ssl_decisions_ = true; |
[email protected] | 66f15731 | 2012-08-01 13:50:26 | [diff] [blame] | 529 | } |
| 530 | |
Patricia Lor | a21a04cf | 2017-06-05 02:53:29 | [diff] [blame] | 531 | void PageInfo::OpenSiteSettingsView() { |
Christopher Lam | 0dbac2b | 2017-11-14 07:12:10 | [diff] [blame] | 532 | #if defined(OS_ANDROID) |
| 533 | NOTREACHED(); |
| 534 | #else |
| 535 | chrome::ShowSiteSettings(chrome::FindBrowserWithWebContents(web_contents()), |
| 536 | site_url()); |
Patricia Lor | a21a04cf | 2017-06-05 02:53:29 | [diff] [blame] | 537 | RecordPageInfoAction(PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED); |
Christopher Lam | 0dbac2b | 2017-11-14 07:12:10 | [diff] [blame] | 538 | #endif |
Patricia Lor | a21a04cf | 2017-06-05 02:53:29 | [diff] [blame] | 539 | } |
| 540 | |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 541 | void PageInfo::OnChangePasswordButtonPressed( |
| 542 | content::WebContents* web_contents) { |
Jialiu Lin | feb6bb3 | 2017-08-30 00:21:36 | [diff] [blame] | 543 | #if defined(SAFE_BROWSING_DB_LOCAL) |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 544 | DCHECK(password_protection_service_); |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 545 | DCHECK(site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE || |
| 546 | site_identity_status_ == |
| 547 | SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE); |
Jialiu Lin | 3fc7f38f | 2017-09-21 18:38:37 | [diff] [blame] | 548 | password_protection_service_->OnUserAction( |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 549 | web_contents, |
| 550 | site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE |
| 551 | ? PasswordReuseEvent::SIGN_IN_PASSWORD |
| 552 | : PasswordReuseEvent::ENTERPRISE_PASSWORD, |
Jialiu Lin | a97fe52 | 2018-07-26 16:47:26 | [diff] [blame] | 553 | safe_browsing::WarningUIType::PAGE_INFO, |
| 554 | safe_browsing::WarningAction::CHANGE_PASSWORD); |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 555 | #endif |
| 556 | } |
| 557 | |
| 558 | void PageInfo::OnWhitelistPasswordReuseButtonPressed( |
| 559 | content::WebContents* web_contents) { |
Jialiu Lin | feb6bb3 | 2017-08-30 00:21:36 | [diff] [blame] | 560 | #if defined(SAFE_BROWSING_DB_LOCAL) |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 561 | DCHECK(password_protection_service_); |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 562 | DCHECK(site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE || |
| 563 | site_identity_status_ == |
| 564 | SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE); |
Jialiu Lin | 3fc7f38f | 2017-09-21 18:38:37 | [diff] [blame] | 565 | password_protection_service_->OnUserAction( |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 566 | web_contents, |
| 567 | site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE |
| 568 | ? PasswordReuseEvent::SIGN_IN_PASSWORD |
| 569 | : PasswordReuseEvent::ENTERPRISE_PASSWORD, |
Jialiu Lin | a97fe52 | 2018-07-26 16:47:26 | [diff] [blame] | 570 | safe_browsing::WarningUIType::PAGE_INFO, |
| 571 | safe_browsing::WarningAction::MARK_AS_LEGITIMATE); |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 572 | #endif |
| 573 | } |
| 574 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 575 | void PageInfo::Init(const GURL& url, |
| 576 | const security_state::SecurityInfo& security_info) { |
thestig | 0c55ee3 | 2017-06-20 22:17:51 | [diff] [blame] | 577 | #if !defined(OS_ANDROID) |
meacer | de53fcff | 2016-10-12 19:21:57 | [diff] [blame] | 578 | // On desktop, internal URLs aren't handled by this class. Instead, a |
lgarron | 026e9c4 | 2017-04-07 20:09:31 | [diff] [blame] | 579 | // custom and simpler bubble is shown. |
meacer | de53fcff | 2016-10-12 19:21:57 | [diff] [blame] | 580 | DCHECK(!url.SchemeIs(content::kChromeUIScheme) && |
| 581 | !url.SchemeIs(content::kChromeDevToolsScheme) && |
| 582 | !url.SchemeIs(content::kViewSourceScheme) && |
| 583 | !url.SchemeIs(content_settings::kExtensionScheme)); |
| 584 | #endif |
| 585 | |
thestig | 0c55ee3 | 2017-06-20 22:17:51 | [diff] [blame] | 586 | bool is_chrome_ui_native_scheme = false; |
zpeng | db4a58e | 2017-01-10 17:40:32 | [diff] [blame] | 587 | #if defined(OS_ANDROID) |
thestig | 0c55ee3 | 2017-06-20 22:17:51 | [diff] [blame] | 588 | is_chrome_ui_native_scheme = url.SchemeIs(chrome::kChromeUINativeScheme); |
sashab | 97894ce | 2014-10-22 10:08:33 | [diff] [blame] | 589 | #endif |
| 590 | |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 591 | security_level_ = security_info.security_level; |
| 592 | |
upendrag.gowda | 60886a6e | 2015-10-31 05:51:09 | [diff] [blame] | 593 | 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 | |
thestig | 0c55ee3 | 2017-06-20 22:17:51 | [diff] [blame] | 606 | if (url.SchemeIs(content::kChromeUIScheme) || is_chrome_ui_native_scheme) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 607 | 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] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 614 | // Identity section. |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 615 | certificate_ = security_info.certificate; |
[email protected] | f61c1ce | 2012-05-09 13:55:11 | [diff] [blame] | 616 | |
estark | fcfccdb8 | 2016-11-14 02:17:29 | [diff] [blame] | 617 | if (security_info.malicious_content_status != |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 618 | security_state::MALICIOUS_CONTENT_STATUS_NONE) { |
estark | fcfccdb8 | 2016-11-14 02:17:29 | [diff] [blame] | 619 | // 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 Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 623 | show_change_password_buttons_ = |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 624 | (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); |
estark | fcfccdb8 | 2016-11-14 02:17:29 | [diff] [blame] | 629 | } else if (certificate_ && |
| 630 | (!net::IsCertStatusError(security_info.cert_status) || |
| 631 | net::IsCertStatusMinorError(security_info.cert_status))) { |
| 632 | // HTTPS with no or minor errors. |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 633 | if (security_info.security_level == |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 634 | security_state::SECURE_WITH_POLICY_INSTALLED_CERT) { |
Eric Lawrence | 6758d1d | 2017-11-21 16:06:05 | [diff] [blame] | 635 | #if defined(OS_CHROMEOS) |
[email protected] | eaf3f32 | 2013-04-25 21:53:59 | [diff] [blame] | 636 | site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT; |
[email protected] | 24a9f1c9 | 2013-11-13 12:33:37 | [diff] [blame] | 637 | site_identity_details_ = l10n_util::GetStringFUTF16( |
| 638 | IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host())); |
Eric Lawrence | 6758d1d | 2017-11-21 16:06:05 | [diff] [blame] | 639 | #else |
| 640 | DCHECK(false) << "Policy certificates exist only on ChromeOS"; |
| 641 | #endif |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 642 | } else if (net::IsCertStatusMinorError(security_info.cert_status)) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 643 | site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN; |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 644 | base::string16 issuer_name( |
| 645 | UTF8ToUTF16(certificate_->issuer().GetDisplayName())); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 646 | if (issuer_name.empty()) { |
| 647 | issuer_name.assign(l10n_util::GetStringUTF16( |
| 648 | IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 649 | } |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 650 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 651 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 652 | IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name)); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 653 | |
| 654 | site_identity_details_ += ASCIIToUTF16("\n\n"); |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 655 | if (security_info.cert_status & |
| 656 | net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 657 | site_identity_details_ += l10n_util::GetStringUTF16( |
| 658 | IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION); |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 659 | } else if (security_info.cert_status & |
| 660 | net::CERT_STATUS_NO_REVOCATION_MECHANISM) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 661 | 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] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 666 | } else { |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 667 | // No major or minor errors. |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 668 | if (security_info.cert_status & net::CERT_STATUS_IS_EV) { |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 669 | // EV HTTPS page. |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 670 | site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT; |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 671 | DCHECK(!certificate_->subject().organization_names.empty()); |
| 672 | organization_name_ = |
| 673 | UTF8ToUTF16(certificate_->subject().organization_names[0]); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 674 | // An EV Cert is required to have a city (localityName) and country but |
| 675 | // state is "if any". |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 676 | DCHECK(!certificate_->subject().locality_name.empty()); |
| 677 | DCHECK(!certificate_->subject().country_name.empty()); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 678 | base::string16 locality; |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 679 | if (!certificate_->subject().state_or_province_name.empty()) { |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 680 | locality = l10n_util::GetStringFUTF16( |
lgarron | fc1d5e5 | 2017-05-03 23:15:21 | [diff] [blame] | 681 | IDS_PAGE_INFO_ADDRESS, |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 682 | UTF8ToUTF16(certificate_->subject().locality_name), |
| 683 | UTF8ToUTF16(certificate_->subject().state_or_province_name), |
| 684 | UTF8ToUTF16(certificate_->subject().country_name)); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 685 | } else { |
| 686 | locality = l10n_util::GetStringFUTF16( |
lgarron | fc1d5e5 | 2017-05-03 23:15:21 | [diff] [blame] | 687 | IDS_PAGE_INFO_PARTIAL_ADDRESS, |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 688 | UTF8ToUTF16(certificate_->subject().locality_name), |
| 689 | UTF8ToUTF16(certificate_->subject().country_name)); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 690 | } |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 691 | DCHECK(!certificate_->subject().organization_names.empty()); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 692 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 693 | IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED, |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 694 | UTF8ToUTF16(certificate_->subject().organization_names[0]), |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 695 | locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName()))); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 696 | } else { |
| 697 | // Non-EV OK HTTPS page. |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 698 | site_identity_status_ = SITE_IDENTITY_STATUS_CERT; |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 699 | base::string16 issuer_name( |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 700 | UTF8ToUTF16(certificate_->issuer().GetDisplayName())); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 701 | if (issuer_name.empty()) { |
| 702 | issuer_name.assign(l10n_util::GetStringUTF16( |
| 703 | IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 704 | } |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 705 | |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 706 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 707 | IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name)); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 708 | } |
elawrence | be87bd6 | 2017-01-10 16:08:59 | [diff] [blame] | 709 | 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); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 716 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 717 | } |
| 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)); |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 722 | if (!security_info.scheme_is_cryptographic || !security_info.certificate) |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 723 | site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT; |
| 724 | else |
| 725 | site_identity_status_ = SITE_IDENTITY_STATUS_ERROR; |
| 726 | |
[email protected] | a04db82 | 2013-12-11 19:14:40 | [diff] [blame] | 727 | const base::string16 bullet = UTF8ToUTF16("\n • "); |
felt | 2493b445 | 2015-09-17 20:33:59 | [diff] [blame] | 728 | std::vector<ssl_errors::ErrorInfo> errors; |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 729 | ssl_errors::ErrorInfo::GetErrorsForCertStatus( |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 730 | certificate_, security_info.cert_status, url, &errors); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 731 | for (size_t i = 0; i < errors.size(); ++i) { |
| 732 | site_identity_details_ += bullet; |
| 733 | site_identity_details_ += errors[i].short_description(); |
| 734 | } |
| 735 | |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 736 | if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 737 | site_identity_details_ += ASCIIToUTF16("\n\n"); |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 738 | site_identity_details_ += |
| 739 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 740 | } |
| 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 | |
jshin | 1fb7646 | 2016-04-05 22:13:03 | [diff] [blame] | 749 | base::string16 subject_name(GetSimpleSiteName(url)); |
palmer | 153af98 | 2015-09-15 02:04:19 | [diff] [blame] | 750 | if (subject_name.empty()) { |
| 751 | subject_name.assign( |
| 752 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 753 | } |
| 754 | |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 755 | if (!security_info.certificate || !security_info.scheme_is_cryptographic) { |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 756 | // 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] | 1c1051d | 2014-05-10 11:39:58 | [diff] [blame] | 758 | 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 McArdle | 2bd4fd8 | 2018-11-28 20:58:08 | [diff] [blame] | 763 | } else if (!security_info.connection_info_initialized) { |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 764 | DCHECK_NE(security_info.security_level, security_state::NONE); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 765 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 766 | } else { |
| 767 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED; |
Adam Langley | 71c2b59b | 2014-11-13 00:34:22 | [diff] [blame] | 768 | |
lgarron | 3e2c33e | 2016-08-25 06:33:43 | [diff] [blame] | 769 | if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) { |
Adam Langley | 71c2b59b | 2014-11-13 00:34:22 | [diff] [blame] | 770 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 771 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, subject_name)); |
Adam Langley | 71c2b59b | 2014-11-13 00:34:22 | [diff] [blame] | 772 | } else { |
| 773 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 774 | IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT, |
| 775 | subject_name)); |
| 776 | } |
| 777 | |
thestig | 4427f13b | 2017-06-20 20:42:47 | [diff] [blame] | 778 | ReportAnyInsecureContent(security_info, &site_connection_status_, |
| 779 | &site_connection_details_); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 780 | } |
| 781 | |
avi | 655876a | 2015-12-25 07:18:15 | [diff] [blame] | 782 | uint16_t cipher_suite = |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 783 | net::SSLConnectionStatusToCipherSuite(security_info.connection_status); |
Daniel McArdle | 2bd4fd8 | 2018-11-28 20:58:08 | [diff] [blame] | 784 | if (security_info.connection_info_initialized && cipher_suite) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 785 | int ssl_version = |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 786 | net::SSLConnectionStatusToVersion(security_info.connection_status); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 787 | 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( |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 791 | IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, ASCIIToUTF16(ssl_version_str)); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 792 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 793 | const char *key_exchange, *cipher, *mac; |
davidben | 56a8aece | 2016-10-14 18:20:56 | [diff] [blame] | 794 | bool is_aead, is_tls13; |
| 795 | net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, |
| 796 | &is_tls13, cipher_suite); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 797 | |
| 798 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
[email protected] | b6c1d9e8 | 2013-06-12 17:26:57 | [diff] [blame] | 799 | if (is_aead) { |
davidben | 56a8aece | 2016-10-14 18:20:56 | [diff] [blame] | 800 | 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] | b6c1d9e8 | 2013-06-12 17:26:57 | [diff] [blame] | 809 | 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( |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 814 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, ASCIIToUTF16(cipher), |
| 815 | ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange)); |
[email protected] | b6c1d9e8 | 2013-06-12 17:26:57 | [diff] [blame] | 816 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 817 | } |
[email protected] | e583f75 | 2012-08-30 13:26:21 | [diff] [blame] | 818 | |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 819 | // Check if a user decision has been made to allow or deny certificates with |
| 820 | // errors on this site. |
| 821 | ChromeSSLHostStateDelegate* delegate = |
estark | 7c6bfbf | 2015-09-16 22:20:50 | [diff] [blame] | 822 | ChromeSSLHostStateDelegateFactory::GetForProfile(profile_); |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 823 | DCHECK(delegate); |
jww | f806c36 | 2015-06-02 02:00:40 | [diff] [blame] | 824 | // 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] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 827 | } |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 828 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 829 | void PageInfo::PresentSitePermissions() { |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 830 | PermissionInfoList permission_info_list; |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 831 | ChosenObjectInfoList chosen_object_info_list; |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 832 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 833 | PageInfoUI::PermissionInfo permission_info; |
Avi Drissman | 22f8287 | 2018-12-25 23:09:07 | [diff] [blame^] | 834 | for (size_t i = 0; i < base::size(kPermissionType); ++i) { |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 835 | permission_info.type = kPermissionType[i]; |
| 836 | |
| 837 | content_settings::SettingInfo info; |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 838 | std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting( |
| 839 | site_url_, site_url_, permission_info.type, std::string(), &info); |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 840 | DCHECK(value.get()); |
jdoerrie | 76cee9c | 2017-10-06 22:42:42 | [diff] [blame] | 841 | if (value->type() == base::Value::Type::INTEGER) { |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 842 | permission_info.setting = |
| 843 | content_settings::ValueToContentSetting(value.get()); |
[email protected] | fe4686a | 2012-10-19 15:38:26 | [diff] [blame] | 844 | } else { |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 845 | NOTREACHED(); |
[email protected] | fe4686a | 2012-10-19 15:38:26 | [diff] [blame] | 846 | } |
| 847 | |
[email protected] | 8bdf45c3 | 2012-08-04 00:12:55 | [diff] [blame] | 848 | permission_info.source = info.source; |
johnme | 9ed9388 | 2016-01-15 01:13:28 | [diff] [blame] | 849 | permission_info.is_incognito = profile_->IsOffTheRecord(); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 850 | |
[email protected] | b1d113d | 2012-06-27 21:27:34 | [diff] [blame] | 851 | if (info.primary_pattern == ContentSettingsPattern::Wildcard() && |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 852 | info.secondary_pattern == ContentSettingsPattern::Wildcard()) { |
[email protected] | b1d113d | 2012-06-27 21:27:34 | [diff] [blame] | 853 | 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] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 859 | } |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 860 | |
patricialor | 2a4f41a | 2017-03-08 02:52:56 | [diff] [blame] | 861 | // 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 Loh | 8fbdac5 | 2018-03-15 03:34:30 | [diff] [blame] | 876 | permission_result.source == |
| 877 | PermissionStatusSource::MULTIPLE_DISMISSALS) { |
patricialor | 2a4f41a | 2017-03-08 02:52:56 | [diff] [blame] | 878 | permission_info.setting = permission_result.content_setting; |
Timothy Loh | 8fbdac5 | 2018-03-15 03:34:30 | [diff] [blame] | 879 | } |
patricialor | 2a4f41a | 2017-03-08 02:52:56 | [diff] [blame] | 880 | } |
| 881 | |
Tommy Steimel | c9f6c93 | 2017-10-13 23:33:04 | [diff] [blame] | 882 | if (ShouldShowPermission(permission_info, site_url_, content_settings_, |
shahriar rostami | a9c769d | 2017-12-06 04:54:08 | [diff] [blame] | 883 | web_contents(), tab_specific_content_settings())) { |
Patti | 0601e53 | 2017-09-20 08:39:30 | [diff] [blame] | 884 | permission_info_list.push_back(permission_info); |
Tommy Steimel | c9f6c93 | 2017-10-13 23:33:04 | [diff] [blame] | 885 | } |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 886 | } |
| 887 | |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 888 | for (const ChooserUIInfo& ui_info : kChooserUIInfo) { |
| 889 | ChooserContextBase* context = ui_info.get_context(profile_); |
reillyg | 36a7fab3 | 2016-01-28 19:15:10 | [diff] [blame] | 890 | const GURL origin = site_url_.GetOrigin(); |
Reilly Grant | a69ab67 | 2018-04-06 18:26:07 | [diff] [blame] | 891 | |
| 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 | |
reillyg | 36a7fab3 | 2016-01-28 19:15:10 | [diff] [blame] | 897 | auto chosen_objects = context->GetGrantedObjects(origin, origin); |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 898 | for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) { |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 899 | chosen_object_info_list.push_back( |
Jinho Bang | cc28079 | 2018-01-17 23:33:55 | [diff] [blame] | 900 | std::make_unique<PageInfoUI::ChosenObjectInfo>(ui_info, |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 901 | std::move(object))); |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 902 | } |
| 903 | } |
| 904 | |
avi | 09dd4d0 | 2016-10-14 20:40:09 | [diff] [blame] | 905 | ui_->SetPermissionInfo(permission_info_list, |
| 906 | std::move(chosen_object_info_list)); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 907 | } |
| 908 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 909 | void PageInfo::PresentSiteData() { |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 910 | CookieInfoList cookie_info_list; |
vabr | bab3ffcb | 2016-10-04 10:08:10 | [diff] [blame] | 911 | const LocalSharedObjectsContainer& allowed_objects = |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 912 | tab_specific_content_settings()->allowed_local_shared_objects(); |
vabr | bab3ffcb | 2016-10-04 10:08:10 | [diff] [blame] | 913 | const LocalSharedObjectsContainer& blocked_objects = |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 914 | tab_specific_content_settings()->blocked_local_shared_objects(); |
| 915 | |
| 916 | // Add first party cookie and site data counts. |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 917 | PageInfoUI::CookieInfo cookie_info; |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 918 | cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_); |
| 919 | cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_); |
palmer | b14526492 | 2015-08-28 23:53:15 | [diff] [blame] | 920 | cookie_info.is_first_party = true; |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 921 | cookie_info_list.push_back(cookie_info); |
| 922 | |
| 923 | // Add third party cookie counts. |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 924 | cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed; |
| 925 | cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked; |
palmer | b14526492 | 2015-08-28 23:53:15 | [diff] [blame] | 926 | cookie_info.is_first_party = false; |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 927 | cookie_info_list.push_back(cookie_info); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 928 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 929 | ui_->SetCookieInfo(cookie_info_list); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 930 | } |
[email protected] | 16de6de | 2012-04-04 12:24:14 | [diff] [blame] | 931 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 932 | void PageInfo::PresentSiteIdentity() { |
palmer | f9b680a | 2015-07-09 18:56:04 | [diff] [blame] | 933 | // After initialization the status about the site's connection and its |
| 934 | // identity must be available. |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 935 | DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN); |
| 936 | DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN); |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 937 | PageInfoUI::IdentityInfo info; |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 938 | if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT) |
| 939 | info.site_identity = UTF16ToUTF8(organization_name()); |
| 940 | else |
jshin | 1fb7646 | 2016-04-05 22:13:03 | [diff] [blame] | 941 | info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_)); |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 942 | |
| 943 | info.connection_status = site_connection_status_; |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 944 | info.connection_status_description = UTF16ToUTF8(site_connection_details_); |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 945 | info.identity_status = site_identity_status_; |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 946 | info.identity_status_description = UTF16ToUTF8(site_identity_details_); |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 947 | info.certificate = certificate_; |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 948 | info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 949 | info.show_change_password_buttons = show_change_password_buttons_; |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 950 | ui_->SetIdentityInfo(info); |
Jialiu Lin | feb6bb3 | 2017-08-30 00:21:36 | [diff] [blame] | 951 | #if defined(SAFE_BROWSING_DB_LOCAL) |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 952 | if (password_protection_service_ && show_change_password_buttons_) { |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 953 | if (site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE) { |
Jialiu Lin | a97fe52 | 2018-07-26 16:47:26 | [diff] [blame] | 954 | safe_browsing::LogWarningAction( |
| 955 | safe_browsing::WarningUIType::PAGE_INFO, |
| 956 | safe_browsing::WarningAction::SHOWN, |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 957 | safe_browsing::LoginReputationClientRequest::PasswordReuseEvent:: |
Jialiu Lin | a97fe52 | 2018-07-26 16:47:26 | [diff] [blame] | 958 | SIGN_IN_PASSWORD, |
| 959 | password_protection_service_->GetSyncAccountType()); |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 960 | } else { |
Jialiu Lin | a97fe52 | 2018-07-26 16:47:26 | [diff] [blame] | 961 | safe_browsing::LogWarningAction( |
| 962 | safe_browsing::WarningUIType::PAGE_INFO, |
| 963 | safe_browsing::WarningAction::SHOWN, |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 964 | safe_browsing::LoginReputationClientRequest::PasswordReuseEvent:: |
Jialiu Lin | a97fe52 | 2018-07-26 16:47:26 | [diff] [blame] | 965 | ENTERPRISE_PASSWORD, |
| 966 | password_protection_service_->GetSyncAccountType()); |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 967 | } |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 968 | } |
| 969 | #endif |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 970 | } |
Patti | 7f21c4b | 2017-11-28 03:37:17 | [diff] [blame] | 971 | |
| 972 | std::vector<ContentSettingsType> PageInfo::GetAllPermissionsForTesting() { |
| 973 | std::vector<ContentSettingsType> permission_list; |
Avi Drissman | 22f8287 | 2018-12-25 23:09:07 | [diff] [blame^] | 974 | for (size_t i = 0; i < base::size(kPermissionType); ++i) { |
Patti | 7f21c4b | 2017-11-28 03:37:17 | [diff] [blame] | 975 | #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 Lin | 4d7c604 | 2018-04-04 17:45:35 | [diff] [blame] | 983 | |
| 984 | void 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 Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 1006 | case security_state::MALICIOUS_CONTENT_STATUS_SIGN_IN_PASSWORD_REUSE: |
Jialiu Lin | 4d7c604 | 2018-04-04 17:45:35 | [diff] [blame] | 1007 | #if defined(SAFE_BROWSING_DB_LOCAL) |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 1008 | *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 Lin | 4d7c604 | 2018-04-04 17:45:35 | [diff] [blame] | 1024 | #endif |
| 1025 | break; |
spqchan | 6da308a | 2018-08-10 19:19:53 | [diff] [blame] | 1026 | case security_state::MALICIOUS_CONTENT_STATUS_BILLING: |
spqchan | 6da308a | 2018-08-10 19:19:53 | [diff] [blame] | 1027 | *status = PageInfo::SITE_IDENTITY_STATUS_BILLING; |
| 1028 | *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_BILLING_DETAILS); |
spqchan | 6da308a | 2018-08-10 19:19:53 | [diff] [blame] | 1029 | break; |
Jialiu Lin | 4d7c604 | 2018-04-04 17:45:35 | [diff] [blame] | 1030 | } |
| 1031 | } |