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