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