[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), |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 326 | site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN), |
alshabalin | 5e894c1 | 2016-10-25 06:47:46 | [diff] [blame] | 327 | show_ssl_decision_revoke_button_(false), |
peconn | 5100d43 | 2015-09-16 12:03:08 | [diff] [blame] | 328 | content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)), |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 329 | chrome_ssl_host_state_delegate_( |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 330 | ChromeSSLHostStateDelegateFactory::GetForProfile(profile)), |
palmer | 153af98 | 2015-09-15 02:04:19 | [diff] [blame] | 331 | did_revoke_user_ssl_decisions_(false), |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 332 | profile_(profile), |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 333 | security_level_(security_state::NONE), |
Michael Thiessen | 4c9e4a8 | 2019-03-08 04:39:44 | [diff] [blame] | 334 | #if defined(FULL_SAFE_BROWSING) |
Jialiu Lin | 0d8cc72 | 2017-09-19 01:01:51 | [diff] [blame] | 335 | password_protection_service_( |
| 336 | safe_browsing::ChromePasswordProtectionService:: |
| 337 | GetPasswordProtectionService(profile_)), |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 338 | #endif |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 339 | show_change_password_buttons_(false), |
| 340 | did_perform_action_(false) { |
Joe DeBlasio | c7187e6 | 2019-04-25 21:14:15 | [diff] [blame] | 341 | ComputeUIInputs(url, security_level, visible_security_state); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 342 | |
| 343 | PresentSitePermissions(); |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 344 | PresentSiteIdentity(); |
Patti | e8c61620 | 2017-09-29 07:58:03 | [diff] [blame] | 345 | PresentSiteData(); |
Suman Kancherla | d54a6e5b | 2019-01-29 22:17:49 | [diff] [blame] | 346 | PresentPageFeatureInfo(); |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 347 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 348 | // Every time the Page Info UI is opened a |PageInfo| object is |
| 349 | // created. So this counts how ofter the Page Info UI is opened. |
| 350 | RecordPageInfoAction(PAGE_INFO_OPENED); |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 351 | |
| 352 | // Record the time when the Page Info UI is opened so the total time it is |
| 353 | // open can be measured. |
| 354 | start_time_ = base::TimeTicks::Now(); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 355 | } |
| 356 | |
Carlos IL | e5dfda7 | 2017-09-21 02:33:05 | [diff] [blame] | 357 | PageInfo::~PageInfo() { |
| 358 | // Check if Re-enable warnings button was visible, if so, log on UMA whether |
| 359 | // it was clicked or not. |
| 360 | SSLCertificateDecisionsDidRevoke user_decision = |
| 361 | did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED |
| 362 | : USER_CERT_DECISIONS_NOT_REVOKED; |
| 363 | if (show_ssl_decision_revoke_button_) { |
| 364 | UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions2", |
| 365 | user_decision, |
| 366 | END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM); |
| 367 | } |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 368 | |
| 369 | // Record the total time the Page Info UI was open for all opens as well as |
| 370 | // split between whether any action was taken. |
| 371 | base::UmaHistogramCustomTimes( |
Joe DeBlasio | c7b9528 | 2018-11-08 18:41:37 | [diff] [blame] | 372 | security_state::GetSecurityLevelHistogramName( |
| 373 | kPageInfoTimePrefix, security_level_), |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 374 | base::TimeTicks::Now() - start_time_, |
| 375 | base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), 100); |
| 376 | if (did_perform_action_) { |
| 377 | base::UmaHistogramCustomTimes( |
Joe DeBlasio | c7b9528 | 2018-11-08 18:41:37 | [diff] [blame] | 378 | security_state::GetSecurityLevelHistogramName( |
| 379 | kPageInfoTimeActionPrefix, security_level_), |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 380 | base::TimeTicks::Now() - start_time_, |
| 381 | base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), |
| 382 | 100); |
| 383 | } else { |
| 384 | base::UmaHistogramCustomTimes( |
Joe DeBlasio | c7b9528 | 2018-11-08 18:41:37 | [diff] [blame] | 385 | security_state::GetSecurityLevelHistogramName( |
| 386 | kPageInfoTimeNoActionPrefix, security_level_), |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 387 | base::TimeTicks::Now() - start_time_, |
| 388 | base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), |
| 389 | 100); |
| 390 | } |
Carlos IL | e5dfda7 | 2017-09-21 02:33:05 | [diff] [blame] | 391 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 392 | |
Joe DeBlasio | c7187e6 | 2019-04-25 21:14:15 | [diff] [blame] | 393 | void PageInfo::UpdateSecurityState( |
| 394 | security_state::SecurityLevel security_level, |
| 395 | const security_state::VisibleSecurityState& visible_security_state) { |
| 396 | ComputeUIInputs(site_url_, security_level, visible_security_state); |
| 397 | PresentSiteIdentity(); |
| 398 | } |
| 399 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 400 | void PageInfo::RecordPageInfoAction(PageInfoAction action) { |
Christopher Thompson | 0c4e06c2 | 2018-07-11 22:29:59 | [diff] [blame] | 401 | if (action != PAGE_INFO_OPENED) |
| 402 | did_perform_action_ = true; |
| 403 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 404 | UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action, PAGE_INFO_COUNT); |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 405 | |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 406 | std::string histogram_name; |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 407 | if (site_url_.SchemeIsCryptographic()) { |
Carlos IL | cb232111 | 2018-02-01 18:05:23 | [diff] [blame] | 408 | if (security_level_ == security_state::SECURE) { |
| 409 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.ValidNonEV", |
| 410 | action, PAGE_INFO_COUNT); |
| 411 | } else if (security_level_ == security_state::EV_SECURE) { |
| 412 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.ValidEV", |
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::NONE) { |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 415 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 416 | action, PAGE_INFO_COUNT); |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 417 | } else if (security_level_ == security_state::DANGEROUS) { |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 418 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 419 | action, PAGE_INFO_COUNT); |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 420 | } |
| 421 | return; |
| 422 | } |
| 423 | |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 424 | if (security_level_ == security_state::HTTP_SHOW_WARNING) { |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 425 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 426 | action, PAGE_INFO_COUNT); |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 427 | } else if (security_level_ == security_state::DANGEROUS) { |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 428 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 429 | action, PAGE_INFO_COUNT); |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 430 | } else { |
| 431 | UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral", |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 432 | action, PAGE_INFO_COUNT); |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 433 | } |
| 434 | } |
| 435 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 436 | void PageInfo::OnSitePermissionChanged(ContentSettingsType type, |
| 437 | ContentSetting setting) { |
shahriar rostami | a9c769d | 2017-12-06 04:54:08 | [diff] [blame] | 438 | tab_specific_content_settings()->ContentSettingChangedViaPageInfo(type); |
| 439 | |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 440 | // Count how often a permission for a specific content type is changed using |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 441 | // the Page Info UI. |
raymes | 4a13d43 | 2015-09-08 00:44:07 | [diff] [blame] | 442 | size_t num_values; |
| 443 | int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values); |
dcheng | f6f4e494 | 2017-03-30 23:55:57 | [diff] [blame] | 444 | UMA_HISTOGRAM_EXACT_LINEAR("WebsiteSettings.OriginInfo.PermissionChanged", |
| 445 | histogram_value, num_values); |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 446 | |
| 447 | if (setting == ContentSetting::CONTENT_SETTING_ALLOW) { |
dcheng | f6f4e494 | 2017-03-30 23:55:57 | [diff] [blame] | 448 | UMA_HISTOGRAM_EXACT_LINEAR( |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 449 | "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value, |
raymes | 4a13d43 | 2015-09-08 00:44:07 | [diff] [blame] | 450 | num_values); |
tommycli | 34cf29bf | 2016-09-08 05:46:25 | [diff] [blame] | 451 | |
| 452 | if (type == CONTENT_SETTINGS_TYPE_PLUGINS) { |
| 453 | rappor::SampleDomainAndRegistryFromGURL( |
| 454 | g_browser_process->rappor_service(), |
| 455 | "ContentSettings.Plugins.AddedAllowException", site_url_); |
| 456 | } |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 457 | } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) { |
dcheng | f6f4e494 | 2017-03-30 23:55:57 | [diff] [blame] | 458 | UMA_HISTOGRAM_EXACT_LINEAR( |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 459 | "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value, |
raymes | 4a13d43 | 2015-09-08 00:44:07 | [diff] [blame] | 460 | num_values); |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 461 | } |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 462 | |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 463 | // This is technically redundant given the histogram above, but putting the |
| 464 | // total count of permission changes in another histogram makes it easier to |
lgarron | 026e9c4 | 2017-04-07 20:09:31 | [diff] [blame] | 465 | // compare it against other kinds of actions in Page Info. |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 466 | RecordPageInfoAction(PAGE_INFO_CHANGED_PERMISSION); |
Tommy Steimel | dea90f7 | 2017-11-07 20:58:03 | [diff] [blame] | 467 | if (type == CONTENT_SETTINGS_TYPE_SOUND) { |
| 468 | ContentSetting default_setting = |
| 469 | content_settings_->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_SOUND, |
| 470 | nullptr); |
| 471 | bool mute = (setting == CONTENT_SETTING_BLOCK) || |
| 472 | (setting == CONTENT_SETTING_DEFAULT && |
| 473 | default_setting == CONTENT_SETTING_BLOCK); |
| 474 | if (mute) { |
| 475 | base::RecordAction( |
| 476 | base::UserMetricsAction("SoundContentSetting.MuteBy.PageInfo")); |
| 477 | } else { |
| 478 | base::RecordAction( |
| 479 | base::UserMetricsAction("SoundContentSetting.UnmuteBy.PageInfo")); |
| 480 | } |
| 481 | } |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 482 | |
stefanocs | 8b3490cc | 2016-07-28 05:32:52 | [diff] [blame] | 483 | PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( |
patricialor | 7131c1fe | 2017-04-07 01:25:52 | [diff] [blame] | 484 | profile_, site_url_, site_url_, type, PermissionSourceUI::OIB); |
stefanocs | 8b3490cc | 2016-07-28 05:32:52 | [diff] [blame] | 485 | |
patricialor | 7131c1fe | 2017-04-07 01:25:52 | [diff] [blame] | 486 | // The permission may have been blocked due to being under embargo, so if it |
| 487 | // was changed away from BLOCK, clear embargo status if it exists. |
| 488 | if (setting != CONTENT_SETTING_BLOCK) { |
| 489 | PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveEmbargoByUrl( |
| 490 | site_url_, type); |
| 491 | } |
raymes | fbaaaaa | 2015-11-10 02:20:40 | [diff] [blame] | 492 | content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type, |
| 493 | setting); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 494 | |
Tommy Steimel | 97ee2f8 | 2017-11-01 21:39:52 | [diff] [blame] | 495 | // When the sound setting is changed, no reload is necessary. |
| 496 | if (type != CONTENT_SETTINGS_TYPE_SOUND) |
| 497 | show_info_bar_ = true; |
[email protected] | 2f45d54 | 2012-08-22 08:47:24 | [diff] [blame] | 498 | |
| 499 | // Refresh the UI to reflect the new setting. |
| 500 | PresentSitePermissions(); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 501 | } |
| 502 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 503 | void PageInfo::OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info, |
Ovidio Henriquez | 3fc113f | 2019-04-23 14:37:10 | [diff] [blame] | 504 | const base::Value& object) { |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 505 | // TODO(reillyg): Create metrics for revocations. crbug.com/556845 |
| 506 | ChooserContextBase* context = ui_info.get_context(profile_); |
Reilly Grant | bcdeddb | 2019-05-06 22:37:24 | [diff] [blame] | 507 | const auto origin = url::Origin::Create(site_url_); |
reillyg | 36a7fab3 | 2016-01-28 19:15:10 | [diff] [blame] | 508 | context->RevokeObjectPermission(origin, origin, object); |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 509 | show_info_bar_ = true; |
| 510 | |
| 511 | // Refresh the UI to reflect the changed settings. |
| 512 | PresentSitePermissions(); |
| 513 | } |
| 514 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 515 | void PageInfo::OnSiteDataAccessed() { |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 516 | PresentSiteData(); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 517 | } |
| 518 | |
Dana Fried | 08b774a | 2019-05-10 18:21:48 | [diff] [blame] | 519 | void PageInfo::OnUIClosing(bool* reload_prompt) { |
| 520 | if (reload_prompt) |
| 521 | *reload_prompt = false; |
estade | 3feb83f | 2015-09-01 23:00:49 | [diff] [blame] | 522 | #if defined(OS_ANDROID) |
| 523 | NOTREACHED(); |
| 524 | #else |
dominickn | bdd53b5f | 2016-09-28 01:08:13 | [diff] [blame] | 525 | if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) { |
palmer | f2cba0d | 2015-08-27 23:15:06 | [diff] [blame] | 526 | InfoBarService* infobar_service = |
dominickn | bdd53b5f | 2016-09-28 01:08:13 | [diff] [blame] | 527 | InfoBarService::FromWebContents(web_contents()); |
Dana Fried | 08b774a | 2019-05-10 18:21:48 | [diff] [blame] | 528 | if (infobar_service) { |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 529 | PageInfoInfoBarDelegate::Create(infobar_service); |
Dana Fried | 08b774a | 2019-05-10 18:21:48 | [diff] [blame] | 530 | if (reload_prompt) |
| 531 | *reload_prompt = true; |
| 532 | } |
palmer | f2cba0d | 2015-08-27 23:15:06 | [diff] [blame] | 533 | } |
estade | 3feb83f | 2015-09-01 23:00:49 | [diff] [blame] | 534 | #endif |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 535 | } |
| 536 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 537 | void PageInfo::OnRevokeSSLErrorBypassButtonPressed() { |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 538 | DCHECK(chrome_ssl_host_state_delegate_); |
jww | 6a55df7 | 2014-09-05 19:59:29 | [diff] [blame] | 539 | chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard( |
| 540 | site_url().host()); |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 541 | did_revoke_user_ssl_decisions_ = true; |
[email protected] | 66f15731 | 2012-08-01 13:50:26 | [diff] [blame] | 542 | } |
| 543 | |
Patricia Lor | a21a04cf | 2017-06-05 02:53:29 | [diff] [blame] | 544 | void PageInfo::OpenSiteSettingsView() { |
Christopher Lam | 0dbac2b | 2017-11-14 07:12:10 | [diff] [blame] | 545 | #if defined(OS_ANDROID) |
| 546 | NOTREACHED(); |
| 547 | #else |
| 548 | chrome::ShowSiteSettings(chrome::FindBrowserWithWebContents(web_contents()), |
| 549 | site_url()); |
Patricia Lor | a21a04cf | 2017-06-05 02:53:29 | [diff] [blame] | 550 | RecordPageInfoAction(PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED); |
Christopher Lam | 0dbac2b | 2017-11-14 07:12:10 | [diff] [blame] | 551 | #endif |
Patricia Lor | a21a04cf | 2017-06-05 02:53:29 | [diff] [blame] | 552 | } |
| 553 | |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 554 | void PageInfo::OnChangePasswordButtonPressed( |
| 555 | content::WebContents* web_contents) { |
Michael Thiessen | 4c9e4a8 | 2019-03-08 04:39:44 | [diff] [blame] | 556 | #if defined(FULL_SAFE_BROWSING) |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 557 | DCHECK(password_protection_service_); |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 558 | DCHECK(site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE || |
| 559 | site_identity_status_ == |
| 560 | SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE); |
Jialiu Lin | 3fc7f38f | 2017-09-21 18:38:37 | [diff] [blame] | 561 | password_protection_service_->OnUserAction( |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 562 | web_contents, |
| 563 | site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE |
| 564 | ? PasswordReuseEvent::SIGN_IN_PASSWORD |
| 565 | : PasswordReuseEvent::ENTERPRISE_PASSWORD, |
Jialiu Lin | a97fe52 | 2018-07-26 16:47:26 | [diff] [blame] | 566 | safe_browsing::WarningUIType::PAGE_INFO, |
| 567 | safe_browsing::WarningAction::CHANGE_PASSWORD); |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 568 | #endif |
| 569 | } |
| 570 | |
| 571 | void PageInfo::OnWhitelistPasswordReuseButtonPressed( |
| 572 | content::WebContents* web_contents) { |
Michael Thiessen | 4c9e4a8 | 2019-03-08 04:39:44 | [diff] [blame] | 573 | #if defined(FULL_SAFE_BROWSING) |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 574 | DCHECK(password_protection_service_); |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 575 | DCHECK(site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE || |
| 576 | site_identity_status_ == |
| 577 | SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE); |
Jialiu Lin | 3fc7f38f | 2017-09-21 18:38:37 | [diff] [blame] | 578 | password_protection_service_->OnUserAction( |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 579 | web_contents, |
| 580 | site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE |
| 581 | ? PasswordReuseEvent::SIGN_IN_PASSWORD |
| 582 | : PasswordReuseEvent::ENTERPRISE_PASSWORD, |
Jialiu Lin | a97fe52 | 2018-07-26 16:47:26 | [diff] [blame] | 583 | safe_browsing::WarningUIType::PAGE_INFO, |
| 584 | safe_browsing::WarningAction::MARK_AS_LEGITIMATE); |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 585 | #endif |
| 586 | } |
| 587 | |
Joe DeBlasio | c7187e6 | 2019-04-25 21:14:15 | [diff] [blame] | 588 | void PageInfo::ComputeUIInputs( |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 589 | const GURL& url, |
| 590 | security_state::SecurityLevel security_level, |
| 591 | const security_state::VisibleSecurityState& visible_security_state) { |
thestig | 0c55ee3 | 2017-06-20 22:17:51 | [diff] [blame] | 592 | #if !defined(OS_ANDROID) |
meacer | de53fcff | 2016-10-12 19:21:57 | [diff] [blame] | 593 | // On desktop, internal URLs aren't handled by this class. Instead, a |
lgarron | 026e9c4 | 2017-04-07 20:09:31 | [diff] [blame] | 594 | // custom and simpler bubble is shown. |
meacer | de53fcff | 2016-10-12 19:21:57 | [diff] [blame] | 595 | DCHECK(!url.SchemeIs(content::kChromeUIScheme) && |
| 596 | !url.SchemeIs(content::kChromeDevToolsScheme) && |
| 597 | !url.SchemeIs(content::kViewSourceScheme) && |
| 598 | !url.SchemeIs(content_settings::kExtensionScheme)); |
| 599 | #endif |
| 600 | |
thestig | 0c55ee3 | 2017-06-20 22:17:51 | [diff] [blame] | 601 | bool is_chrome_ui_native_scheme = false; |
zpeng | db4a58e | 2017-01-10 17:40:32 | [diff] [blame] | 602 | #if defined(OS_ANDROID) |
thestig | 0c55ee3 | 2017-06-20 22:17:51 | [diff] [blame] | 603 | is_chrome_ui_native_scheme = url.SchemeIs(chrome::kChromeUINativeScheme); |
sashab | 97894ce | 2014-10-22 10:08:33 | [diff] [blame] | 604 | #endif |
| 605 | |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 606 | security_level_ = security_level; |
estark | 8d67cd7a | 2016-10-24 05:06:41 | [diff] [blame] | 607 | |
upendrag.gowda | 60886a6e | 2015-10-31 05:51:09 | [diff] [blame] | 608 | if (url.SchemeIs(url::kAboutScheme)) { |
| 609 | // All about: URLs except about:blank are redirected. |
| 610 | DCHECK_EQ(url::kAboutBlankURL, url.spec()); |
| 611 | site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT; |
| 612 | site_identity_details_ = |
| 613 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY); |
| 614 | site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED; |
| 615 | site_connection_details_ = l10n_util::GetStringFUTF16( |
| 616 | IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, |
| 617 | UTF8ToUTF16(url.spec())); |
| 618 | return; |
| 619 | } |
| 620 | |
thestig | 0c55ee3 | 2017-06-20 22:17:51 | [diff] [blame] | 621 | if (url.SchemeIs(content::kChromeUIScheme) || is_chrome_ui_native_scheme) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 622 | site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE; |
| 623 | site_identity_details_ = |
| 624 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE); |
| 625 | site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE; |
| 626 | return; |
| 627 | } |
| 628 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 629 | // Identity section. |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 630 | certificate_ = visible_security_state.certificate; |
[email protected] | f61c1ce | 2012-05-09 13:55:11 | [diff] [blame] | 631 | |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 632 | if (visible_security_state.malicious_content_status != |
eseckler | cac56b6 | 2016-11-16 13:49:44 | [diff] [blame] | 633 | security_state::MALICIOUS_CONTENT_STATUS_NONE) { |
estark | fcfccdb8 | 2016-11-14 02:17:29 | [diff] [blame] | 634 | // The site has been flagged by Safe Browsing as dangerous. |
| 635 | GetSiteIdentityByMaliciousContentStatus( |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 636 | visible_security_state.malicious_content_status, &site_identity_status_, |
estark | fcfccdb8 | 2016-11-14 02:17:29 | [diff] [blame] | 637 | &site_identity_details_); |
Joe DeBlasio | c7187e6 | 2019-04-25 21:14:15 | [diff] [blame] | 638 | #if defined(FULL_SAFE_BROWSING) |
| 639 | bool old_show_change_pw_buttons = show_change_password_buttons_; |
| 640 | #endif |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 641 | show_change_password_buttons_ = |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 642 | (visible_security_state.malicious_content_status == |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 643 | security_state::MALICIOUS_CONTENT_STATUS_SIGN_IN_PASSWORD_REUSE || |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 644 | visible_security_state.malicious_content_status == |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 645 | security_state:: |
| 646 | MALICIOUS_CONTENT_STATUS_ENTERPRISE_PASSWORD_REUSE); |
Joe DeBlasio | c7187e6 | 2019-04-25 21:14:15 | [diff] [blame] | 647 | #if defined(FULL_SAFE_BROWSING) |
| 648 | // Only record password reuse when adding the button, not on updates. |
| 649 | if (show_change_password_buttons_ && !old_show_change_pw_buttons) { |
| 650 | RecordPasswordReuseEvent(); |
| 651 | } |
| 652 | #endif |
estark | fcfccdb8 | 2016-11-14 02:17:29 | [diff] [blame] | 653 | } else if (certificate_ && |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 654 | (!net::IsCertStatusError(visible_security_state.cert_status) || |
| 655 | net::IsCertStatusMinorError( |
| 656 | visible_security_state.cert_status))) { |
estark | fcfccdb8 | 2016-11-14 02:17:29 | [diff] [blame] | 657 | // HTTPS with no or minor errors. |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 658 | if (security_level == security_state::SECURE_WITH_POLICY_INSTALLED_CERT) { |
Eric Lawrence | 6758d1d | 2017-11-21 16:06:05 | [diff] [blame] | 659 | #if defined(OS_CHROMEOS) |
[email protected] | eaf3f32 | 2013-04-25 21:53:59 | [diff] [blame] | 660 | site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT; |
[email protected] | 24a9f1c9 | 2013-11-13 12:33:37 | [diff] [blame] | 661 | site_identity_details_ = l10n_util::GetStringFUTF16( |
| 662 | IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host())); |
Eric Lawrence | 6758d1d | 2017-11-21 16:06:05 | [diff] [blame] | 663 | #else |
| 664 | DCHECK(false) << "Policy certificates exist only on ChromeOS"; |
| 665 | #endif |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 666 | } else if (net::IsCertStatusMinorError( |
| 667 | visible_security_state.cert_status)) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 668 | site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN; |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 669 | base::string16 issuer_name( |
| 670 | UTF8ToUTF16(certificate_->issuer().GetDisplayName())); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 671 | if (issuer_name.empty()) { |
| 672 | issuer_name.assign(l10n_util::GetStringUTF16( |
| 673 | IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 674 | } |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 675 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 676 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 677 | IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name)); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 678 | |
| 679 | site_identity_details_ += ASCIIToUTF16("\n\n"); |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 680 | if (visible_security_state.cert_status & |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 681 | net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 682 | site_identity_details_ += l10n_util::GetStringUTF16( |
| 683 | IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION); |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 684 | } else if (visible_security_state.cert_status & |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 685 | net::CERT_STATUS_NO_REVOCATION_MECHANISM) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 686 | site_identity_details_ += l10n_util::GetStringUTF16( |
| 687 | IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM); |
| 688 | } else { |
| 689 | NOTREACHED() << "Need to specify string for this warning"; |
| 690 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 691 | } else { |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 692 | // No major or minor errors. |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 693 | if (visible_security_state.cert_status & net::CERT_STATUS_IS_EV) { |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 694 | // EV HTTPS page. |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 695 | site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT; |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 696 | DCHECK(!certificate_->subject().organization_names.empty()); |
| 697 | organization_name_ = |
| 698 | UTF8ToUTF16(certificate_->subject().organization_names[0]); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 699 | // An EV Cert is required to have a city (localityName) and country but |
| 700 | // state is "if any". |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 701 | DCHECK(!certificate_->subject().locality_name.empty()); |
| 702 | DCHECK(!certificate_->subject().country_name.empty()); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 703 | base::string16 locality; |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 704 | if (!certificate_->subject().state_or_province_name.empty()) { |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 705 | locality = l10n_util::GetStringFUTF16( |
lgarron | fc1d5e5 | 2017-05-03 23:15:21 | [diff] [blame] | 706 | IDS_PAGE_INFO_ADDRESS, |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 707 | UTF8ToUTF16(certificate_->subject().locality_name), |
| 708 | UTF8ToUTF16(certificate_->subject().state_or_province_name), |
| 709 | UTF8ToUTF16(certificate_->subject().country_name)); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 710 | } else { |
| 711 | locality = l10n_util::GetStringFUTF16( |
lgarron | fc1d5e5 | 2017-05-03 23:15:21 | [diff] [blame] | 712 | IDS_PAGE_INFO_PARTIAL_ADDRESS, |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 713 | UTF8ToUTF16(certificate_->subject().locality_name), |
| 714 | UTF8ToUTF16(certificate_->subject().country_name)); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 715 | } |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 716 | DCHECK(!certificate_->subject().organization_names.empty()); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 717 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 718 | IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED, |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 719 | UTF8ToUTF16(certificate_->subject().organization_names[0]), |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 720 | locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName()))); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 721 | } else { |
| 722 | // Non-EV OK HTTPS page. |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 723 | site_identity_status_ = SITE_IDENTITY_STATUS_CERT; |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 724 | base::string16 issuer_name( |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 725 | UTF8ToUTF16(certificate_->issuer().GetDisplayName())); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 726 | if (issuer_name.empty()) { |
| 727 | issuer_name.assign(l10n_util::GetStringUTF16( |
| 728 | IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 729 | } |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 730 | |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 731 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
estark | cf30556 | 2016-11-15 03:45:39 | [diff] [blame] | 732 | IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name)); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 733 | } |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 734 | if (security_state::IsSHA1InChain(visible_security_state)) { |
elawrence | be87bd6 | 2017-01-10 16:08:59 | [diff] [blame] | 735 | site_identity_status_ = |
| 736 | SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM; |
| 737 | site_identity_details_ += |
| 738 | UTF8ToUTF16("\n\n") + |
| 739 | l10n_util::GetStringUTF16( |
| 740 | IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 741 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 742 | } |
| 743 | } else { |
| 744 | // HTTP or HTTPS with errors (not warnings). |
| 745 | site_identity_details_.assign(l10n_util::GetStringUTF16( |
| 746 | IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY)); |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 747 | if (!security_state::IsSchemeCryptographic(visible_security_state.url) || |
| 748 | !visible_security_state.certificate) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 749 | site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT; |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 750 | } else { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 751 | site_identity_status_ = SITE_IDENTITY_STATUS_ERROR; |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 752 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 753 | |
[email protected] | a04db82 | 2013-12-11 19:14:40 | [diff] [blame] | 754 | const base::string16 bullet = UTF8ToUTF16("\n • "); |
felt | 2493b445 | 2015-09-17 20:33:59 | [diff] [blame] | 755 | std::vector<ssl_errors::ErrorInfo> errors; |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 756 | ssl_errors::ErrorInfo::GetErrorsForCertStatus( |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 757 | certificate_, visible_security_state.cert_status, url, &errors); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 758 | for (size_t i = 0; i < errors.size(); ++i) { |
| 759 | site_identity_details_ += bullet; |
| 760 | site_identity_details_ += errors[i].short_description(); |
| 761 | } |
| 762 | |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 763 | if (visible_security_state.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 764 | site_identity_details_ += ASCIIToUTF16("\n\n"); |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 765 | site_identity_details_ += |
| 766 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 767 | } |
| 768 | } |
| 769 | |
| 770 | // Site Connection |
| 771 | // We consider anything less than 80 bits encryption to be weak encryption. |
| 772 | // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and |
| 773 | // weakly encrypted connections. |
| 774 | site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN; |
| 775 | |
jshin | 1fb7646 | 2016-04-05 22:13:03 | [diff] [blame] | 776 | base::string16 subject_name(GetSimpleSiteName(url)); |
palmer | 153af98 | 2015-09-15 02:04:19 | [diff] [blame] | 777 | if (subject_name.empty()) { |
| 778 | subject_name.assign( |
| 779 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 780 | } |
| 781 | |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 782 | if (!visible_security_state.certificate || |
| 783 | !security_state::IsSchemeCryptographic(visible_security_state.url)) { |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 784 | // Page is still loading (so SSL status is not yet available) or |
| 785 | // loaded over HTTP or loaded over HTTPS with no cert. |
[email protected] | 1c1051d | 2014-05-10 11:39:58 | [diff] [blame] | 786 | site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED; |
| 787 | |
| 788 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 789 | IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, |
| 790 | subject_name)); |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 791 | } else if (!visible_security_state.connection_info_initialized) { |
| 792 | DCHECK_NE(security_level, security_state::NONE); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 793 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 794 | } else { |
| 795 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED; |
Adam Langley | 71c2b59b | 2014-11-13 00:34:22 | [diff] [blame] | 796 | |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 797 | if (net::ObsoleteSSLStatus( |
| 798 | visible_security_state.connection_status, |
| 799 | visible_security_state.peer_signature_algorithm) == |
| 800 | net::OBSOLETE_SSL_NONE) { |
Adam Langley | 71c2b59b | 2014-11-13 00:34:22 | [diff] [blame] | 801 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 802 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, subject_name)); |
Adam Langley | 71c2b59b | 2014-11-13 00:34:22 | [diff] [blame] | 803 | } else { |
| 804 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 805 | IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT, |
| 806 | subject_name)); |
| 807 | } |
| 808 | |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 809 | ReportAnyInsecureContent(visible_security_state, &site_connection_status_, |
thestig | 4427f13b | 2017-06-20 20:42:47 | [diff] [blame] | 810 | &site_connection_details_); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 811 | } |
| 812 | |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 813 | uint16_t cipher_suite = net::SSLConnectionStatusToCipherSuite( |
| 814 | visible_security_state.connection_status); |
| 815 | if (visible_security_state.connection_info_initialized && cipher_suite) { |
| 816 | int ssl_version = net::SSLConnectionStatusToVersion( |
| 817 | visible_security_state.connection_status); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 818 | const char* ssl_version_str; |
| 819 | net::SSLVersionToString(&ssl_version_str, ssl_version); |
| 820 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
| 821 | site_connection_details_ += l10n_util::GetStringFUTF16( |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 822 | IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, ASCIIToUTF16(ssl_version_str)); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 823 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 824 | const char *key_exchange, *cipher, *mac; |
davidben | 56a8aece | 2016-10-14 18:20:56 | [diff] [blame] | 825 | bool is_aead, is_tls13; |
| 826 | net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, |
| 827 | &is_tls13, cipher_suite); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 828 | |
| 829 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
[email protected] | b6c1d9e8 | 2013-06-12 17:26:57 | [diff] [blame] | 830 | if (is_aead) { |
davidben | 56a8aece | 2016-10-14 18:20:56 | [diff] [blame] | 831 | if (is_tls13) { |
| 832 | // For TLS 1.3 ciphers, report the group (historically, curve) as the |
| 833 | // key exchange. |
Emily Stark | d75d54ce | 2019-03-12 20:23:09 | [diff] [blame] | 834 | key_exchange = |
| 835 | SSL_get_curve_name(visible_security_state.key_exchange_group); |
davidben | 56a8aece | 2016-10-14 18:20:56 | [diff] [blame] | 836 | if (!key_exchange) { |
| 837 | NOTREACHED(); |
| 838 | key_exchange = ""; |
| 839 | } |
| 840 | } |
[email protected] | b6c1d9e8 | 2013-06-12 17:26:57 | [diff] [blame] | 841 | site_connection_details_ += l10n_util::GetStringFUTF16( |
| 842 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD, |
| 843 | ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange)); |
| 844 | } else { |
| 845 | site_connection_details_ += l10n_util::GetStringFUTF16( |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 846 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, ASCIIToUTF16(cipher), |
| 847 | ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange)); |
[email protected] | b6c1d9e8 | 2013-06-12 17:26:57 | [diff] [blame] | 848 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 849 | } |
[email protected] | e583f75 | 2012-08-30 13:26:21 | [diff] [blame] | 850 | |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 851 | // Check if a user decision has been made to allow or deny certificates with |
| 852 | // errors on this site. |
| 853 | ChromeSSLHostStateDelegate* delegate = |
estark | 7c6bfbf | 2015-09-16 22:20:50 | [diff] [blame] | 854 | ChromeSSLHostStateDelegateFactory::GetForProfile(profile_); |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 855 | DCHECK(delegate); |
jww | f806c36 | 2015-06-02 02:00:40 | [diff] [blame] | 856 | // Only show an SSL decision revoke button if the user has chosen to bypass |
| 857 | // SSL host errors for this host in the past. |
| 858 | show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host()); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 859 | } |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 860 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 861 | void PageInfo::PresentSitePermissions() { |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 862 | PermissionInfoList permission_info_list; |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 863 | ChosenObjectInfoList chosen_object_info_list; |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 864 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 865 | PageInfoUI::PermissionInfo permission_info; |
Avi Drissman | 22f8287 | 2018-12-25 23:09:07 | [diff] [blame] | 866 | for (size_t i = 0; i < base::size(kPermissionType); ++i) { |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 867 | permission_info.type = kPermissionType[i]; |
| 868 | |
| 869 | content_settings::SettingInfo info; |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 870 | std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting( |
| 871 | site_url_, site_url_, permission_info.type, std::string(), &info); |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 872 | DCHECK(value.get()); |
jdoerrie | 76cee9c | 2017-10-06 22:42:42 | [diff] [blame] | 873 | if (value->type() == base::Value::Type::INTEGER) { |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 874 | permission_info.setting = |
| 875 | content_settings::ValueToContentSetting(value.get()); |
[email protected] | fe4686a | 2012-10-19 15:38:26 | [diff] [blame] | 876 | } else { |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 877 | NOTREACHED(); |
[email protected] | fe4686a | 2012-10-19 15:38:26 | [diff] [blame] | 878 | } |
| 879 | |
[email protected] | 8bdf45c3 | 2012-08-04 00:12:55 | [diff] [blame] | 880 | permission_info.source = info.source; |
johnme | 9ed9388 | 2016-01-15 01:13:28 | [diff] [blame] | 881 | permission_info.is_incognito = profile_->IsOffTheRecord(); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 882 | |
[email protected] | b1d113d | 2012-06-27 21:27:34 | [diff] [blame] | 883 | if (info.primary_pattern == ContentSettingsPattern::Wildcard() && |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 884 | info.secondary_pattern == ContentSettingsPattern::Wildcard()) { |
[email protected] | b1d113d | 2012-06-27 21:27:34 | [diff] [blame] | 885 | permission_info.default_setting = permission_info.setting; |
| 886 | permission_info.setting = CONTENT_SETTING_DEFAULT; |
| 887 | } else { |
| 888 | permission_info.default_setting = |
| 889 | content_settings_->GetDefaultContentSetting(permission_info.type, |
| 890 | NULL); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 891 | } |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 892 | |
patricialor | 2a4f41a | 2017-03-08 02:52:56 | [diff] [blame] | 893 | // For permissions that are still prompting the user and haven't been |
| 894 | // explicitly set by another source, check its embargo status. |
| 895 | if (PermissionUtil::IsPermission(permission_info.type) && |
| 896 | permission_info.setting == CONTENT_SETTING_DEFAULT && |
| 897 | permission_info.source == |
| 898 | content_settings::SettingSource::SETTING_SOURCE_USER) { |
| 899 | // TODO(raymes): Use GetPermissionStatus() to retrieve information |
| 900 | // about *all* permissions once it has default behaviour implemented for |
| 901 | // ContentSettingTypes that aren't permissions. |
| 902 | PermissionResult permission_result = |
| 903 | PermissionManager::Get(profile_)->GetPermissionStatus( |
| 904 | permission_info.type, site_url_, site_url_); |
| 905 | |
| 906 | // If under embargo, update |permission_info| to reflect that. |
| 907 | if (permission_result.content_setting == CONTENT_SETTING_BLOCK && |
Timothy Loh | 8fbdac5 | 2018-03-15 03:34:30 | [diff] [blame] | 908 | permission_result.source == |
| 909 | PermissionStatusSource::MULTIPLE_DISMISSALS) { |
patricialor | 2a4f41a | 2017-03-08 02:52:56 | [diff] [blame] | 910 | permission_info.setting = permission_result.content_setting; |
Timothy Loh | 8fbdac5 | 2018-03-15 03:34:30 | [diff] [blame] | 911 | } |
patricialor | 2a4f41a | 2017-03-08 02:52:56 | [diff] [blame] | 912 | } |
| 913 | |
Tommy Steimel | c9f6c93 | 2017-10-13 23:33:04 | [diff] [blame] | 914 | if (ShouldShowPermission(permission_info, site_url_, content_settings_, |
shahriar rostami | a9c769d | 2017-12-06 04:54:08 | [diff] [blame] | 915 | web_contents(), tab_specific_content_settings())) { |
Patti | 0601e53 | 2017-09-20 08:39:30 | [diff] [blame] | 916 | permission_info_list.push_back(permission_info); |
Tommy Steimel | c9f6c93 | 2017-10-13 23:33:04 | [diff] [blame] | 917 | } |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 918 | } |
| 919 | |
Reilly Grant | bcdeddb | 2019-05-06 22:37:24 | [diff] [blame] | 920 | const auto origin = url::Origin::Create(site_url_); |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 921 | for (const ChooserUIInfo& ui_info : kChooserUIInfo) { |
| 922 | ChooserContextBase* context = ui_info.get_context(profile_); |
reillyg | 36a7fab3 | 2016-01-28 19:15:10 | [diff] [blame] | 923 | auto chosen_objects = context->GetGrantedObjects(origin, origin); |
Ovidio Henriquez | 0e7c32a | 2019-01-16 03:15:29 | [diff] [blame] | 924 | for (std::unique_ptr<ChooserContextBase::Object>& object : chosen_objects) { |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 925 | chosen_object_info_list.push_back( |
Jinho Bang | cc28079 | 2018-01-17 23:33:55 | [diff] [blame] | 926 | std::make_unique<PageInfoUI::ChosenObjectInfo>(ui_info, |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 927 | std::move(object))); |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 928 | } |
| 929 | } |
| 930 | |
avi | 09dd4d0 | 2016-10-14 20:40:09 | [diff] [blame] | 931 | ui_->SetPermissionInfo(permission_info_list, |
| 932 | std::move(chosen_object_info_list)); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 933 | } |
| 934 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 935 | void PageInfo::PresentSiteData() { |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 936 | CookieInfoList cookie_info_list; |
vabr | bab3ffcb | 2016-10-04 10:08:10 | [diff] [blame] | 937 | const LocalSharedObjectsContainer& allowed_objects = |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 938 | tab_specific_content_settings()->allowed_local_shared_objects(); |
vabr | bab3ffcb | 2016-10-04 10:08:10 | [diff] [blame] | 939 | const LocalSharedObjectsContainer& blocked_objects = |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 940 | tab_specific_content_settings()->blocked_local_shared_objects(); |
| 941 | |
| 942 | // Add first party cookie and site data counts. |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 943 | PageInfoUI::CookieInfo cookie_info; |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 944 | cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_); |
| 945 | cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_); |
palmer | b14526492 | 2015-08-28 23:53:15 | [diff] [blame] | 946 | cookie_info.is_first_party = true; |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 947 | cookie_info_list.push_back(cookie_info); |
| 948 | |
| 949 | // Add third party cookie counts. |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 950 | cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed; |
| 951 | cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked; |
palmer | b14526492 | 2015-08-28 23:53:15 | [diff] [blame] | 952 | cookie_info.is_first_party = false; |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 953 | cookie_info_list.push_back(cookie_info); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 954 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 955 | ui_->SetCookieInfo(cookie_info_list); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 956 | } |
[email protected] | 16de6de | 2012-04-04 12:24:14 | [diff] [blame] | 957 | |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 958 | void PageInfo::PresentSiteIdentity() { |
palmer | f9b680a | 2015-07-09 18:56:04 | [diff] [blame] | 959 | // After initialization the status about the site's connection and its |
| 960 | // identity must be available. |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 961 | DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN); |
| 962 | DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN); |
lgarron | 617a30f3 | 2017-03-24 21:42:07 | [diff] [blame] | 963 | PageInfoUI::IdentityInfo info; |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 964 | if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT) |
| 965 | info.site_identity = UTF16ToUTF8(organization_name()); |
| 966 | else |
jshin | 1fb7646 | 2016-04-05 22:13:03 | [diff] [blame] | 967 | info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_)); |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 968 | |
| 969 | info.connection_status = site_connection_status_; |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 970 | info.connection_status_description = UTF16ToUTF8(site_connection_details_); |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 971 | info.identity_status = site_identity_status_; |
lgarron | 1a6300d | 2017-03-18 03:33:04 | [diff] [blame] | 972 | info.identity_status_description = UTF16ToUTF8(site_identity_details_); |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 973 | info.certificate = certificate_; |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 974 | info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; |
Jialiu Lin | 11e1854 | 2017-08-14 18:16:26 | [diff] [blame] | 975 | info.show_change_password_buttons = show_change_password_buttons_; |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 976 | ui_->SetIdentityInfo(info); |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 977 | } |
Patti | 7f21c4b | 2017-11-28 03:37:17 | [diff] [blame] | 978 | |
Suman Kancherla | d54a6e5b | 2019-01-29 22:17:49 | [diff] [blame] | 979 | void PageInfo::PresentPageFeatureInfo() { |
| 980 | PageInfoUI::PageFeatureInfo info; |
| 981 | info.is_vr_presentation_in_headset = |
| 982 | vr::VrTabHelper::IsContentDisplayedInHeadset(web_contents()); |
| 983 | |
| 984 | ui_->SetPageFeatureInfo(info); |
| 985 | } |
| 986 | |
Joe DeBlasio | c7187e6 | 2019-04-25 21:14:15 | [diff] [blame] | 987 | #if defined(FULL_SAFE_BROWSING) |
| 988 | void PageInfo::RecordPasswordReuseEvent() { |
| 989 | if (!password_protection_service_) { |
| 990 | return; |
| 991 | } |
| 992 | |
| 993 | if (site_identity_status_ == SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE) { |
| 994 | safe_browsing::LogWarningAction( |
| 995 | safe_browsing::WarningUIType::PAGE_INFO, |
| 996 | safe_browsing::WarningAction::SHOWN, |
| 997 | safe_browsing::LoginReputationClientRequest::PasswordReuseEvent:: |
| 998 | SIGN_IN_PASSWORD, |
| 999 | password_protection_service_->GetSyncAccountType()); |
| 1000 | } else { |
| 1001 | safe_browsing::LogWarningAction( |
| 1002 | safe_browsing::WarningUIType::PAGE_INFO, |
| 1003 | safe_browsing::WarningAction::SHOWN, |
| 1004 | safe_browsing::LoginReputationClientRequest::PasswordReuseEvent:: |
| 1005 | ENTERPRISE_PASSWORD, |
| 1006 | password_protection_service_->GetSyncAccountType()); |
| 1007 | } |
| 1008 | } |
| 1009 | #endif |
| 1010 | |
Patti | 7f21c4b | 2017-11-28 03:37:17 | [diff] [blame] | 1011 | std::vector<ContentSettingsType> PageInfo::GetAllPermissionsForTesting() { |
| 1012 | std::vector<ContentSettingsType> permission_list; |
Avi Drissman | 22f8287 | 2018-12-25 23:09:07 | [diff] [blame] | 1013 | for (size_t i = 0; i < base::size(kPermissionType); ++i) { |
Patti | 7f21c4b | 2017-11-28 03:37:17 | [diff] [blame] | 1014 | #if !defined(OS_ANDROID) |
| 1015 | if (kPermissionType[i] == CONTENT_SETTINGS_TYPE_AUTOPLAY) |
| 1016 | continue; |
| 1017 | #endif |
| 1018 | permission_list.push_back(kPermissionType[i]); |
| 1019 | } |
| 1020 | return permission_list; |
| 1021 | } |
Jialiu Lin | 4d7c604 | 2018-04-04 17:45:35 | [diff] [blame] | 1022 | |
| 1023 | void PageInfo::GetSiteIdentityByMaliciousContentStatus( |
| 1024 | security_state::MaliciousContentStatus malicious_content_status, |
| 1025 | PageInfo::SiteIdentityStatus* status, |
| 1026 | base::string16* details) { |
| 1027 | switch (malicious_content_status) { |
| 1028 | case security_state::MALICIOUS_CONTENT_STATUS_NONE: |
| 1029 | NOTREACHED(); |
| 1030 | break; |
| 1031 | case security_state::MALICIOUS_CONTENT_STATUS_MALWARE: |
| 1032 | *status = PageInfo::SITE_IDENTITY_STATUS_MALWARE; |
| 1033 | *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MALWARE_DETAILS); |
| 1034 | break; |
| 1035 | case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING: |
| 1036 | *status = PageInfo::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING; |
| 1037 | *details = |
| 1038 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_SOCIAL_ENGINEERING_DETAILS); |
| 1039 | break; |
| 1040 | case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE: |
| 1041 | *status = PageInfo::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE; |
| 1042 | *details = |
| 1043 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_UNWANTED_SOFTWARE_DETAILS); |
| 1044 | break; |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 1045 | case security_state::MALICIOUS_CONTENT_STATUS_SIGN_IN_PASSWORD_REUSE: |
Michael Thiessen | 4c9e4a8 | 2019-03-08 04:39:44 | [diff] [blame] | 1046 | #if defined(FULL_SAFE_BROWSING) |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 1047 | *status = PageInfo::SITE_IDENTITY_STATUS_SIGN_IN_PASSWORD_REUSE; |
| 1048 | // |password_protection_service_| may be null in test. |
| 1049 | *details = password_protection_service_ |
| 1050 | ? password_protection_service_->GetWarningDetailText( |
| 1051 | PasswordReuseEvent::SIGN_IN_PASSWORD) |
| 1052 | : base::string16(); |
| 1053 | #endif |
| 1054 | break; |
| 1055 | case security_state::MALICIOUS_CONTENT_STATUS_ENTERPRISE_PASSWORD_REUSE: |
Michael Thiessen | 4c9e4a8 | 2019-03-08 04:39:44 | [diff] [blame] | 1056 | #if defined(FULL_SAFE_BROWSING) |
Jialiu Lin | d7defe65 | 2018-06-20 18:47:06 | [diff] [blame] | 1057 | *status = PageInfo::SITE_IDENTITY_STATUS_ENTERPRISE_PASSWORD_REUSE; |
| 1058 | // |password_protection_service_| maybe null in test. |
| 1059 | *details = password_protection_service_ |
| 1060 | ? password_protection_service_->GetWarningDetailText( |
| 1061 | PasswordReuseEvent::ENTERPRISE_PASSWORD) |
| 1062 | : base::string16(); |
Jialiu Lin | 4d7c604 | 2018-04-04 17:45:35 | [diff] [blame] | 1063 | #endif |
| 1064 | break; |
spqchan | 6da308a | 2018-08-10 19:19:53 | [diff] [blame] | 1065 | case security_state::MALICIOUS_CONTENT_STATUS_BILLING: |
spqchan | 6da308a | 2018-08-10 19:19:53 | [diff] [blame] | 1066 | *status = PageInfo::SITE_IDENTITY_STATUS_BILLING; |
| 1067 | *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_BILLING_DETAILS); |
spqchan | 6da308a | 2018-08-10 19:19:53 | [diff] [blame] | 1068 | break; |
Jialiu Lin | 4d7c604 | 2018-04-04 17:45:35 | [diff] [blame] | 1069 | } |
| 1070 | } |