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