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