[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" |
Suman Kancherla | d54a6e5b | 2019-01-29 22:17:49 | [diff] [blame] | 25 | #include "build/build_config.h" |
jialiul | 02aad2d | 2015-04-01 18:56:03 | [diff] [blame] | 26 | #include "chrome/browser/browser_process.h" |
[email protected] | b0cb5e8 | 2012-07-19 19:22:47 | [diff] [blame] | 27 | #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" |
peconn | 5100d43 | 2015-09-16 12:03:08 | [diff] [blame] | 32 | #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
vabr | bab3ffcb | 2016-10-04 10:08:10 | [diff] [blame] | 33 | #include "chrome/browser/content_settings/local_shared_objects_container.h" |
[email protected] | 77a91c7 | 2012-08-13 16:19:34 | [diff] [blame] | 34 | #include "chrome/browser/history/history_service_factory.h" |
palmer | f2cba0d | 2015-08-27 23:15:06 | [diff] [blame] | 35 | #include "chrome/browser/infobars/infobar_service.h" |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 36 | #include "chrome/browser/permissions/chooser_context_base.h" |
patricialor | 7131c1fe | 2017-04-07 01:25:52 | [diff] [blame] | 37 | #include "chrome/browser/permissions/permission_decision_auto_blocker.h" |
patricialor | 2a4f41a | 2017-03-08 02:52:56 | [diff] [blame] | 38 | #include "chrome/browser/permissions/permission_manager.h" |
| 39 | #include "chrome/browser/permissions/permission_result.h" |
tsergeant | f1e8935 | 2016-01-15 20:34:54 | [diff] [blame] | 40 | #include "chrome/browser/permissions/permission_uma_util.h" |
| 41 | #include "chrome/browser/permissions/permission_util.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 42 | #include "chrome/browser/profiles/profile.h" |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 43 | #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 44 | #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" |
| 45 | #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 46 | #include "chrome/browser/ui/page_info/page_info_ui.h" |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 47 | #include "chrome/browser/usb/usb_chooser_context.h" |
| 48 | #include "chrome/browser/usb/usb_chooser_context_factory.h" |
Suman Kancherla | d54a6e5b | 2019-01-29 22:17:49 | [diff] [blame] | 49 | #include "chrome/browser/vr/vr_tab_helper.h" |
Patricia Lor | a21a04cf | 2017-06-05 02:53:29 | [diff] [blame] | 50 | #include "chrome/common/chrome_features.h" |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 51 | #include "chrome/common/chrome_switches.h" |
jsbell | ddb849e | 2015-08-27 00:12:56 | [diff] [blame] | 52 | #include "chrome/common/url_constants.h" |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 53 | #include "chrome/grit/theme_resources.h" |
Patti | 0601e53 | 2017-09-20 08:39:30 | [diff] [blame] | 54 | #include "components/content_settings/core/browser/content_settings_registry.h" |
mukai | 8eaec82 | 2014-10-25 17:53:16 | [diff] [blame] | 55 | #include "components/content_settings/core/browser/content_settings_utils.h" |
| 56 | #include "components/content_settings/core/browser/host_content_settings_map.h" |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 57 | #include "components/content_settings/core/common/content_settings.h" |
vasilii | f62dbf9 | 2014-09-05 10:23:13 | [diff] [blame] | 58 | #include "components/content_settings/core/common/content_settings_pattern.h" |
tbansal | 08a0e3e | 2017-06-30 21:30:08 | [diff] [blame] | 59 | #include "components/content_settings/core/common/content_settings_utils.h" |
nzolghadr | d87a308d | 2016-12-07 15:45:56 | [diff] [blame] | 60 | #include "components/rappor/public/rappor_utils.h" |
| 61 | #include "components/rappor/rappor_service_impl.h" |
felt | 2493b445 | 2015-09-17 20:33:59 | [diff] [blame] | 62 | #include "components/ssl_errors/error_info.h" |
thestig | 4a2e88e | 2016-08-27 23:23:51 | [diff] [blame] | 63 | #include "components/strings/grit/components_chromium_strings.h" |
| 64 | #include "components/strings/grit/components_strings.h" |
melandory | 7be36d31 | 2017-03-29 15:51:12 | [diff] [blame] | 65 | #include "components/subresource_filter/core/browser/subresource_filter_features.h" |
palmer | 153af98 | 2015-09-15 02:04:19 | [diff] [blame] | 66 | #include "components/url_formatter/elide_url.h" |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 67 | #include "content/public/browser/browser_thread.h" |
[email protected] | eb2140c | 2013-07-29 12:37:34 | [diff] [blame] | 68 | #include "content/public/common/content_switches.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 69 | #include "content/public/common/url_constants.h" |
[email protected] | 6e7845ae | 2013-03-29 21:48:11 | [diff] [blame] | 70 | #include "net/cert/cert_status_flags.h" |
| 71 | #include "net/cert/x509_certificate.h" |
[email protected] | 536fd0b | 2013-03-14 17:41:57 | [diff] [blame] | 72 | #include "net/ssl/ssl_cipher_suite_names.h" |
| 73 | #include "net/ssl/ssl_connection_status_flags.h" |
tfarina | 29a3a174 | 2016-10-28 18:47:33 | [diff] [blame] | 74 | #include "third_party/boringssl/src/include/openssl/ssl.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 75 | #include "ui/base/l10n/l10n_util.h" |
Patricia Lor | a21a04cf | 2017-06-05 02:53:29 | [diff] [blame] | 76 | #include "url/origin.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 77 | |
[email protected] | 24a9f1c9 | 2013-11-13 12:33:37 | [diff] [blame] | 78 | #if defined(OS_CHROMEOS) |
| 79 | #include "chrome/browser/chromeos/policy/policy_cert_service.h" |
| 80 | #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" |
| 81 | #endif |
| 82 | |
estade | 3feb83f | 2015-09-01 23:00:49 | [diff] [blame] | 83 | #if !defined(OS_ANDROID) |
Reilly Grant | 4e9d4f2 | 2019-02-13 17:17:30 | [diff] [blame] | 84 | #include "chrome/browser/serial/serial_chooser_context.h" |
| 85 | #include "chrome/browser/serial/serial_chooser_context_factory.h" |
Christopher Lam | 0dbac2b | 2017-11-14 07:12:10 | [diff] [blame] | 86 | #include "chrome/browser/ui/browser_finder.h" |
| 87 | #include "chrome/browser/ui/chrome_pages.h" |
mgiuca | a319f21 | 2016-01-14 03:30:11 | [diff] [blame] | 88 | #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 89 | #include "chrome/browser/ui/page_info/page_info_infobar_delegate.h" |
estade | 3feb83f | 2015-09-01 23:00:49 | [diff] [blame] | 90 | #endif |
| 91 | |
Michael Thiessen | 4c9e4a8 | 2019-03-08 04:39:44 | [diff] [blame] | 92 | #if defined(FULL_SAFE_BROWSING) |
Jialiu Lin | 0d8cc72 | 2017-09-19 01:01:51 | [diff] [blame] | 93 | #include "chrome/browser/safe_browsing/chrome_password_protection_service.h" |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 94 | #endif |
| 95 | |
[email protected] | ab6df3b1 | 2013-12-24 23:32:26 | [diff] [blame] | 96 | using base::ASCIIToUTF16; |
[email protected] | f729d7a | 2013-12-26 07:07:56 | [diff] [blame] | 97 | using base::UTF16ToUTF8; |
Ovidio Henriquez | 3fc113f | 2019-04-23 14:37:10 | [diff] [blame] | 98 | using base::UTF8ToUTF16; |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 99 | using content::BrowserThread; |
Michael Thiessen | 4c9e4a8 | 2019-03-08 04:39:44 | [diff] [blame] | 100 | #if defined(FULL_SAFE_BROWSING) |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 101 | using PasswordReuseEvent = |
| 102 | safe_browsing::LoginReputationClientRequest::PasswordReuseEvent; |
Michael Thiessen | 4c9e4a8 | 2019-03-08 04:39:44 | [diff] [blame] | 103 | #endif // FULL_SAFE_BROWSING |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 104 | |
| 105 | namespace { |
| 106 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 107 | // The list of content settings types to display on the Page Info UI. THE |
csharrison | ad1eaa6c | 2017-05-11 17:14:38 | [diff] [blame] | 108 | // ORDER OF THESE ITEMS IS IMPORTANT and comes from https://crbug.com/610358. To |
| 109 | // propose changing it, email [email protected]. |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 110 | ContentSettingsType kPermissionType[] = { |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 111 | CONTENT_SETTINGS_TYPE_GEOLOCATION, |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 112 | CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
| 113 | CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
Alexander Shalamov | ce5aab5 | 2018-02-07 11:45:15 | [diff] [blame] | 114 | CONTENT_SETTINGS_TYPE_SENSORS, |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 115 | CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 116 | CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
lshang | e085f20 | 2016-06-14 01:25:08 | [diff] [blame] | 117 | #if !defined(OS_ANDROID) |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 118 | CONTENT_SETTINGS_TYPE_PLUGINS, |
| 119 | CONTENT_SETTINGS_TYPE_IMAGES, |
lshang | e085f20 | 2016-06-14 01:25:08 | [diff] [blame] | 120 | #endif |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 121 | CONTENT_SETTINGS_TYPE_POPUPS, |
Charles Harrison | 239d4798 | 2017-06-13 02:42:31 | [diff] [blame] | 122 | CONTENT_SETTINGS_TYPE_ADS, |
nsatragno | 670fe92 | 2016-04-08 14:10:50 | [diff] [blame] | 123 | CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, |
Tommy Steimel | a8c3757e | 2017-08-24 00:15:46 | [diff] [blame] | 124 | CONTENT_SETTINGS_TYPE_SOUND, |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 125 | CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, |
finnur | 46cafd4 | 2016-09-22 10:27:17 | [diff] [blame] | 126 | CONTENT_SETTINGS_TYPE_AUTOPLAY, |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 127 | CONTENT_SETTINGS_TYPE_MIDI_SYSEX, |
Gary Kacmarcik | 10533cf | 2017-11-22 03:31:28 | [diff] [blame] | 128 | CONTENT_SETTINGS_TYPE_CLIPBOARD_READ, |
Reilly Grant | a69ab67 | 2018-04-06 18:26:07 | [diff] [blame] | 129 | CONTENT_SETTINGS_TYPE_USB_GUARD, |
Reilly Grant | 87d6eb02 | 2019-04-19 23:55:59 | [diff] [blame] | 130 | #if !defined(OS_ANDROID) |
| 131 | CONTENT_SETTINGS_TYPE_SERIAL_GUARD, |
| 132 | #endif |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 133 | }; |
| 134 | |
Patti | 0601e53 | 2017-09-20 08:39:30 | [diff] [blame] | 135 | // Checks whether this permission is currently the factory default, as set by |
| 136 | // Chrome. Specifically, that the following three conditions are true: |
| 137 | // - The current active setting comes from the default or pref provider. |
| 138 | // - The setting is the factory default setting (as opposed to a global |
| 139 | // default setting set by the user). |
| 140 | // - The setting is a wildcard setting applying to all origins (which can only |
| 141 | // be set from the default provider). |
| 142 | bool IsPermissionFactoryDefault(HostContentSettingsMap* content_settings, |
| 143 | const PageInfoUI::PermissionInfo& info) { |
| 144 | const ContentSetting factory_default_setting = |
| 145 | content_settings::ContentSettingsRegistry::GetInstance() |
| 146 | ->Get(info.type) |
| 147 | ->GetInitialDefaultSetting(); |
| 148 | return (info.source == content_settings::SETTING_SOURCE_USER && |
| 149 | factory_default_setting == info.default_setting && |
| 150 | info.setting == CONTENT_SETTING_DEFAULT); |
| 151 | } |
| 152 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 153 | // Determines whether to show permission |type| in the Page Info UI. Only |
mgiuca | a319f21 | 2016-01-14 03:30:11 | [diff] [blame] | 154 | // applies to permissions listed in |kPermissionType|. |
shahriar rostami | a9c769d | 2017-12-06 04:54:08 | [diff] [blame] | 155 | bool ShouldShowPermission( |
| 156 | const PageInfoUI::PermissionInfo& info, |
| 157 | const GURL& site_url, |
| 158 | HostContentSettingsMap* content_settings, |
| 159 | content::WebContents* web_contents, |
| 160 | TabSpecificContentSettings* tab_specific_content_settings) { |
Patti | 0601e53 | 2017-09-20 08:39:30 | [diff] [blame] | 161 | // Note |CONTENT_SETTINGS_TYPE_ADS| will show up regardless of its default |
| 162 | // value when it has been activated on the current origin. |
| 163 | if (info.type == CONTENT_SETTINGS_TYPE_ADS) { |
csharrison | ad1eaa6c | 2017-05-11 17:14:38 | [diff] [blame] | 164 | if (!base::FeatureList::IsEnabled( |
Charlie Harrison | b73f762 | 2018-06-01 14:24:34 | [diff] [blame] | 165 | subresource_filter::kSafeBrowsingSubresourceFilter)) { |
csharrison | ad1eaa6c | 2017-05-11 17:14:38 | [diff] [blame] | 166 | return false; |
| 167 | } |
| 168 | |
| 169 | // The setting for subresource filtering should not show up if the site is |
| 170 | // not activated, both on android and desktop platforms. |
| 171 | return content_settings->GetWebsiteSetting( |
Charles Harrison | 239d4798 | 2017-06-13 02:42:31 | [diff] [blame] | 172 | site_url, GURL(), CONTENT_SETTINGS_TYPE_ADS_DATA, std::string(), |
| 173 | nullptr) != nullptr; |
melandory | 7be36d31 | 2017-03-29 15:51:12 | [diff] [blame] | 174 | } |
| 175 | |
Tommy Steimel | c9f6c93 | 2017-10-13 23:33:04 | [diff] [blame] | 176 | if (info.type == CONTENT_SETTINGS_TYPE_SOUND) { |
Tommy Steimel | 1836051 | 2017-11-01 00:38:19 | [diff] [blame] | 177 | // The sound content setting should always show up when the tab has played |
| 178 | // audio. |
| 179 | if (web_contents && web_contents->WasEverAudible()) |
Tommy Steimel | c9f6c93 | 2017-10-13 23:33:04 | [diff] [blame] | 180 | return true; |
| 181 | } |
| 182 | |
Patti | 749d4d1 | 2017-10-11 06:20:30 | [diff] [blame] | 183 | #if defined(OS_ANDROID) |
| 184 | // Special geolocation DSE settings apply only on Android, so make sure it |
| 185 | // gets checked there regardless of default setting on Desktop. |
| 186 | if (info.type == CONTENT_SETTINGS_TYPE_GEOLOCATION) |
| 187 | return true; |
Patti | d7c4d54 | 2017-12-07 00:54:14 | [diff] [blame] | 188 | #else |
Patti | 8c57f37d | 2018-01-31 04:33:21 | [diff] [blame] | 189 | // Flash is shown if the user has ever changed its setting for |site_url|. |
| 190 | if (info.type == CONTENT_SETTINGS_TYPE_PLUGINS && |
| 191 | content_settings->GetWebsiteSetting(site_url, site_url, |
| 192 | CONTENT_SETTINGS_TYPE_PLUGINS_DATA, |
| 193 | std::string(), nullptr) != nullptr) { |
Patti | d7c4d54 | 2017-12-07 00:54:14 | [diff] [blame] | 194 | return true; |
Patti | 8c57f37d | 2018-01-31 04:33:21 | [diff] [blame] | 195 | } |
Patti | 749d4d1 | 2017-10-11 06:20:30 | [diff] [blame] | 196 | #endif |
| 197 | |
Patti | 0601e53 | 2017-09-20 08:39:30 | [diff] [blame] | 198 | #if !defined(OS_ANDROID) |
| 199 | // Autoplay is Android-only at the moment. |
| 200 | if (info.type == CONTENT_SETTINGS_TYPE_AUTOPLAY) |
| 201 | return false; |
| 202 | #endif |
| 203 | |
shahriar rostami | a9c769d | 2017-12-06 04:54:08 | [diff] [blame] | 204 | // Show the content setting if it has been changed by the user since the last |
| 205 | // page load. |
| 206 | if (tab_specific_content_settings->HasContentSettingChangedViaPageInfo( |
| 207 | info.type)) { |
| 208 | return true; |
| 209 | } |
| 210 | |
| 211 | // Show the content setting when it has a non-default value. |
| 212 | if (!IsPermissionFactoryDefault(content_settings, info)) |
| 213 | return true; |
| 214 | |
| 215 | return false; |
mgiuca | a319f21 | 2016-01-14 03:30:11 | [diff] [blame] | 216 | } |
| 217 | |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 218 | // If the |visible_security_state| indicates that mixed content or certificate |
| 219 | // errors were present, update |connection_status| and |connection_details|. |
| 220 | void ReportAnyInsecureContent( |
| 221 | const security_state::VisibleSecurityState& visible_security_state, |
| 222 | PageInfo::SiteConnectionStatus* connection_status, |
| 223 | base::string16* connection_details) { |
| 224 | bool displayed_insecure_content = |
| 225 | visible_security_state.displayed_mixed_content; |
| 226 | bool ran_insecure_content = visible_security_state.ran_mixed_content; |
elawrence | b2ac2a23 | 2017-03-27 21:46:25 | [diff] [blame] | 227 | // Only note subresources with certificate errors if the main resource was |
| 228 | // loaded without major certificate errors. If the main resource had a |
| 229 | // certificate error, then it would not be that useful (and could |
| 230 | // potentially be confusing) to warn about subresources that had certificate |
| 231 | // errors too. |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 232 | if (!net::IsCertStatusError(visible_security_state.cert_status) || |
| 233 | net::IsCertStatusMinorError(visible_security_state.cert_status)) { |
| 234 | displayed_insecure_content = |
| 235 | displayed_insecure_content || |
| 236 | visible_security_state.displayed_content_with_cert_errors; |
| 237 | ran_insecure_content = ran_insecure_content || |
| 238 | visible_security_state.ran_content_with_cert_errors; |
elawrence | b2ac2a23 | 2017-03-27 21:46:25 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | // Only one insecure content warning is displayed; show the most severe. |
| 242 | if (ran_insecure_content) { |
thestig | 4427f13b | 2017-06-20 20:42:47 | [diff] [blame] | 243 | *connection_status = |
elawrence | b2ac2a23 | 2017-03-27 21:46:25 | [diff] [blame] | 244 | PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE; |
thestig | 4427f13b | 2017-06-20 20:42:47 | [diff] [blame] | 245 | connection_details->assign(l10n_util::GetStringFUTF16( |
| 246 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details, |
elawrence | b2ac2a23 | 2017-03-27 21:46:25 | [diff] [blame] | 247 | l10n_util::GetStringUTF16( |
| 248 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR))); |
estark | 00e83f1 | 2016-08-19 18:24:04 | [diff] [blame] | 249 | return; |
| 250 | } |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 251 | if (visible_security_state.contained_mixed_form) { |
thestig | 4427f13b | 2017-06-20 20:42:47 | [diff] [blame] | 252 | *connection_status = PageInfo::SITE_CONNECTION_STATUS_INSECURE_FORM_ACTION; |
| 253 | connection_details->assign(l10n_util::GetStringFUTF16( |
| 254 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details, |
elawrence | b2ac2a23 | 2017-03-27 21:46:25 | [diff] [blame] | 255 | l10n_util::GetStringUTF16( |
| 256 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_FORM_WARNING))); |
| 257 | return; |
| 258 | } |
| 259 | if (displayed_insecure_content) { |
thestig | 4427f13b | 2017-06-20 20:42:47 | [diff] [blame] | 260 | *connection_status = |
elawrence | b2ac2a23 | 2017-03-27 21:46:25 | [diff] [blame] | 261 | PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE; |
thestig | 4427f13b | 2017-06-20 20:42:47 | [diff] [blame] | 262 | connection_details->assign(l10n_util::GetStringFUTF16( |
| 263 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details, |
elawrence | b2ac2a23 | 2017-03-27 21:46:25 | [diff] [blame] | 264 | l10n_util::GetStringUTF16( |
| 265 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING))); |
| 266 | } |
estark | 00e83f1 | 2016-08-19 18:24:04 | [diff] [blame] | 267 | } |
| 268 | |
jshin | 1fb7646 | 2016-04-05 22:13:03 | [diff] [blame] | 269 | base::string16 GetSimpleSiteName(const GURL& url) { |
benwells | 2337b810 | 2016-04-20 01:53:53 | [diff] [blame] | 270 | return url_formatter::FormatUrlForSecurityDisplay( |
| 271 | url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS); |
palmer | 153af98 | 2015-09-15 02:04:19 | [diff] [blame] | 272 | } |
| 273 | |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 274 | ChooserContextBase* GetUsbChooserContext(Profile* profile) { |
| 275 | return UsbChooserContextFactory::GetForProfile(profile); |
| 276 | } |
| 277 | |
Reilly Grant | 4e9d4f2 | 2019-02-13 17:17:30 | [diff] [blame] | 278 | #if !defined(OS_ANDROID) |
| 279 | ChooserContextBase* GetSerialChooserContext(Profile* profile) { |
| 280 | return SerialChooserContextFactory::GetForProfile(profile); |
| 281 | } |
| 282 | #endif |
| 283 | |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 284 | // The list of chooser types that need to display entries in the Website |
| 285 | // Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, |
| 286 | // email [email protected]. |
Andrew Grieve | d1978b0e | 2017-07-28 15:53:41 | [diff] [blame] | 287 | const PageInfo::ChooserUIInfo kChooserUIInfo[] = { |
reillyg | 58f82ab | 2016-08-03 01:49:52 | [diff] [blame] | 288 | {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext, |
Reilly Grant | 4e9d4f2 | 2019-02-13 17:17:30 | [diff] [blame] | 289 | IDS_PAGE_INFO_USB_DEVICE_SECONDARY_LABEL, |
Ovidio Henriquez | 017d3b8f | 2019-02-01 18:51:24 | [diff] [blame] | 290 | IDS_PAGE_INFO_USB_DEVICE_ALLOWED_BY_POLICY_LABEL, |
Ovidio Henriquez | 3fc113f | 2019-04-23 14:37:10 | [diff] [blame] | 291 | IDS_PAGE_INFO_DELETE_USB_DEVICE, &UsbChooserContext::GetObjectName}, |
Reilly Grant | 4e9d4f2 | 2019-02-13 17:17:30 | [diff] [blame] | 292 | #if !defined(OS_ANDROID) |
| 293 | {CONTENT_SETTINGS_TYPE_SERIAL_CHOOSER_DATA, &GetSerialChooserContext, |
| 294 | IDS_PAGE_INFO_SERIAL_PORT_SECONDARY_LABEL, |
| 295 | /*allowed_by_policy_description_string_id=*/-1, |
Ovidio Henriquez | 3fc113f | 2019-04-23 14:37:10 | [diff] [blame] | 296 | IDS_PAGE_INFO_DELETE_SERIAL_PORT, &SerialChooserContext::GetObjectName}, |
Reilly Grant | 4e9d4f2 | 2019-02-13 17:17:30 | [diff] [blame] | 297 | #endif |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 298 | }; |
| 299 | |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 300 | // Time open histogram prefixes. |
| 301 | const char kPageInfoTimePrefix[] = "Security.PageInfo.TimeOpen"; |
| 302 | const char kPageInfoTimeActionPrefix[] = "Security.PageInfo.TimeOpen.Action"; |
| 303 | const char kPageInfoTimeNoActionPrefix[] = |
| 304 | "Security.PageInfo.TimeOpen.NoAction"; |
| 305 | |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 306 | } // namespace |
| 307 | |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 308 | PageInfo::PageInfo( |
| 309 | PageInfoUI* ui, |
| 310 | Profile* profile, |
| 311 | TabSpecificContentSettings* tab_specific_content_settings, |
| 312 | content::WebContents* web_contents, |
| 313 | const GURL& url, |
| 314 | security_state::SecurityLevel security_level, |
| 315 | const security_state::VisibleSecurityState& visible_security_state) |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 316 | : TabSpecificContentSettings::SiteDataObserver( |
| 317 | tab_specific_content_settings), |
dominickn | bdd53b5f | 2016-09-28 01:08:13 | [diff] [blame] | 318 | content::WebContentsObserver(web_contents), |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 319 | ui_(ui), |
[email protected] | 66f15731 | 2012-08-01 13:50:26 | [diff] [blame] | 320 | show_info_bar_(false), |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 321 | site_url_(url), |
| 322 | site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN), |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 323 | site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN), |
alshabalin | 5e894c1 | 2016-10-25 06:47:46 | [diff] [blame] | 324 | show_ssl_decision_revoke_button_(false), |
peconn | 5100d43 | 2015-09-16 12:03:08 | [diff] [blame] | 325 | content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)), |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 326 | chrome_ssl_host_state_delegate_( |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 327 | ChromeSSLHostStateDelegateFactory::GetForProfile(profile)), |
palmer | 153af98 | 2015-09-15 02:04:19 | [diff] [blame] | 328 | did_revoke_user_ssl_decisions_(false), |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 329 | profile_(profile), |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 330 | security_level_(security_state::NONE), |
Michael Thiessen | 4c9e4a8 | 2019-03-08 04:39:44 | [diff] [blame] | 331 | #if defined(FULL_SAFE_BROWSING) |
Jialiu Lin | 0d8cc72 | 2017-09-19 01:01:51 | [diff] [blame] | 332 | password_protection_service_( |
| 333 | safe_browsing::ChromePasswordProtectionService:: |
| 334 | GetPasswordProtectionService(profile_)), |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 335 | #endif |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 336 | show_change_password_buttons_(false), |
| 337 | did_perform_action_(false) { |
Joe DeBlasio | c7187e6 | 2019-04-25 21:14:15 | [diff] [blame^] | 338 | ComputeUIInputs(url, security_level, visible_security_state); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 339 | |
| 340 | PresentSitePermissions(); |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 341 | PresentSiteIdentity(); |
Patti | e8c61620 | 2017-09-29 07:58:03 | [diff] [blame] | 342 | PresentSiteData(); |
Suman Kancherla | d54a6e5b | 2019-01-29 22:17:49 | [diff] [blame] | 343 | PresentPageFeatureInfo(); |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 344 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 345 | // Every time the Page Info UI is opened a |PageInfo| object is |
| 346 | // created. So this counts how ofter the Page Info UI is opened. |
| 347 | RecordPageInfoAction(PAGE_INFO_OPENED); |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 348 | |
| 349 | // Record the time when the Page Info UI is opened so the total time it is |
| 350 | // open can be measured. |
| 351 | start_time_ = base::TimeTicks::Now(); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 352 | } |
| 353 | |
Carlos IL | e5dfda7 | 2017-09-21 02:33:05 | [diff] [blame] | 354 | PageInfo::~PageInfo() { |
| 355 | // Check if Re-enable warnings button was visible, if so, log on UMA whether |
| 356 | // it was clicked or not. |
| 357 | SSLCertificateDecisionsDidRevoke user_decision = |
| 358 | did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED |
| 359 | : USER_CERT_DECISIONS_NOT_REVOKED; |
| 360 | if (show_ssl_decision_revoke_button_) { |
| 361 | UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions2", |
| 362 | user_decision, |
| 363 | END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM); |
| 364 | } |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 365 | |
| 366 | // Record the total time the Page Info UI was open for all opens as well as |
| 367 | // split between whether any action was taken. |
| 368 | base::UmaHistogramCustomTimes( |
Joe DeBlasio | c7b9528 | 2018-11-08 18:41:37 | [diff] [blame] | 369 | security_state::GetSecurityLevelHistogramName( |
| 370 | kPageInfoTimePrefix, security_level_), |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 371 | base::TimeTicks::Now() - start_time_, |
| 372 | base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), 100); |
| 373 | if (did_perform_action_) { |
| 374 | base::UmaHistogramCustomTimes( |
Joe DeBlasio | c7b9528 | 2018-11-08 18:41:37 | [diff] [blame] | 375 | security_state::GetSecurityLevelHistogramName( |
| 376 | kPageInfoTimeActionPrefix, security_level_), |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 377 | base::TimeTicks::Now() - start_time_, |
| 378 | base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), |
| 379 | 100); |
| 380 | } else { |
| 381 | base::UmaHistogramCustomTimes( |
Joe DeBlasio | c7b9528 | 2018-11-08 18:41:37 | [diff] [blame] | 382 | security_state::GetSecurityLevelHistogramName( |
| 383 | kPageInfoTimeNoActionPrefix, security_level_), |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 384 | base::TimeTicks::Now() - start_time_, |
| 385 | base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), |
| 386 | 100); |
| 387 | } |
Carlos IL | e5dfda7 | 2017-09-21 02:33:05 | [diff] [blame] | 388 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 389 | |
Joe DeBlasio | c7187e6 | 2019-04-25 21:14:15 | [diff] [blame^] | 390 | void PageInfo::UpdateSecurityState( |
| 391 | security_state::SecurityLevel security_level, |
| 392 | const security_state::VisibleSecurityState& visible_security_state) { |
| 393 | ComputeUIInputs(site_url_, security_level, visible_security_state); |
| 394 | PresentSiteIdentity(); |
| 395 | } |
| 396 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 397 | void PageInfo::RecordPageInfoAction(PageInfoAction action) { |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 398 | if (action != PAGE_INFO_OPENED) |
| 399 | did_perform_action_ = true; |
| 400 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 401 | UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action, PAGE_INFO_COUNT); |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 402 | |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 403 | std::string histogram_name; |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 404 | if (site_url_.SchemeIsCryptographic()) { |
Carlos IL | cb232111 | 2018-02-01 18:05:23 | [diff] [blame] | 405 | if (security_level_ == security_state::SECURE) { |
| 406 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.ValidNonEV", |
| 407 | action, PAGE_INFO_COUNT); |
| 408 | } else if (security_level_ == security_state::EV_SECURE) { |
| 409 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.ValidEV", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 410 | action, PAGE_INFO_COUNT); |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 411 | } else if (security_level_ == security_state::NONE) { |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 412 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 413 | action, PAGE_INFO_COUNT); |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 414 | } else if (security_level_ == security_state::DANGEROUS) { |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 415 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 416 | action, PAGE_INFO_COUNT); |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 417 | } |
| 418 | return; |
| 419 | } |
| 420 | |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 421 | if (security_level_ == security_state::HTTP_SHOW_WARNING) { |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 422 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 423 | action, PAGE_INFO_COUNT); |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 424 | } else if (security_level_ == security_state::DANGEROUS) { |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 425 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 426 | action, PAGE_INFO_COUNT); |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 427 | } else { |
| 428 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 429 | action, PAGE_INFO_COUNT); |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 430 | } |
| 431 | } |
| 432 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 433 | void PageInfo::OnSitePermissionChanged(ContentSettingsType type, |
| 434 | ContentSetting setting) { |
shahriar rostami | a9c769d | 2017-12-06 04:54:08 | [diff] [blame] | 435 | tab_specific_content_settings()->ContentSettingChangedViaPageInfo(type); |
| 436 | |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 437 | // Count how often a permission for a specific content type is changed using |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 438 | // the Page Info UI. |
raymes | 4a13d43 | 2015-09-08 00:44:07 | [diff] [blame] | 439 | size_t num_values; |
| 440 | int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values); |
dcheng | f6f4e494 | 2017-03-30 23:55:57 | [diff] [blame] | 441 | UMA_HISTOGRAM_EXACT_LINEAR("WebsiteSettings.OriginInfo.PermissionChanged", |
| 442 | histogram_value, num_values); |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 443 | |
| 444 | if (setting == ContentSetting::CONTENT_SETTING_ALLOW) { |
dcheng | f6f4e494 | 2017-03-30 23:55:57 | [diff] [blame] | 445 | UMA_HISTOGRAM_EXACT_LINEAR( |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 446 | "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value, |
raymes | 4a13d43 | 2015-09-08 00:44:07 | [diff] [blame] | 447 | num_values); |
tommycli | 34cf29bf | 2016-09-08 05:46:25 | [diff] [blame] | 448 | |
| 449 | if (type == CONTENT_SETTINGS_TYPE_PLUGINS) { |
| 450 | rappor::SampleDomainAndRegistryFromGURL( |
| 451 | g_browser_process->rappor_service(), |
| 452 | "ContentSettings.Plugins.AddedAllowException", site_url_); |
| 453 | } |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 454 | } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) { |
dcheng | f6f4e494 | 2017-03-30 23:55:57 | [diff] [blame] | 455 | UMA_HISTOGRAM_EXACT_LINEAR( |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 456 | "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value, |
raymes | 4a13d43 | 2015-09-08 00:44:07 | [diff] [blame] | 457 | num_values); |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 458 | } |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 459 | |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 460 | // This is technically redundant given the histogram above, but putting the |
| 461 | // total count of permission changes in another histogram makes it easier to |
lgarron | 026e9c4 | 2017-04-07 20:09:31 | [diff] [blame] | 462 | // compare it against other kinds of actions in Page Info. |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 463 | RecordPageInfoAction(PAGE_INFO_CHANGED_PERMISSION); |
Tommy Steimel | dea90f7 | 2017-11-07 20:58:03 | [diff] [blame] | 464 | if (type == CONTENT_SETTINGS_TYPE_SOUND) { |
| 465 | ContentSetting default_setting = |
| 466 | content_settings_->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_SOUND, |
| 467 | nullptr); |
| 468 | bool mute = (setting == CONTENT_SETTING_BLOCK) || |
| 469 | (setting == CONTENT_SETTING_DEFAULT && |
| 470 | default_setting == CONTENT_SETTING_BLOCK); |
| 471 | if (mute) { |
| 472 | base::RecordAction( |
| 473 | base::UserMetricsAction("SoundContentSetting.MuteBy.PageInfo")); |
| 474 | } else { |
| 475 | base::RecordAction( |
| 476 | base::UserMetricsAction("SoundContentSetting.UnmuteBy.PageInfo")); |
| 477 | } |
| 478 | } |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 479 | |
stefanocs | 8b3490cc | 2016-07-28 05:32:52 | [diff] [blame] | 480 | PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( |
patricialor | 7131c1fe | 2017-04-07 01:25:52 | [diff] [blame] | 481 | profile_, site_url_, site_url_, type, PermissionSourceUI::OIB); |
stefanocs | 8b3490cc | 2016-07-28 05:32:52 | [diff] [blame] | 482 | |
patricialor | 7131c1fe | 2017-04-07 01:25:52 | [diff] [blame] | 483 | // The permission may have been blocked due to being under embargo, so if it |
| 484 | // was changed away from BLOCK, clear embargo status if it exists. |
| 485 | if (setting != CONTENT_SETTING_BLOCK) { |
| 486 | PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveEmbargoByUrl( |
| 487 | site_url_, type); |
| 488 | } |
raymes | fbaaaaa | 2015-11-10 02:20:40 | [diff] [blame] | 489 | content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type, |
| 490 | setting); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 491 | |
Tommy Steimel | 97ee2f8 | 2017-11-01 21:39:52 | [diff] [blame] | 492 | // When the sound setting is changed, no reload is necessary. |
| 493 | if (type != CONTENT_SETTINGS_TYPE_SOUND) |
| 494 | show_info_bar_ = true; |
[email protected] | 2f45d54 | 2012-08-22 08:47:24 | [diff] [blame] | 495 | |
| 496 | // Refresh the UI to reflect the new setting. |
| 497 | PresentSitePermissions(); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 498 | } |
| 499 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 500 | void PageInfo::OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info, |
Ovidio Henriquez | 3fc113f | 2019-04-23 14:37:10 | [diff] [blame] | 501 | const base::Value& object) { |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 502 | // TODO(reillyg): Create metrics for revocations. crbug.com/556845 |
| 503 | ChooserContextBase* context = ui_info.get_context(profile_); |
reillyg | 36a7fab3 | 2016-01-28 19:15:10 | [diff] [blame] | 504 | const GURL origin = site_url_.GetOrigin(); |
| 505 | context->RevokeObjectPermission(origin, origin, object); |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 506 | show_info_bar_ = true; |
| 507 | |
| 508 | // Refresh the UI to reflect the changed settings. |
| 509 | PresentSitePermissions(); |
| 510 | } |
| 511 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 512 | void PageInfo::OnSiteDataAccessed() { |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 513 | PresentSiteData(); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 514 | } |
| 515 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 516 | void PageInfo::OnUIClosing() { |
estade | 3feb83f | 2015-09-01 23:00:49 | [diff] [blame] | 517 | #if defined(OS_ANDROID) |
| 518 | NOTREACHED(); |
| 519 | #else |
dominickn | bdd53b5f | 2016-09-28 01:08:13 | [diff] [blame] | 520 | if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) { |
palmer | f2cba0d | 2015-08-27 23:15:06 | [diff] [blame] | 521 | InfoBarService* infobar_service = |
dominickn | bdd53b5f | 2016-09-28 01:08:13 | [diff] [blame] | 522 | InfoBarService::FromWebContents(web_contents()); |
palmer | f2cba0d | 2015-08-27 23:15:06 | [diff] [blame] | 523 | if (infobar_service) |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 524 | PageInfoInfoBarDelegate::Create(infobar_service); |
palmer | f2cba0d | 2015-08-27 23:15:06 | [diff] [blame] | 525 | } |
estade | 3feb83f | 2015-09-01 23:00:49 | [diff] [blame] | 526 | #endif |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 527 | } |
| 528 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 529 | void PageInfo::OnRevokeSSLErrorBypassButtonPressed() { |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 530 | DCHECK(chrome_ssl_host_state_delegate_); |
jww | 6a55df7 | 2014-09-05 19:59:29 | [diff] [blame] | 531 | chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard( |
| 532 | site_url().host()); |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 533 | did_revoke_user_ssl_decisions_ = true; |
[email protected] | 66f15731 | 2012-08-01 13:50:26 | [diff] [blame] | 534 | } |
| 535 | |
Patricia Lor | a21a04cf | 2017-06-05 02:53:29 | [diff] [blame] | 536 | void PageInfo::OpenSiteSettingsView() { |
Christopher Lam | 0dbac2b | 2017-11-14 07:12:10 | [diff] [blame] | 537 | #if defined(OS_ANDROID) |
| 538 | NOTREACHED(); |
| 539 | #else |
| 540 | chrome::ShowSiteSettings(chrome::FindBrowserWithWebContents(web_contents()), |
| 541 | site_url()); |
Patricia Lor | a21a04cf | 2017-06-05 02:53:29 | [diff] [blame] | 542 | RecordPageInfoAction(PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED); |
Christopher Lam | 0dbac2b | 2017-11-14 07:12:10 | [diff] [blame] | 543 | #endif |
Patricia Lor | a21a04cf | 2017-06-05 02:53:29 | [diff] [blame] | 544 | } |
| 545 | |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 546 | void PageInfo::OnChangePasswordButtonPressed( |
| 547 | content::WebContents* web_contents) { |
Michael Thiessen | 4c9e4a8 | 2019-03-08 04:39:44 | [diff] [blame] | 548 | #if defined(FULL_SAFE_BROWSING) |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 549 | DCHECK(password_protection_service_); |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 550 | DCHECK(site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE || |
| 551 | site_identity_status_ == |
| 552 | SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE); |
Jialiu Lin | 3fc7f38f | 2017-09-21 18:38:37 | [diff] [blame] | 553 | password_protection_service_->OnUserAction( |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 554 | web_contents, |
| 555 | site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE |
| 556 | ? PasswordReuseEvent::SIGN_IN_PASSWORD |
| 557 | : PasswordReuseEvent::ENTERPRISE_PASSWORD, |
Jialiu Lin | a97fe52 | 2018-07-26 16:47:26 | [diff] [blame] | 558 | safe_browsing::WarningUIType::PAGE_INFO, |
| 559 | safe_browsing::WarningAction::CHANGE_PASSWORD); |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 560 | #endif |
| 561 | } |
| 562 | |
| 563 | void PageInfo::OnWhitelistPasswordReuseButtonPressed( |
| 564 | content::WebContents* web_contents) { |
Michael Thiessen | 4c9e4a8 | 2019-03-08 04:39:44 | [diff] [blame] | 565 | #if defined(FULL_SAFE_BROWSING) |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 566 | DCHECK(password_protection_service_); |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 567 | DCHECK(site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE || |
| 568 | site_identity_status_ == |
| 569 | SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE); |
Jialiu Lin | 3fc7f38f | 2017-09-21 18:38:37 | [diff] [blame] | 570 | password_protection_service_->OnUserAction( |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 571 | web_contents, |
| 572 | site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE |
| 573 | ? PasswordReuseEvent::SIGN_IN_PASSWORD |
| 574 | : PasswordReuseEvent::ENTERPRISE_PASSWORD, |
Jialiu Lin | a97fe52 | 2018-07-26 16:47:26 | [diff] [blame] | 575 | safe_browsing::WarningUIType::PAGE_INFO, |
| 576 | safe_browsing::WarningAction::MARK_AS_LEGITIMATE); |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 577 | #endif |
| 578 | } |
| 579 | |
Joe DeBlasio | c7187e6 | 2019-04-25 21:14:15 | [diff] [blame^] | 580 | void PageInfo::ComputeUIInputs( |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 581 | const GURL& url, |
| 582 | security_state::SecurityLevel security_level, |
| 583 | const security_state::VisibleSecurityState& visible_security_state) { |
thestig | 0c55ee3 | 2017-06-20 22:17:51 | [diff] [blame] | 584 | #if !defined(OS_ANDROID) |
meacer | de53fcff | 2016-10-12 19:21:57 | [diff] [blame] | 585 | // On desktop, internal URLs aren't handled by this class. Instead, a |
lgarron | 026e9c4 | 2017-04-07 20:09:31 | [diff] [blame] | 586 | // custom and simpler bubble is shown. |
meacer | de53fcff | 2016-10-12 19:21:57 | [diff] [blame] | 587 | DCHECK(!url.SchemeIs(content::kChromeUIScheme) && |
| 588 | !url.SchemeIs(content::kChromeDevToolsScheme) && |
| 589 | !url.SchemeIs(content::kViewSourceScheme) && |
| 590 | !url.SchemeIs(content_settings::kExtensionScheme)); |
| 591 | #endif |
| 592 | |
thestig | 0c55ee3 | 2017-06-20 22:17:51 | [diff] [blame] | 593 | bool is_chrome_ui_native_scheme = false; |
zpeng | db4a58e | 2017-01-10 17:40:32 | [diff] [blame] | 594 | #if defined(OS_ANDROID) |
thestig | 0c55ee3 | 2017-06-20 22:17:51 | [diff] [blame] | 595 | is_chrome_ui_native_scheme = url.SchemeIs(chrome::kChromeUINativeScheme); |
sashab | 97894ce | 2014-10-22 10:08:33 | [diff] [blame] | 596 | #endif |
| 597 | |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 598 | security_level_ = security_level; |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 599 | |
upendrag.gowda | 60886a6e | 2015-10-31 05:51:09 | [diff] [blame] | 600 | if (url.SchemeIs(url::kAboutScheme)) { |
| 601 | // All about: URLs except about:blank are redirected. |
| 602 | DCHECK_EQ(url::kAboutBlankURL, url.spec()); |
| 603 | site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT; |
| 604 | site_identity_details_ = |
| 605 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY); |
| 606 | site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED; |
| 607 | site_connection_details_ = l10n_util::GetStringFUTF16( |
| 608 | IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, |
| 609 | UTF8ToUTF16(url.spec())); |
| 610 | return; |
| 611 | } |
| 612 | |
thestig | 0c55ee3 | 2017-06-20 22:17:51 | [diff] [blame] | 613 | if (url.SchemeIs(content::kChromeUIScheme) || is_chrome_ui_native_scheme) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 614 | site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE; |
| 615 | site_identity_details_ = |
| 616 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE); |
| 617 | site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE; |
| 618 | return; |
| 619 | } |
| 620 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 621 | // Identity section. |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 622 | certificate_ = visible_security_state.certificate; |
[email protected] | f61c1ce | 2012-05-09 13:55:11 | [diff] [blame] | 623 | |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 624 | if (visible_security_state.malicious_content_status != |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 625 | security_state::MALICIOUS_CONTENT_STATUS_NONE) { |
estark | fcfccdb8 | 2016-11-14 02:17:29 | [diff] [blame] | 626 | // The site has been flagged by Safe Browsing as dangerous. |
| 627 | GetSiteIdentityByMaliciousContentStatus( |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 628 | visible_security_state.malicious_content_status, &site_identity_status_, |
estark | fcfccdb8 | 2016-11-14 02:17:29 | [diff] [blame] | 629 | &site_identity_details_); |
Joe DeBlasio | c7187e6 | 2019-04-25 21:14:15 | [diff] [blame^] | 630 | #if defined(FULL_SAFE_BROWSING) |
| 631 | bool old_show_change_pw_buttons = show_change_password_buttons_; |
| 632 | #endif |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 633 | show_change_password_buttons_ = |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 634 | (visible_security_state.malicious_content_status == |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 635 | security_state::MALICIOUS_CONTENT_STATUS_SIGN_IN_PASSWORD_REUSE || |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 636 | visible_security_state.malicious_content_status == |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 637 | security_state:: |
| 638 | MALICIOUS_CONTENT_STATUS_ENTERPRISE_PASSWORD_REUSE); |
Joe DeBlasio | c7187e6 | 2019-04-25 21:14:15 | [diff] [blame^] | 639 | #if defined(FULL_SAFE_BROWSING) |
| 640 | // Only record password reuse when adding the button, not on updates. |
| 641 | if (show_change_password_buttons_ && !old_show_change_pw_buttons) { |
| 642 | RecordPasswordReuseEvent(); |
| 643 | } |
| 644 | #endif |
estark | fcfccdb8 | 2016-11-14 02:17:29 | [diff] [blame] | 645 | } else if (certificate_ && |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 646 | (!net::IsCertStatusError(visible_security_state.cert_status) || |
| 647 | net::IsCertStatusMinorError( |
| 648 | visible_security_state.cert_status))) { |
estark | fcfccdb8 | 2016-11-14 02:17:29 | [diff] [blame] | 649 | // HTTPS with no or minor errors. |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 650 | if (security_level == security_state::SECURE_WITH_POLICY_INSTALLED_CERT) { |
Eric Lawrence | 6758d1d | 2017-11-21 16:06:05 | [diff] [blame] | 651 | #if defined(OS_CHROMEOS) |
[email protected] | eaf3f32 | 2013-04-25 21:53:59 | [diff] [blame] | 652 | site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT; |
[email protected] | 24a9f1c9 | 2013-11-13 12:33:37 | [diff] [blame] | 653 | site_identity_details_ = l10n_util::GetStringFUTF16( |
| 654 | IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host())); |
Eric Lawrence | 6758d1d | 2017-11-21 16:06:05 | [diff] [blame] | 655 | #else |
| 656 | DCHECK(false) << "Policy certificates exist only on ChromeOS"; |
| 657 | #endif |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 658 | } else if (net::IsCertStatusMinorError( |
| 659 | visible_security_state.cert_status)) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 660 | site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN; |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 661 | base::string16 issuer_name( |
| 662 | UTF8ToUTF16(certificate_->issuer().GetDisplayName())); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 663 | if (issuer_name.empty()) { |
| 664 | issuer_name.assign(l10n_util::GetStringUTF16( |
| 665 | IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 666 | } |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 667 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 668 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 669 | IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name)); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 670 | |
| 671 | site_identity_details_ += ASCIIToUTF16("\n\n"); |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 672 | if (visible_security_state.cert_status & |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 673 | net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 674 | site_identity_details_ += l10n_util::GetStringUTF16( |
| 675 | IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION); |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 676 | } else if (visible_security_state.cert_status & |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 677 | net::CERT_STATUS_NO_REVOCATION_MECHANISM) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 678 | site_identity_details_ += l10n_util::GetStringUTF16( |
| 679 | IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM); |
| 680 | } else { |
| 681 | NOTREACHED() << "Need to specify string for this warning"; |
| 682 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 683 | } else { |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 684 | // No major or minor errors. |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 685 | if (visible_security_state.cert_status & net::CERT_STATUS_IS_EV) { |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 686 | // EV HTTPS page. |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 687 | site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT; |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 688 | DCHECK(!certificate_->subject().organization_names.empty()); |
| 689 | organization_name_ = |
| 690 | UTF8ToUTF16(certificate_->subject().organization_names[0]); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 691 | // An EV Cert is required to have a city (localityName) and country but |
| 692 | // state is "if any". |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 693 | DCHECK(!certificate_->subject().locality_name.empty()); |
| 694 | DCHECK(!certificate_->subject().country_name.empty()); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 695 | base::string16 locality; |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 696 | if (!certificate_->subject().state_or_province_name.empty()) { |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 697 | locality = l10n_util::GetStringFUTF16( |
lgarron | fc1d5e5 | 2017-05-03 23:15:21 | [diff] [blame] | 698 | IDS_PAGE_INFO_ADDRESS, |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 699 | UTF8ToUTF16(certificate_->subject().locality_name), |
| 700 | UTF8ToUTF16(certificate_->subject().state_or_province_name), |
| 701 | UTF8ToUTF16(certificate_->subject().country_name)); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 702 | } else { |
| 703 | locality = l10n_util::GetStringFUTF16( |
lgarron | fc1d5e5 | 2017-05-03 23:15:21 | [diff] [blame] | 704 | IDS_PAGE_INFO_PARTIAL_ADDRESS, |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 705 | UTF8ToUTF16(certificate_->subject().locality_name), |
| 706 | UTF8ToUTF16(certificate_->subject().country_name)); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 707 | } |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 708 | DCHECK(!certificate_->subject().organization_names.empty()); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 709 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 710 | IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED, |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 711 | UTF8ToUTF16(certificate_->subject().organization_names[0]), |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 712 | locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName()))); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 713 | } else { |
| 714 | // Non-EV OK HTTPS page. |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 715 | site_identity_status_ = SITE_IDENTITY_STATUS_CERT; |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 716 | base::string16 issuer_name( |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 717 | UTF8ToUTF16(certificate_->issuer().GetDisplayName())); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 718 | if (issuer_name.empty()) { |
| 719 | issuer_name.assign(l10n_util::GetStringUTF16( |
| 720 | IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 721 | } |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 722 | |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 723 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 724 | IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name)); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 725 | } |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 726 | if (security_state::IsSHA1InChain(visible_security_state)) { |
elawrence | be87bd6 | 2017-01-10 16:08:59 | [diff] [blame] | 727 | site_identity_status_ = |
| 728 | SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM; |
| 729 | site_identity_details_ += |
| 730 | UTF8ToUTF16("\n\n") + |
| 731 | l10n_util::GetStringUTF16( |
| 732 | IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 733 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 734 | } |
| 735 | } else { |
| 736 | // HTTP or HTTPS with errors (not warnings). |
| 737 | site_identity_details_.assign(l10n_util::GetStringUTF16( |
| 738 | IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY)); |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 739 | if (!security_state::IsSchemeCryptographic(visible_security_state.url) || |
| 740 | !visible_security_state.certificate) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 741 | site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT; |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 742 | } else { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 743 | site_identity_status_ = SITE_IDENTITY_STATUS_ERROR; |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 744 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 745 | |
[email protected] | a04db82 | 2013-12-11 19:14:40 | [diff] [blame] | 746 | const base::string16 bullet = UTF8ToUTF16("\n • "); |
felt | 2493b445 | 2015-09-17 20:33:59 | [diff] [blame] | 747 | std::vector<ssl_errors::ErrorInfo> errors; |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 748 | ssl_errors::ErrorInfo::GetErrorsForCertStatus( |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 749 | certificate_, visible_security_state.cert_status, url, &errors); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 750 | for (size_t i = 0; i < errors.size(); ++i) { |
| 751 | site_identity_details_ += bullet; |
| 752 | site_identity_details_ += errors[i].short_description(); |
| 753 | } |
| 754 | |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 755 | if (visible_security_state.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 756 | site_identity_details_ += ASCIIToUTF16("\n\n"); |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 757 | site_identity_details_ += |
| 758 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 759 | } |
| 760 | } |
| 761 | |
| 762 | // Site Connection |
| 763 | // We consider anything less than 80 bits encryption to be weak encryption. |
| 764 | // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and |
| 765 | // weakly encrypted connections. |
| 766 | site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN; |
| 767 | |
jshin | 1fb7646 | 2016-04-05 22:13:03 | [diff] [blame] | 768 | base::string16 subject_name(GetSimpleSiteName(url)); |
palmer | 153af98 | 2015-09-15 02:04:19 | [diff] [blame] | 769 | if (subject_name.empty()) { |
| 770 | subject_name.assign( |
| 771 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 772 | } |
| 773 | |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 774 | if (!visible_security_state.certificate || |
| 775 | !security_state::IsSchemeCryptographic(visible_security_state.url)) { |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 776 | // Page is still loading (so SSL status is not yet available) or |
| 777 | // loaded over HTTP or loaded over HTTPS with no cert. |
[email protected] | 1c1051d | 2014-05-10 11:39:58 | [diff] [blame] | 778 | site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED; |
| 779 | |
| 780 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 781 | IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, |
| 782 | subject_name)); |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 783 | } else if (!visible_security_state.connection_info_initialized) { |
| 784 | DCHECK_NE(security_level, security_state::NONE); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 785 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 786 | } else { |
| 787 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED; |
Adam Langley | 71c2b59b | 2014-11-13 00:34:22 | [diff] [blame] | 788 | |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 789 | if (net::ObsoleteSSLStatus( |
| 790 | visible_security_state.connection_status, |
| 791 | visible_security_state.peer_signature_algorithm) == |
| 792 | net::OBSOLETE_SSL_NONE) { |
Adam Langley | 71c2b59b | 2014-11-13 00:34:22 | [diff] [blame] | 793 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 794 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, subject_name)); |
Adam Langley | 71c2b59b | 2014-11-13 00:34:22 | [diff] [blame] | 795 | } else { |
| 796 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 797 | IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT, |
| 798 | subject_name)); |
| 799 | } |
| 800 | |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 801 | ReportAnyInsecureContent(visible_security_state, &site_connection_status_, |
thestig | 4427f13b | 2017-06-20 20:42:47 | [diff] [blame] | 802 | &site_connection_details_); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 803 | } |
| 804 | |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 805 | uint16_t cipher_suite = net::SSLConnectionStatusToCipherSuite( |
| 806 | visible_security_state.connection_status); |
| 807 | if (visible_security_state.connection_info_initialized && cipher_suite) { |
| 808 | int ssl_version = net::SSLConnectionStatusToVersion( |
| 809 | visible_security_state.connection_status); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 810 | const char* ssl_version_str; |
| 811 | net::SSLVersionToString(&ssl_version_str, ssl_version); |
| 812 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
| 813 | site_connection_details_ += l10n_util::GetStringFUTF16( |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 814 | IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, ASCIIToUTF16(ssl_version_str)); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 815 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 816 | const char *key_exchange, *cipher, *mac; |
davidben | 56a8aece | 2016-10-14 18:20:56 | [diff] [blame] | 817 | bool is_aead, is_tls13; |
| 818 | net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, |
| 819 | &is_tls13, cipher_suite); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 820 | |
| 821 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
[email protected] | b6c1d9e8 | 2013-06-12 17:26:57 | [diff] [blame] | 822 | if (is_aead) { |
davidben | 56a8aece | 2016-10-14 18:20:56 | [diff] [blame] | 823 | if (is_tls13) { |
| 824 | // For TLS 1.3 ciphers, report the group (historically, curve) as the |
| 825 | // key exchange. |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 826 | key_exchange = |
| 827 | SSL_get_curve_name(visible_security_state.key_exchange_group); |
davidben | 56a8aece | 2016-10-14 18:20:56 | [diff] [blame] | 828 | if (!key_exchange) { |
| 829 | NOTREACHED(); |
| 830 | key_exchange = ""; |
| 831 | } |
| 832 | } |
[email protected] | b6c1d9e8 | 2013-06-12 17:26:57 | [diff] [blame] | 833 | site_connection_details_ += l10n_util::GetStringFUTF16( |
| 834 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD, |
| 835 | ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange)); |
| 836 | } else { |
| 837 | site_connection_details_ += l10n_util::GetStringFUTF16( |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 838 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, ASCIIToUTF16(cipher), |
| 839 | ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange)); |
[email protected] | b6c1d9e8 | 2013-06-12 17:26:57 | [diff] [blame] | 840 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 841 | } |
[email protected] | e583f75 | 2012-08-30 13:26:21 | [diff] [blame] | 842 | |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 843 | // Check if a user decision has been made to allow or deny certificates with |
| 844 | // errors on this site. |
| 845 | ChromeSSLHostStateDelegate* delegate = |
estark | 7c6bfbf | 2015-09-16 22:20:50 | [diff] [blame] | 846 | ChromeSSLHostStateDelegateFactory::GetForProfile(profile_); |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 847 | DCHECK(delegate); |
jww | f806c36 | 2015-06-02 02:00:40 | [diff] [blame] | 848 | // Only show an SSL decision revoke button if the user has chosen to bypass |
| 849 | // SSL host errors for this host in the past. |
| 850 | show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host()); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 851 | } |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 852 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 853 | void PageInfo::PresentSitePermissions() { |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 854 | PermissionInfoList permission_info_list; |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 855 | ChosenObjectInfoList chosen_object_info_list; |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 856 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 857 | PageInfoUI::PermissionInfo permission_info; |
Avi Drissman | 22f8287 | 2018-12-25 23:09:07 | [diff] [blame] | 858 | for (size_t i = 0; i < base::size(kPermissionType); ++i) { |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 859 | permission_info.type = kPermissionType[i]; |
| 860 | |
| 861 | content_settings::SettingInfo info; |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 862 | std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting( |
| 863 | site_url_, site_url_, permission_info.type, std::string(), &info); |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 864 | DCHECK(value.get()); |
jdoerrie | 76cee9c | 2017-10-06 22:42:42 | [diff] [blame] | 865 | if (value->type() == base::Value::Type::INTEGER) { |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 866 | permission_info.setting = |
| 867 | content_settings::ValueToContentSetting(value.get()); |
[email protected] | fe4686a | 2012-10-19 15:38:26 | [diff] [blame] | 868 | } else { |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 869 | NOTREACHED(); |
[email protected] | fe4686a | 2012-10-19 15:38:26 | [diff] [blame] | 870 | } |
| 871 | |
[email protected] | 8bdf45c3 | 2012-08-04 00:12:55 | [diff] [blame] | 872 | permission_info.source = info.source; |
johnme | 9ed9388 | 2016-01-15 01:13:28 | [diff] [blame] | 873 | permission_info.is_incognito = profile_->IsOffTheRecord(); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 874 | |
[email protected] | b1d113d | 2012-06-27 21:27:34 | [diff] [blame] | 875 | if (info.primary_pattern == ContentSettingsPattern::Wildcard() && |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 876 | info.secondary_pattern == ContentSettingsPattern::Wildcard()) { |
[email protected] | b1d113d | 2012-06-27 21:27:34 | [diff] [blame] | 877 | permission_info.default_setting = permission_info.setting; |
| 878 | permission_info.setting = CONTENT_SETTING_DEFAULT; |
| 879 | } else { |
| 880 | permission_info.default_setting = |
| 881 | content_settings_->GetDefaultContentSetting(permission_info.type, |
| 882 | NULL); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 883 | } |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 884 | |
patricialor | 2a4f41a | 2017-03-08 02:52:56 | [diff] [blame] | 885 | // For permissions that are still prompting the user and haven't been |
| 886 | // explicitly set by another source, check its embargo status. |
| 887 | if (PermissionUtil::IsPermission(permission_info.type) && |
| 888 | permission_info.setting == CONTENT_SETTING_DEFAULT && |
| 889 | permission_info.source == |
| 890 | content_settings::SettingSource::SETTING_SOURCE_USER) { |
| 891 | // TODO(raymes): Use GetPermissionStatus() to retrieve information |
| 892 | // about *all* permissions once it has default behaviour implemented for |
| 893 | // ContentSettingTypes that aren't permissions. |
| 894 | PermissionResult permission_result = |
| 895 | PermissionManager::Get(profile_)->GetPermissionStatus( |
| 896 | permission_info.type, site_url_, site_url_); |
| 897 | |
| 898 | // If under embargo, update |permission_info| to reflect that. |
| 899 | if (permission_result.content_setting == CONTENT_SETTING_BLOCK && |
Timothy Loh | 8fbdac5 | 2018-03-15 03:34:30 | [diff] [blame] | 900 | permission_result.source == |
| 901 | PermissionStatusSource::MULTIPLE_DISMISSALS) { |
patricialor | 2a4f41a | 2017-03-08 02:52:56 | [diff] [blame] | 902 | permission_info.setting = permission_result.content_setting; |
Timothy Loh | 8fbdac5 | 2018-03-15 03:34:30 | [diff] [blame] | 903 | } |
patricialor | 2a4f41a | 2017-03-08 02:52:56 | [diff] [blame] | 904 | } |
| 905 | |
Tommy Steimel | c9f6c93 | 2017-10-13 23:33:04 | [diff] [blame] | 906 | if (ShouldShowPermission(permission_info, site_url_, content_settings_, |
shahriar rostami | a9c769d | 2017-12-06 04:54:08 | [diff] [blame] | 907 | web_contents(), tab_specific_content_settings())) { |
Patti | 0601e53 | 2017-09-20 08:39:30 | [diff] [blame] | 908 | permission_info_list.push_back(permission_info); |
Tommy Steimel | c9f6c93 | 2017-10-13 23:33:04 | [diff] [blame] | 909 | } |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 910 | } |
| 911 | |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 912 | for (const ChooserUIInfo& ui_info : kChooserUIInfo) { |
| 913 | ChooserContextBase* context = ui_info.get_context(profile_); |
reillyg | 36a7fab3 | 2016-01-28 19:15:10 | [diff] [blame] | 914 | const GURL origin = site_url_.GetOrigin(); |
Reilly Grant | a69ab67 | 2018-04-06 18:26:07 | [diff] [blame] | 915 | |
reillyg | 36a7fab3 | 2016-01-28 19:15:10 | [diff] [blame] | 916 | auto chosen_objects = context->GetGrantedObjects(origin, origin); |
Ovidio Henriquez | 0e7c32a | 2019-01-16 03:15:29 | [diff] [blame] | 917 | for (std::unique_ptr<ChooserContextBase::Object>& object : chosen_objects) { |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 918 | chosen_object_info_list.push_back( |
Jinho Bang | cc28079 | 2018-01-17 23:33:55 | [diff] [blame] | 919 | std::make_unique<PageInfoUI::ChosenObjectInfo>(ui_info, |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 920 | std::move(object))); |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 921 | } |
| 922 | } |
| 923 | |
avi | 09dd4d0 | 2016-10-14 20:40:09 | [diff] [blame] | 924 | ui_->SetPermissionInfo(permission_info_list, |
| 925 | std::move(chosen_object_info_list)); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 926 | } |
| 927 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 928 | void PageInfo::PresentSiteData() { |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 929 | CookieInfoList cookie_info_list; |
vabr | bab3ffcb | 2016-10-04 10:08:10 | [diff] [blame] | 930 | const LocalSharedObjectsContainer& allowed_objects = |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 931 | tab_specific_content_settings()->allowed_local_shared_objects(); |
vabr | bab3ffcb | 2016-10-04 10:08:10 | [diff] [blame] | 932 | const LocalSharedObjectsContainer& blocked_objects = |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 933 | tab_specific_content_settings()->blocked_local_shared_objects(); |
| 934 | |
| 935 | // Add first party cookie and site data counts. |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 936 | PageInfoUI::CookieInfo cookie_info; |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 937 | cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_); |
| 938 | cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_); |
palmer | b14526492 | 2015-08-28 23:53:15 | [diff] [blame] | 939 | cookie_info.is_first_party = true; |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 940 | cookie_info_list.push_back(cookie_info); |
| 941 | |
| 942 | // Add third party cookie counts. |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 943 | cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed; |
| 944 | cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked; |
palmer | b14526492 | 2015-08-28 23:53:15 | [diff] [blame] | 945 | cookie_info.is_first_party = false; |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 946 | cookie_info_list.push_back(cookie_info); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 947 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 948 | ui_->SetCookieInfo(cookie_info_list); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 949 | } |
[email protected] | 16de6de | 2012-04-04 12:24:14 | [diff] [blame] | 950 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 951 | void PageInfo::PresentSiteIdentity() { |
palmer | f9b680a | 2015-07-09 18:56:04 | [diff] [blame] | 952 | // After initialization the status about the site's connection and its |
| 953 | // identity must be available. |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 954 | DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN); |
| 955 | DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN); |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 956 | PageInfoUI::IdentityInfo info; |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 957 | if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT) |
| 958 | info.site_identity = UTF16ToUTF8(organization_name()); |
| 959 | else |
jshin | 1fb7646 | 2016-04-05 22:13:03 | [diff] [blame] | 960 | info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_)); |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 961 | |
| 962 | info.connection_status = site_connection_status_; |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 963 | info.connection_status_description = UTF16ToUTF8(site_connection_details_); |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 964 | info.identity_status = site_identity_status_; |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 965 | info.identity_status_description = UTF16ToUTF8(site_identity_details_); |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 966 | info.certificate = certificate_; |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 967 | info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 968 | info.show_change_password_buttons = show_change_password_buttons_; |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 969 | ui_->SetIdentityInfo(info); |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 970 | } |
Patti | 7f21c4b | 2017-11-28 03:37:17 | [diff] [blame] | 971 | |
Suman Kancherla | d54a6e5b | 2019-01-29 22:17:49 | [diff] [blame] | 972 | void PageInfo::PresentPageFeatureInfo() { |
| 973 | PageInfoUI::PageFeatureInfo info; |
| 974 | info.is_vr_presentation_in_headset = |
| 975 | vr::VrTabHelper::IsContentDisplayedInHeadset(web_contents()); |
| 976 | |
| 977 | ui_->SetPageFeatureInfo(info); |
| 978 | } |
| 979 | |
Joe DeBlasio | c7187e6 | 2019-04-25 21:14:15 | [diff] [blame^] | 980 | #if defined(FULL_SAFE_BROWSING) |
| 981 | void PageInfo::RecordPasswordReuseEvent() { |
| 982 | if (!password_protection_service_) { |
| 983 | return; |
| 984 | } |
| 985 | |
| 986 | if (site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE) { |
| 987 | safe_browsing::LogWarningAction( |
| 988 | safe_browsing::WarningUIType::PAGE_INFO, |
| 989 | safe_browsing::WarningAction::SHOWN, |
| 990 | safe_browsing::LoginReputationClientRequest::PasswordReuseEvent:: |
| 991 | SIGN_IN_PASSWORD, |
| 992 | password_protection_service_->GetSyncAccountType()); |
| 993 | } else { |
| 994 | safe_browsing::LogWarningAction( |
| 995 | safe_browsing::WarningUIType::PAGE_INFO, |
| 996 | safe_browsing::WarningAction::SHOWN, |
| 997 | safe_browsing::LoginReputationClientRequest::PasswordReuseEvent:: |
| 998 | ENTERPRISE_PASSWORD, |
| 999 | password_protection_service_->GetSyncAccountType()); |
| 1000 | } |
| 1001 | } |
| 1002 | #endif |
| 1003 | |
Patti | 7f21c4b | 2017-11-28 03:37:17 | [diff] [blame] | 1004 | std::vector<ContentSettingsType> PageInfo::GetAllPermissionsForTesting() { |
| 1005 | std::vector<ContentSettingsType> permission_list; |
Avi Drissman | 22f8287 | 2018-12-25 23:09:07 | [diff] [blame] | 1006 | for (size_t i = 0; i < base::size(kPermissionType); ++i) { |
Patti | 7f21c4b | 2017-11-28 03:37:17 | [diff] [blame] | 1007 | #if !defined(OS_ANDROID) |
| 1008 | if (kPermissionType[i] == CONTENT_SETTINGS_TYPE_AUTOPLAY) |
| 1009 | continue; |
| 1010 | #endif |
| 1011 | permission_list.push_back(kPermissionType[i]); |
| 1012 | } |
| 1013 | return permission_list; |
| 1014 | } |
Jialiu Lin | 4d7c604 | 2018-04-04 17:45:35 | [diff] [blame] | 1015 | |
| 1016 | void PageInfo::GetSiteIdentityByMaliciousContentStatus( |
| 1017 | security_state::MaliciousContentStatus malicious_content_status, |
| 1018 | PageInfo::SiteIdentityStatus* status, |
| 1019 | base::string16* details) { |
| 1020 | switch (malicious_content_status) { |
| 1021 | case security_state::MALICIOUS_CONTENT_STATUS_NONE: |
| 1022 | NOTREACHED(); |
| 1023 | break; |
| 1024 | case security_state::MALICIOUS_CONTENT_STATUS_MALWARE: |
| 1025 | *status = PageInfo::SITE_IDENTITY_STATUS_MALWARE; |
| 1026 | *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MALWARE_DETAILS); |
| 1027 | break; |
| 1028 | case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING: |
| 1029 | *status = PageInfo::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING; |
| 1030 | *details = |
| 1031 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_SOCIAL_ENGINEERING_DETAILS); |
| 1032 | break; |
| 1033 | case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE: |
| 1034 | *status = PageInfo::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE; |
| 1035 | *details = |
| 1036 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_UNWANTED_SOFTWARE_DETAILS); |
| 1037 | break; |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 1038 | case security_state::MALICIOUS_CONTENT_STATUS_SIGN_IN_PASSWORD_REUSE: |
Michael Thiessen | 4c9e4a8 | 2019-03-08 04:39:44 | [diff] [blame] | 1039 | #if defined(FULL_SAFE_BROWSING) |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 1040 | *status = PageInfo::SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE; |
| 1041 | // |password_protection_service_| may be null in test. |
| 1042 | *details = password_protection_service_ |
| 1043 | ? password_protection_service_->GetWarningDetailText( |
| 1044 | PasswordReuseEvent::SIGN_IN_PASSWORD) |
| 1045 | : base::string16(); |
| 1046 | #endif |
| 1047 | break; |
| 1048 | case security_state::MALICIOUS_CONTENT_STATUS_ENTERPRISE_PASSWORD_REUSE: |
Michael Thiessen | 4c9e4a8 | 2019-03-08 04:39:44 | [diff] [blame] | 1049 | #if defined(FULL_SAFE_BROWSING) |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 1050 | *status = PageInfo::SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE; |
| 1051 | // |password_protection_service_| maybe null in test. |
| 1052 | *details = password_protection_service_ |
| 1053 | ? password_protection_service_->GetWarningDetailText( |
| 1054 | PasswordReuseEvent::ENTERPRISE_PASSWORD) |
| 1055 | : base::string16(); |
Jialiu Lin | 4d7c604 | 2018-04-04 17:45:35 | [diff] [blame] | 1056 | #endif |
| 1057 | break; |
spqchan | 6da308a | 2018-08-10 19:19:53 | [diff] [blame] | 1058 | case security_state::MALICIOUS_CONTENT_STATUS_BILLING: |
spqchan | 6da308a | 2018-08-10 19:19:53 | [diff] [blame] | 1059 | *status = PageInfo::SITE_IDENTITY_STATUS_BILLING; |
| 1060 | *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_BILLING_DETAILS); |
spqchan | 6da308a | 2018-08-10 19:19:53 | [diff] [blame] | 1061 | break; |
Jialiu Lin | 4d7c604 | 2018-04-04 17:45:35 | [diff] [blame] | 1062 | } |
| 1063 | } |