[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 | |
[email protected] | 4237dd5 | 2012-06-05 00:00:32 | [diff] [blame] | 5 | #include "chrome/browser/ui/website_settings/website_settings.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" |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 16 | #include "base/metrics/field_trial.h" |
asvitkine | 7503603 | 2016-09-01 20:49:34 | [diff] [blame] | 17 | #include "base/metrics/histogram_macros.h" |
[email protected] | 3ea1b18 | 2013-02-08 22:38:41 | [diff] [blame] | 18 | #include "base/strings/string_number_conversions.h" |
jialiul | 02aad2d | 2015-04-01 18:56:03 | [diff] [blame] | 19 | #include "base/strings/stringprintf.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" |
[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" |
tsergeant | f1e8935 | 2016-01-15 20:34:54 | [diff] [blame] | 34 | #include "chrome/browser/permissions/permission_uma_util.h" |
| 35 | #include "chrome/browser/permissions/permission_util.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 36 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 37 | #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" |
| 38 | #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" |
[email protected] | 4237dd5 | 2012-06-05 00:00:32 | [diff] [blame] | 39 | #include "chrome/browser/ui/website_settings/website_settings_ui.h" |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 40 | #include "chrome/browser/usb/usb_chooser_context.h" |
| 41 | #include "chrome/browser/usb/usb_chooser_context_factory.h" |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 42 | #include "chrome/common/chrome_switches.h" |
sievers | 2f1e811 | 2015-12-04 18:43:56 | [diff] [blame] | 43 | #include "chrome/common/features.h" |
jsbell | ddb849e | 2015-08-27 00:12:56 | [diff] [blame] | 44 | #include "chrome/common/url_constants.h" |
thestig | 884a160 | 2014-08-27 01:29:39 | [diff] [blame] | 45 | #include "chrome/grit/chromium_strings.h" |
| 46 | #include "chrome/grit/generated_resources.h" |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 47 | #include "chrome/grit/theme_resources.h" |
mukai | 8eaec82 | 2014-10-25 17:53:16 | [diff] [blame] | 48 | #include "components/content_settings/core/browser/content_settings_utils.h" |
| 49 | #include "components/content_settings/core/browser/host_content_settings_map.h" |
vabr | 4856559 | 2014-10-08 15:06:02 | [diff] [blame] | 50 | #include "components/content_settings/core/browser/local_shared_objects_counter.h" |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 51 | #include "components/content_settings/core/common/content_settings.h" |
vasilii | f62dbf9 | 2014-09-05 10:23:13 | [diff] [blame] | 52 | #include "components/content_settings/core/common/content_settings_pattern.h" |
jialiul | 02aad2d | 2015-04-01 18:56:03 | [diff] [blame] | 53 | #include "components/rappor/rappor_utils.h" |
felt | 2493b445 | 2015-09-17 20:33:59 | [diff] [blame] | 54 | #include "components/ssl_errors/error_info.h" |
thestig | 4a2e88e | 2016-08-27 23:23:51 | [diff] [blame] | 55 | #include "components/strings/grit/components_chromium_strings.h" |
| 56 | #include "components/strings/grit/components_strings.h" |
palmer | 153af98 | 2015-09-15 02:04:19 | [diff] [blame] | 57 | #include "components/url_formatter/elide_url.h" |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 58 | #include "content/public/browser/browser_thread.h" |
tsergeant | f1e8935 | 2016-01-15 20:34:54 | [diff] [blame] | 59 | #include "content/public/browser/permission_type.h" |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 60 | #include "content/public/browser/user_metrics.h" |
[email protected] | eb2140c | 2013-07-29 12:37:34 | [diff] [blame] | 61 | #include "content/public/common/content_switches.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 62 | #include "content/public/common/url_constants.h" |
[email protected] | 6e7845ae | 2013-03-29 21:48:11 | [diff] [blame] | 63 | #include "net/cert/cert_status_flags.h" |
| 64 | #include "net/cert/x509_certificate.h" |
[email protected] | 536fd0b | 2013-03-14 17:41:57 | [diff] [blame] | 65 | #include "net/ssl/ssl_cipher_suite_names.h" |
| 66 | #include "net/ssl/ssl_connection_status_flags.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 67 | #include "ui/base/l10n/l10n_util.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 68 | |
[email protected] | 24a9f1c9 | 2013-11-13 12:33:37 | [diff] [blame] | 69 | #if defined(OS_CHROMEOS) |
| 70 | #include "chrome/browser/chromeos/policy/policy_cert_service.h" |
| 71 | #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" |
| 72 | #endif |
| 73 | |
estade | 3feb83f | 2015-09-01 23:00:49 | [diff] [blame] | 74 | #if !defined(OS_ANDROID) |
mgiuca | a319f21 | 2016-01-14 03:30:11 | [diff] [blame] | 75 | #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
estade | 3feb83f | 2015-09-01 23:00:49 | [diff] [blame] | 76 | #include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h" |
| 77 | #endif |
| 78 | |
[email protected] | ab6df3b1 | 2013-12-24 23:32:26 | [diff] [blame] | 79 | using base::ASCIIToUTF16; |
| 80 | using base::UTF8ToUTF16; |
[email protected] | f729d7a | 2013-12-26 07:07:56 | [diff] [blame] | 81 | using base::UTF16ToUTF8; |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 82 | using content::BrowserThread; |
estark | d9e54fb | 2016-01-11 19:37:12 | [diff] [blame] | 83 | using security_state::SecurityStateModel; |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 84 | |
| 85 | namespace { |
| 86 | |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 87 | // Events for UMA. Do not reorder or change! |
| 88 | enum SSLCertificateDecisionsDidRevoke { |
| 89 | USER_CERT_DECISIONS_NOT_REVOKED = 0, |
| 90 | USER_CERT_DECISIONS_REVOKED, |
| 91 | END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM |
| 92 | }; |
| 93 | |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 94 | // The list of content settings types to display on the Website Settings UI. THE |
| 95 | // ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, email |
| 96 | // [email protected]. |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 97 | ContentSettingsType kPermissionType[] = { |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 98 | CONTENT_SETTINGS_TYPE_GEOLOCATION, |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 99 | CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
| 100 | CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 101 | CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 102 | CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
lshang | e085f20 | 2016-06-14 01:25:08 | [diff] [blame] | 103 | #if !defined(OS_ANDROID) |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 104 | CONTENT_SETTINGS_TYPE_PLUGINS, |
| 105 | CONTENT_SETTINGS_TYPE_IMAGES, |
lshang | e085f20 | 2016-06-14 01:25:08 | [diff] [blame] | 106 | #endif |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 107 | CONTENT_SETTINGS_TYPE_POPUPS, |
nsatragno | 670fe92 | 2016-04-08 14:10:50 | [diff] [blame] | 108 | CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 109 | CONTENT_SETTINGS_TYPE_KEYGEN, |
| 110 | CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, |
lshang | e085f20 | 2016-06-14 01:25:08 | [diff] [blame] | 111 | #if !defined(OS_ANDROID) |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 112 | CONTENT_SETTINGS_TYPE_MOUSELOCK, |
lshang | e085f20 | 2016-06-14 01:25:08 | [diff] [blame] | 113 | #endif |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 114 | CONTENT_SETTINGS_TYPE_FULLSCREEN, |
finnur | 46cafd4 | 2016-09-22 10:27:17 | [diff] [blame] | 115 | CONTENT_SETTINGS_TYPE_AUTOPLAY, |
palmer | 7715e33 | 2016-05-27 00:41:19 | [diff] [blame] | 116 | CONTENT_SETTINGS_TYPE_MIDI_SYSEX, |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 117 | }; |
| 118 | |
mgiuca | a319f21 | 2016-01-14 03:30:11 | [diff] [blame] | 119 | // Determines whether to show permission |type| in the Website Settings UI. Only |
| 120 | // applies to permissions listed in |kPermissionType|. |
| 121 | bool ShouldShowPermission(ContentSettingsType type) { |
mgiuca | 0f3e1f7 | 2016-05-13 01:56:27 | [diff] [blame] | 122 | // TODO(mgiuca): When simplified-fullscreen-ui is enabled permanently on |
| 123 | // Android, remove these from kPermissionType, rather than having this check |
mgiuca | a319f21 | 2016-01-14 03:30:11 | [diff] [blame] | 124 | // (http://crbug.com/577396). |
| 125 | #if !defined(OS_ANDROID) |
mgiuca | 0f3e1f7 | 2016-05-13 01:56:27 | [diff] [blame] | 126 | // Fullscreen and mouselock settings are no longer shown (always allow). |
finnur | 46cafd4 | 2016-09-22 10:27:17 | [diff] [blame] | 127 | // Autoplay is Android-only at the moment. |
| 128 | if (type == CONTENT_SETTINGS_TYPE_AUTOPLAY || |
| 129 | type == CONTENT_SETTINGS_TYPE_FULLSCREEN || |
mgiuca | a319f21 | 2016-01-14 03:30:11 | [diff] [blame] | 130 | type == CONTENT_SETTINGS_TYPE_MOUSELOCK) { |
mgiuca | 0f3e1f7 | 2016-05-13 01:56:27 | [diff] [blame] | 131 | return false; |
mgiuca | a319f21 | 2016-01-14 03:30:11 | [diff] [blame] | 132 | } |
| 133 | #endif |
| 134 | |
| 135 | return true; |
| 136 | } |
| 137 | |
estark | 00e83f1 | 2016-08-19 18:24:04 | [diff] [blame] | 138 | void CheckContentStatus(SecurityStateModel::ContentStatus content_status, |
| 139 | bool* displayed, |
| 140 | bool* ran) { |
| 141 | switch (content_status) { |
| 142 | case SecurityStateModel::CONTENT_STATUS_DISPLAYED: |
| 143 | *displayed = true; |
| 144 | break; |
| 145 | case SecurityStateModel::CONTENT_STATUS_RAN: |
| 146 | *ran = true; |
| 147 | break; |
| 148 | case SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN: |
| 149 | *displayed = true; |
| 150 | *ran = true; |
| 151 | break; |
| 152 | case SecurityStateModel::CONTENT_STATUS_UNKNOWN: |
| 153 | case SecurityStateModel::CONTENT_STATUS_NONE: |
| 154 | break; |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | void CheckForInsecureContent( |
| 159 | const SecurityStateModel::SecurityInfo& security_info, |
| 160 | bool* displayed, |
| 161 | bool* ran) { |
| 162 | CheckContentStatus(security_info.mixed_content_status, displayed, ran); |
| 163 | // Only consider subresources with certificate errors if the main |
| 164 | // resource was loaded over HTTPS without major certificate errors. If |
| 165 | // the main resource had a certificate error, then it would not be |
| 166 | // that useful (and would potentially be confusing) to warn about |
| 167 | // subesources that had certificate errors too. |
| 168 | if (net::IsCertStatusError(security_info.cert_status) && |
| 169 | !net::IsCertStatusMinorError(security_info.cert_status)) { |
| 170 | return; |
| 171 | } |
| 172 | CheckContentStatus(security_info.content_with_cert_errors_status, displayed, |
| 173 | ran); |
| 174 | } |
| 175 | |
estark | 134a982 | 2015-10-29 04:35:18 | [diff] [blame] | 176 | // Returns true if any of the given statuses match |status|. |
| 177 | bool CertificateTransparencyStatusMatchAny( |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 178 | const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses, |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 179 | net::ct::SCTVerifyStatus status) { |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 180 | for (const auto& verify_status : sct_verify_statuses) { |
| 181 | if (verify_status == status) |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 182 | return true; |
| 183 | } |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 184 | return false; |
| 185 | } |
| 186 | |
| 187 | int GetSiteIdentityDetailsMessageByCTInfo( |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 188 | const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses, |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 189 | bool is_ev) { |
| 190 | // No SCTs - no CT information. |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 191 | if (sct_verify_statuses.empty()) |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 192 | return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_NO_CT |
| 193 | : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_NO_CT); |
| 194 | |
estark | 134a982 | 2015-10-29 04:35:18 | [diff] [blame] | 195 | // Any valid SCT. |
| 196 | if (CertificateTransparencyStatusMatchAny(sct_verify_statuses, |
| 197 | net::ct::SCT_STATUS_OK)) |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 198 | return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_VERIFIED |
| 199 | : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_VERIFIED); |
| 200 | |
estark | 134a982 | 2015-10-29 04:35:18 | [diff] [blame] | 201 | // Any invalid SCT. |
eranm | b082a9ff | 2016-09-13 21:03:26 | [diff] [blame] | 202 | if (CertificateTransparencyStatusMatchAny( |
eranm | 194b45d | 2016-08-18 10:00:33 | [diff] [blame] | 203 | sct_verify_statuses, net::ct::SCT_STATUS_INVALID_TIMESTAMP) || |
| 204 | CertificateTransparencyStatusMatchAny( |
| 205 | sct_verify_statuses, net::ct::SCT_STATUS_INVALID_SIGNATURE)) |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 206 | return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_INVALID |
| 207 | : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_INVALID); |
| 208 | |
estark | 134a982 | 2015-10-29 04:35:18 | [diff] [blame] | 209 | // All SCTs are from unknown logs. |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 210 | return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_UNVERIFIED |
| 211 | : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_UNVERIFIED); |
| 212 | } |
| 213 | |
| 214 | // This function will return SITE_IDENTITY_STATUS_CERT or |
estark | 134a982 | 2015-10-29 04:35:18 | [diff] [blame] | 215 | // SITE_IDENTITY_STATUS_EV_CERT depending on |is_ev| unless all SCTs |
| 216 | // failed verification, in which case it will return |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 217 | // SITE_IDENTITY_STATUS_ERROR. |
| 218 | WebsiteSettings::SiteIdentityStatus GetSiteIdentityStatusByCTInfo( |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 219 | const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses, |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 220 | bool is_ev) { |
estark | 134a982 | 2015-10-29 04:35:18 | [diff] [blame] | 221 | if (sct_verify_statuses.empty() || |
| 222 | CertificateTransparencyStatusMatchAny(sct_verify_statuses, |
| 223 | net::ct::SCT_STATUS_OK)) |
| 224 | return is_ev ? WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT |
| 225 | : WebsiteSettings::SITE_IDENTITY_STATUS_CERT; |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 226 | |
estark | 134a982 | 2015-10-29 04:35:18 | [diff] [blame] | 227 | return WebsiteSettings::SITE_IDENTITY_STATUS_CT_ERROR; |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 228 | } |
| 229 | |
jshin | 1fb7646 | 2016-04-05 22:13:03 | [diff] [blame] | 230 | base::string16 GetSimpleSiteName(const GURL& url) { |
benwells | 2337b810 | 2016-04-20 01:53:53 | [diff] [blame] | 231 | return url_formatter::FormatUrlForSecurityDisplay( |
| 232 | url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS); |
palmer | 153af98 | 2015-09-15 02:04:19 | [diff] [blame] | 233 | } |
| 234 | |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 235 | ChooserContextBase* GetUsbChooserContext(Profile* profile) { |
| 236 | return UsbChooserContextFactory::GetForProfile(profile); |
| 237 | } |
| 238 | |
| 239 | // The list of chooser types that need to display entries in the Website |
| 240 | // Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, |
| 241 | // email [email protected]. |
| 242 | WebsiteSettings::ChooserUIInfo kChooserUIInfo[] = { |
reillyg | 58f82ab | 2016-08-03 01:49:52 | [diff] [blame] | 243 | {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext, |
| 244 | IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_WEBSITE_SETTINGS_USB_DEVICE_LABEL, |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 245 | IDS_WEBSITE_SETTINGS_DELETE_USB_DEVICE, "name"}, |
| 246 | }; |
| 247 | |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 248 | } // namespace |
| 249 | |
| 250 | WebsiteSettings::WebsiteSettings( |
| 251 | WebsiteSettingsUI* ui, |
| 252 | Profile* profile, |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 253 | TabSpecificContentSettings* tab_specific_content_settings, |
palmer | f2cba0d | 2015-08-27 23:15:06 | [diff] [blame] | 254 | content::WebContents* web_contents, |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 255 | const GURL& url, |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 256 | const SecurityStateModel::SecurityInfo& security_info) |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 257 | : TabSpecificContentSettings::SiteDataObserver( |
| 258 | tab_specific_content_settings), |
| 259 | ui_(ui), |
pkasting | acd1e12 | 2016-05-19 23:55:10 | [diff] [blame] | 260 | #if !defined(OS_ANDROID) |
palmer | f2cba0d | 2015-08-27 23:15:06 | [diff] [blame] | 261 | web_contents_(web_contents), |
pkasting | acd1e12 | 2016-05-19 23:55:10 | [diff] [blame] | 262 | #endif |
[email protected] | 66f15731 | 2012-08-01 13:50:26 | [diff] [blame] | 263 | show_info_bar_(false), |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 264 | site_url_(url), |
| 265 | site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN), |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 266 | site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN), |
peconn | 5100d43 | 2015-09-16 12:03:08 | [diff] [blame] | 267 | content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)), |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 268 | chrome_ssl_host_state_delegate_( |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 269 | ChromeSSLHostStateDelegateFactory::GetForProfile(profile)), |
palmer | 153af98 | 2015-09-15 02:04:19 | [diff] [blame] | 270 | did_revoke_user_ssl_decisions_(false), |
| 271 | profile_(profile) { |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 272 | Init(url, security_info); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 273 | |
| 274 | PresentSitePermissions(); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 275 | PresentSiteData(); |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 276 | PresentSiteIdentity(); |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 277 | |
| 278 | // Every time the Website Settings UI is opened a |WebsiteSettings| object is |
| 279 | // created. So this counts how ofter the Website Settings UI is opened. |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 280 | RecordWebsiteSettingsAction(WEBSITE_SETTINGS_OPENED); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 281 | } |
| 282 | |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 283 | WebsiteSettings::~WebsiteSettings() { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 284 | } |
| 285 | |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 286 | void WebsiteSettings::RecordWebsiteSettingsAction( |
| 287 | WebsiteSettingsAction action) { |
| 288 | UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", |
| 289 | action, |
| 290 | WEBSITE_SETTINGS_COUNT); |
| 291 | |
| 292 | // Use a separate histogram to record actions if they are done on a page with |
| 293 | // an HTTPS URL. Note that this *disregards* security status. |
palmer | ee0e5af | 2015-06-05 03:10:40 | [diff] [blame] | 294 | // |
| 295 | |
| 296 | // TODO(palmer): Consider adding a new histogram for |
| 297 | // GURL::SchemeIsCryptographic. (We don't want to replace this call with a |
| 298 | // call to that function because we don't want to change the meanings of |
| 299 | // existing metrics.) This would inform the decision to mark non-secure |
| 300 | // origins as Dubious or Non-Secure; the overall bug for that is |
| 301 | // crbug.com/454579. |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 302 | if (site_url_.SchemeIs(url::kHttpsScheme)) { |
| 303 | UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action.HttpsUrl", |
| 304 | action, |
| 305 | WEBSITE_SETTINGS_COUNT); |
| 306 | } |
| 307 | } |
| 308 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 309 | void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type, |
| 310 | ContentSetting setting) { |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 311 | // Count how often a permission for a specific content type is changed using |
| 312 | // the Website Settings UI. |
raymes | 4a13d43 | 2015-09-08 00:44:07 | [diff] [blame] | 313 | size_t num_values; |
| 314 | int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values); |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 315 | UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.OriginInfo.PermissionChanged", |
raymes | 4a13d43 | 2015-09-08 00:44:07 | [diff] [blame] | 316 | histogram_value, num_values); |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 317 | |
| 318 | if (setting == ContentSetting::CONTENT_SETTING_ALLOW) { |
| 319 | UMA_HISTOGRAM_ENUMERATION( |
| 320 | "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value, |
raymes | 4a13d43 | 2015-09-08 00:44:07 | [diff] [blame] | 321 | num_values); |
tommycli | 34cf29bf | 2016-09-08 05:46:25 | [diff] [blame] | 322 | |
| 323 | if (type == CONTENT_SETTINGS_TYPE_PLUGINS) { |
| 324 | rappor::SampleDomainAndRegistryFromGURL( |
| 325 | g_browser_process->rappor_service(), |
| 326 | "ContentSettings.Plugins.AddedAllowException", site_url_); |
| 327 | } |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 328 | } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) { |
| 329 | UMA_HISTOGRAM_ENUMERATION( |
| 330 | "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value, |
raymes | 4a13d43 | 2015-09-08 00:44:07 | [diff] [blame] | 331 | num_values); |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 332 | } |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 333 | |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 334 | // This is technically redundant given the histogram above, but putting the |
| 335 | // total count of permission changes in another histogram makes it easier to |
| 336 | // compare it against other kinds of actions in WebsiteSettings[PopupView]. |
| 337 | RecordWebsiteSettingsAction(WEBSITE_SETTINGS_CHANGED_PERMISSION); |
| 338 | |
stefanocs | 8b3490cc | 2016-07-28 05:32:52 | [diff] [blame] | 339 | PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( |
| 340 | this->profile_, this->site_url_, this->site_url_, type, |
| 341 | PermissionSourceUI::OIB); |
| 342 | |
raymes | fbaaaaa | 2015-11-10 02:20:40 | [diff] [blame] | 343 | content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type, |
| 344 | setting); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 345 | |
[email protected] | 66f15731 | 2012-08-01 13:50:26 | [diff] [blame] | 346 | show_info_bar_ = true; |
[email protected] | 2f45d54 | 2012-08-22 08:47:24 | [diff] [blame] | 347 | |
[email protected] | 2f45d54 | 2012-08-22 08:47:24 | [diff] [blame] | 348 | // Refresh the UI to reflect the new setting. |
| 349 | PresentSitePermissions(); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 350 | } |
| 351 | |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 352 | void WebsiteSettings::OnSiteChosenObjectDeleted( |
| 353 | const ChooserUIInfo& ui_info, |
| 354 | const base::DictionaryValue& object) { |
| 355 | // TODO(reillyg): Create metrics for revocations. crbug.com/556845 |
| 356 | ChooserContextBase* context = ui_info.get_context(profile_); |
reillyg | 36a7fab3 | 2016-01-28 19:15:10 | [diff] [blame] | 357 | const GURL origin = site_url_.GetOrigin(); |
| 358 | context->RevokeObjectPermission(origin, origin, object); |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 359 | |
| 360 | show_info_bar_ = true; |
| 361 | |
| 362 | // Refresh the UI to reflect the changed settings. |
| 363 | PresentSitePermissions(); |
| 364 | } |
| 365 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 366 | void WebsiteSettings::OnSiteDataAccessed() { |
| 367 | PresentSiteData(); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 368 | } |
| 369 | |
[email protected] | 66f15731 | 2012-08-01 13:50:26 | [diff] [blame] | 370 | void WebsiteSettings::OnUIClosing() { |
estade | 3feb83f | 2015-09-01 23:00:49 | [diff] [blame] | 371 | #if defined(OS_ANDROID) |
| 372 | NOTREACHED(); |
| 373 | #else |
palmer | f2cba0d | 2015-08-27 23:15:06 | [diff] [blame] | 374 | if (show_info_bar_ && web_contents_) { |
| 375 | InfoBarService* infobar_service = |
| 376 | InfoBarService::FromWebContents(web_contents_); |
| 377 | if (infobar_service) |
| 378 | WebsiteSettingsInfoBarDelegate::Create(infobar_service); |
| 379 | } |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 380 | |
| 381 | SSLCertificateDecisionsDidRevoke user_decision = |
| 382 | did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED |
| 383 | : USER_CERT_DECISIONS_NOT_REVOKED; |
| 384 | |
| 385 | UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions", |
| 386 | user_decision, |
| 387 | END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM); |
estade | 3feb83f | 2015-09-01 23:00:49 | [diff] [blame] | 388 | #endif |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() { |
| 392 | DCHECK(chrome_ssl_host_state_delegate_); |
jww | 6a55df7 | 2014-09-05 19:59:29 | [diff] [blame] | 393 | chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard( |
| 394 | site_url().host()); |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 395 | did_revoke_user_ssl_decisions_ = true; |
[email protected] | 66f15731 | 2012-08-01 13:50:26 | [diff] [blame] | 396 | } |
| 397 | |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 398 | void WebsiteSettings::Init( |
| 399 | const GURL& url, |
| 400 | const SecurityStateModel::SecurityInfo& security_info) { |
sashab | 97894ce | 2014-10-22 10:08:33 | [diff] [blame] | 401 | bool isChromeUINativeScheme = false; |
sievers | 2f1e811 | 2015-12-04 18:43:56 | [diff] [blame] | 402 | #if BUILDFLAG(ANDROID_JAVA_UI) |
sashab | 97894ce | 2014-10-22 10:08:33 | [diff] [blame] | 403 | isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme); |
| 404 | #endif |
| 405 | |
upendrag.gowda | 60886a6e | 2015-10-31 05:51:09 | [diff] [blame] | 406 | if (url.SchemeIs(url::kAboutScheme)) { |
| 407 | // All about: URLs except about:blank are redirected. |
| 408 | DCHECK_EQ(url::kAboutBlankURL, url.spec()); |
| 409 | site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT; |
| 410 | site_identity_details_ = |
| 411 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY); |
| 412 | site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED; |
| 413 | site_connection_details_ = l10n_util::GetStringFUTF16( |
| 414 | IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, |
| 415 | UTF8ToUTF16(url.spec())); |
| 416 | return; |
| 417 | } |
| 418 | |
| 419 | if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 420 | site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE; |
| 421 | site_identity_details_ = |
| 422 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE); |
| 423 | site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE; |
| 424 | return; |
| 425 | } |
| 426 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 427 | // Identity section. |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 428 | certificate_ = security_info.certificate; |
[email protected] | f61c1ce | 2012-05-09 13:55:11 | [diff] [blame] | 429 | |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 430 | // HTTPS with no or minor errors. |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 431 | if (certificate_ && |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 432 | (!net::IsCertStatusError(security_info.cert_status) || |
| 433 | net::IsCertStatusMinorError(security_info.cert_status))) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 434 | // There are no major errors. Check for minor errors. |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 435 | if (security_info.security_level == |
felt | 89f3f21 | 2016-09-27 00:20:30 | [diff] [blame] | 436 | SecurityStateModel::SECURE_WITH_POLICY_INSTALLED_CERT) { |
[email protected] | eaf3f32 | 2013-04-25 21:53:59 | [diff] [blame] | 437 | site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT; |
[email protected] | 24a9f1c9 | 2013-11-13 12:33:37 | [diff] [blame] | 438 | site_identity_details_ = l10n_util::GetStringFUTF16( |
| 439 | IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host())); |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 440 | } else if (net::IsCertStatusMinorError(security_info.cert_status)) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 441 | site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN; |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 442 | base::string16 issuer_name( |
| 443 | UTF8ToUTF16(certificate_->issuer().GetDisplayName())); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 444 | if (issuer_name.empty()) { |
| 445 | issuer_name.assign(l10n_util::GetStringUTF16( |
| 446 | IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 447 | } |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 448 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 449 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 450 | GetSiteIdentityDetailsMessageByCTInfo( |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 451 | security_info.sct_verify_statuses, false /* not EV */), |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 452 | issuer_name)); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 453 | |
| 454 | site_identity_details_ += ASCIIToUTF16("\n\n"); |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 455 | if (security_info.cert_status & |
| 456 | net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 457 | site_identity_details_ += l10n_util::GetStringUTF16( |
| 458 | IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION); |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 459 | } else if (security_info.cert_status & |
| 460 | net::CERT_STATUS_NO_REVOCATION_MECHANISM) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 461 | site_identity_details_ += l10n_util::GetStringUTF16( |
| 462 | IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM); |
| 463 | } else { |
| 464 | NOTREACHED() << "Need to specify string for this warning"; |
| 465 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 466 | } else { |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 467 | if (security_info.cert_status & net::CERT_STATUS_IS_EV) { |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 468 | // EV HTTPS page. |
| 469 | site_identity_status_ = GetSiteIdentityStatusByCTInfo( |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 470 | security_info.sct_verify_statuses, true); |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 471 | DCHECK(!certificate_->subject().organization_names.empty()); |
| 472 | organization_name_ = |
| 473 | UTF8ToUTF16(certificate_->subject().organization_names[0]); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 474 | // An EV Cert is required to have a city (localityName) and country but |
| 475 | // state is "if any". |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 476 | DCHECK(!certificate_->subject().locality_name.empty()); |
| 477 | DCHECK(!certificate_->subject().country_name.empty()); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 478 | base::string16 locality; |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 479 | if (!certificate_->subject().state_or_province_name.empty()) { |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 480 | locality = l10n_util::GetStringFUTF16( |
| 481 | IDS_PAGEINFO_ADDRESS, |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 482 | UTF8ToUTF16(certificate_->subject().locality_name), |
| 483 | UTF8ToUTF16(certificate_->subject().state_or_province_name), |
| 484 | UTF8ToUTF16(certificate_->subject().country_name)); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 485 | } else { |
| 486 | locality = l10n_util::GetStringFUTF16( |
| 487 | IDS_PAGEINFO_PARTIAL_ADDRESS, |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 488 | UTF8ToUTF16(certificate_->subject().locality_name), |
| 489 | UTF8ToUTF16(certificate_->subject().country_name)); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 490 | } |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 491 | DCHECK(!certificate_->subject().organization_names.empty()); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 492 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
| 493 | GetSiteIdentityDetailsMessageByCTInfo( |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 494 | security_info.sct_verify_statuses, true /* is EV */), |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 495 | UTF8ToUTF16(certificate_->subject().organization_names[0]), |
| 496 | locality, |
| 497 | UTF8ToUTF16(certificate_->issuer().GetDisplayName()))); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 498 | } else { |
| 499 | // Non-EV OK HTTPS page. |
| 500 | site_identity_status_ = GetSiteIdentityStatusByCTInfo( |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 501 | security_info.sct_verify_statuses, false); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 502 | base::string16 issuer_name( |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 503 | UTF8ToUTF16(certificate_->issuer().GetDisplayName())); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 504 | if (issuer_name.empty()) { |
| 505 | issuer_name.assign(l10n_util::GetStringUTF16( |
| 506 | IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 507 | } |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 508 | |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 509 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
| 510 | GetSiteIdentityDetailsMessageByCTInfo( |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 511 | security_info.sct_verify_statuses, false /* not EV */), |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 512 | issuer_name)); |
| 513 | } |
lgarron | cc53de2 | 2015-10-05 23:03:17 | [diff] [blame] | 514 | switch (security_info.sha1_deprecation_status) { |
| 515 | case SecurityStateModel::DEPRECATED_SHA1_MINOR: |
| 516 | site_identity_status_ = |
| 517 | SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR; |
| 518 | site_identity_details_ += |
| 519 | UTF8ToUTF16("\n\n") + |
| 520 | l10n_util::GetStringUTF16( |
| 521 | IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MINOR); |
| 522 | break; |
| 523 | case SecurityStateModel::DEPRECATED_SHA1_MAJOR: |
| 524 | site_identity_status_ = |
| 525 | SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR; |
| 526 | site_identity_details_ += |
| 527 | UTF8ToUTF16("\n\n") + |
| 528 | l10n_util::GetStringUTF16( |
| 529 | IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR); |
| 530 | break; |
| 531 | case SecurityStateModel::NO_DEPRECATED_SHA1: |
| 532 | // Nothing to do. |
| 533 | break; |
felt | 6163845 | 2016-08-09 22:21:55 | [diff] [blame] | 534 | case SecurityStateModel::UNKNOWN_SHA1: |
| 535 | // UNKNOWN_SHA1 should only appear when certificate info has not been |
| 536 | // initialized, in which case this if-statement should not be running |
| 537 | // because there is no other cert info. |
| 538 | NOTREACHED(); |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 539 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 540 | } |
| 541 | } else { |
| 542 | // HTTP or HTTPS with errors (not warnings). |
| 543 | site_identity_details_.assign(l10n_util::GetStringUTF16( |
| 544 | IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY)); |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 545 | if (!security_info.scheme_is_cryptographic || !security_info.certificate) |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 546 | site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT; |
| 547 | else |
| 548 | site_identity_status_ = SITE_IDENTITY_STATUS_ERROR; |
| 549 | |
[email protected] | a04db82 | 2013-12-11 19:14:40 | [diff] [blame] | 550 | const base::string16 bullet = UTF8ToUTF16("\n • "); |
felt | 2493b445 | 2015-09-17 20:33:59 | [diff] [blame] | 551 | std::vector<ssl_errors::ErrorInfo> errors; |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 552 | ssl_errors::ErrorInfo::GetErrorsForCertStatus( |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 553 | certificate_, security_info.cert_status, url, &errors); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 554 | for (size_t i = 0; i < errors.size(); ++i) { |
| 555 | site_identity_details_ += bullet; |
| 556 | site_identity_details_ += errors[i].short_description(); |
| 557 | } |
| 558 | |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 559 | if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 560 | site_identity_details_ += ASCIIToUTF16("\n\n"); |
| 561 | site_identity_details_ += l10n_util::GetStringUTF16( |
| 562 | IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME); |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | // Site Connection |
| 567 | // We consider anything less than 80 bits encryption to be weak encryption. |
| 568 | // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and |
| 569 | // weakly encrypted connections. |
| 570 | site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN; |
| 571 | |
jshin | 1fb7646 | 2016-04-05 22:13:03 | [diff] [blame] | 572 | base::string16 subject_name(GetSimpleSiteName(url)); |
palmer | 153af98 | 2015-09-15 02:04:19 | [diff] [blame] | 573 | if (subject_name.empty()) { |
| 574 | subject_name.assign( |
| 575 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 576 | } |
| 577 | |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 578 | if (!security_info.certificate || !security_info.scheme_is_cryptographic) { |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 579 | // Page is still loading (so SSL status is not yet available) or |
| 580 | // loaded over HTTP or loaded over HTTPS with no cert. |
[email protected] | 1c1051d | 2014-05-10 11:39:58 | [diff] [blame] | 581 | site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED; |
| 582 | |
| 583 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 584 | IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, |
| 585 | subject_name)); |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 586 | } else if (security_info.security_bits < 0) { |
| 587 | // Security strength is unknown. Say nothing. |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 588 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 589 | } else if (security_info.security_bits == 0) { |
| 590 | DCHECK_NE(security_info.security_level, SecurityStateModel::NONE); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 591 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; |
| 592 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 593 | IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, |
| 594 | subject_name)); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 595 | } else { |
| 596 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED; |
Adam Langley | 71c2b59b | 2014-11-13 00:34:22 | [diff] [blame] | 597 | |
lgarron | 3e2c33e | 2016-08-25 06:33:43 | [diff] [blame] | 598 | if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) { |
Adam Langley | 71c2b59b | 2014-11-13 00:34:22 | [diff] [blame] | 599 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 600 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, |
| 601 | subject_name)); |
| 602 | } else { |
| 603 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 604 | IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT, |
| 605 | subject_name)); |
| 606 | } |
| 607 | |
estark | 00e83f1 | 2016-08-19 18:24:04 | [diff] [blame] | 608 | bool ran_insecure_content = false; |
| 609 | bool displayed_insecure_content = false; |
| 610 | CheckForInsecureContent(security_info, &displayed_insecure_content, |
| 611 | &ran_insecure_content); |
| 612 | if (ran_insecure_content || displayed_insecure_content) { |
| 613 | site_connection_status_ = |
| 614 | ran_insecure_content |
| 615 | ? SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE |
| 616 | : SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE; |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 617 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 618 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, |
| 619 | site_connection_details_, |
estark | 00e83f1 | 2016-08-19 18:24:04 | [diff] [blame] | 620 | l10n_util::GetStringUTF16( |
| 621 | ran_insecure_content |
| 622 | ? IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR |
| 623 | : IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING))); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 624 | } |
| 625 | } |
| 626 | |
avi | 655876a | 2015-12-25 07:18:15 | [diff] [blame] | 627 | uint16_t cipher_suite = |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 628 | net::SSLConnectionStatusToCipherSuite(security_info.connection_status); |
| 629 | if (security_info.security_bits > 0 && cipher_suite) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 630 | int ssl_version = |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 631 | net::SSLConnectionStatusToVersion(security_info.connection_status); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 632 | const char* ssl_version_str; |
| 633 | net::SSLVersionToString(&ssl_version_str, ssl_version); |
| 634 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
| 635 | site_connection_details_ += l10n_util::GetStringFUTF16( |
| 636 | IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, |
| 637 | ASCIIToUTF16(ssl_version_str)); |
| 638 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 639 | bool no_renegotiation = |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 640 | (security_info.connection_status & |
| 641 | net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0; |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 642 | const char *key_exchange, *cipher, *mac; |
[email protected] | b6c1d9e8 | 2013-06-12 17:26:57 | [diff] [blame] | 643 | bool is_aead; |
| 644 | net::SSLCipherSuiteToStrings( |
| 645 | &key_exchange, &cipher, &mac, &is_aead, cipher_suite); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 646 | |
| 647 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
[email protected] | b6c1d9e8 | 2013-06-12 17:26:57 | [diff] [blame] | 648 | if (is_aead) { |
| 649 | site_connection_details_ += l10n_util::GetStringFUTF16( |
| 650 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD, |
| 651 | ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange)); |
| 652 | } else { |
| 653 | site_connection_details_ += l10n_util::GetStringFUTF16( |
| 654 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, |
| 655 | ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange)); |
| 656 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 657 | |
agl | 078d210 | 2014-10-20 22:03:22 | [diff] [blame] | 658 | if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 && |
estark | 00e83f1 | 2016-08-19 18:24:04 | [diff] [blame] | 659 | site_connection_status_ < |
| 660 | SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE) { |
agl | 078d210 | 2014-10-20 22:03:22 | [diff] [blame] | 661 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; |
| 662 | } |
| 663 | |
estark | a3121f6b | 2015-09-18 21:15:59 | [diff] [blame] | 664 | const bool did_fallback = (security_info.connection_status & |
| 665 | net::SSL_CONNECTION_VERSION_FALLBACK) != 0; |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 666 | if (did_fallback) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 667 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
| 668 | site_connection_details_ += l10n_util::GetStringUTF16( |
| 669 | IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE); |
| 670 | } |
agl | 078d210 | 2014-10-20 22:03:22 | [diff] [blame] | 671 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 672 | if (no_renegotiation) { |
| 673 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
| 674 | site_connection_details_ += l10n_util::GetStringUTF16( |
| 675 | IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE); |
| 676 | } |
| 677 | } |
[email protected] | e583f75 | 2012-08-30 13:26:21 | [diff] [blame] | 678 | |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 679 | // Check if a user decision has been made to allow or deny certificates with |
| 680 | // errors on this site. |
| 681 | ChromeSSLHostStateDelegate* delegate = |
estark | 7c6bfbf | 2015-09-16 22:20:50 | [diff] [blame] | 682 | ChromeSSLHostStateDelegateFactory::GetForProfile(profile_); |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 683 | DCHECK(delegate); |
jww | f806c36 | 2015-06-02 02:00:40 | [diff] [blame] | 684 | // Only show an SSL decision revoke button if the user has chosen to bypass |
| 685 | // SSL host errors for this host in the past. |
| 686 | show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host()); |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 687 | |
palmer | 82b1f7b | 2015-09-17 19:20:41 | [diff] [blame] | 688 | // By default select the Permissions Tab that displays all the site |
| 689 | // permissions. In case of a connection error or an issue with the certificate |
| 690 | // presented by the website, select the Connection Tab to draw the user's |
| 691 | // attention to the issue. If the site does not provide a certificate because |
| 692 | // it was loaded over an unencrypted connection, don't select the Connection |
| 693 | // Tab. |
[email protected] | e583f75 | 2012-08-30 13:26:21 | [diff] [blame] | 694 | WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS; |
| 695 | if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR || |
estark | 00e83f1 | 2016-08-19 18:24:04 | [diff] [blame] | 696 | site_connection_status_ == |
| 697 | SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE || |
| 698 | site_connection_status_ == |
| 699 | SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE || |
[email protected] | e583f75 | 2012-08-30 13:26:21 | [diff] [blame] | 700 | site_identity_status_ == SITE_IDENTITY_STATUS_ERROR || |
estark | 134a982 | 2015-10-29 04:35:18 | [diff] [blame] | 701 | site_identity_status_ == SITE_IDENTITY_STATUS_CT_ERROR || |
[email protected] | eaf3f32 | 2013-04-25 21:53:59 | [diff] [blame] | 702 | site_identity_status_ == SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN || |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 703 | site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT || |
| 704 | site_identity_status_ == |
lgarron | cc53de2 | 2015-10-05 23:03:17 | [diff] [blame] | 705 | SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR || |
| 706 | site_identity_status_ == |
| 707 | SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR) { |
[email protected] | e583f75 | 2012-08-30 13:26:21 | [diff] [blame] | 708 | tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION; |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 709 | RecordWebsiteSettingsAction( |
| 710 | WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY); |
| 711 | } |
palmer | 82b1f7b | 2015-09-17 19:20:41 | [diff] [blame] | 712 | |
[email protected] | e583f75 | 2012-08-30 13:26:21 | [diff] [blame] | 713 | ui_->SetSelectedTab(tab_id); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 714 | } |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 715 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 716 | void WebsiteSettings::PresentSitePermissions() { |
| 717 | PermissionInfoList permission_info_list; |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 718 | ChosenObjectInfoList chosen_object_info_list; |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 719 | |
| 720 | WebsiteSettingsUI::PermissionInfo permission_info; |
| 721 | for (size_t i = 0; i < arraysize(kPermissionType); ++i) { |
| 722 | permission_info.type = kPermissionType[i]; |
| 723 | |
mgiuca | a319f21 | 2016-01-14 03:30:11 | [diff] [blame] | 724 | if (!ShouldShowPermission(permission_info.type)) |
| 725 | continue; |
| 726 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 727 | content_settings::SettingInfo info; |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 728 | std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting( |
| 729 | site_url_, site_url_, permission_info.type, std::string(), &info); |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 730 | DCHECK(value.get()); |
| 731 | if (value->GetType() == base::Value::TYPE_INTEGER) { |
| 732 | permission_info.setting = |
| 733 | content_settings::ValueToContentSetting(value.get()); |
[email protected] | fe4686a | 2012-10-19 15:38:26 | [diff] [blame] | 734 | } else { |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 735 | NOTREACHED(); |
[email protected] | fe4686a | 2012-10-19 15:38:26 | [diff] [blame] | 736 | } |
| 737 | |
[email protected] | 8bdf45c3 | 2012-08-04 00:12:55 | [diff] [blame] | 738 | permission_info.source = info.source; |
johnme | 9ed9388 | 2016-01-15 01:13:28 | [diff] [blame] | 739 | permission_info.is_incognito = profile_->IsOffTheRecord(); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 740 | |
[email protected] | b1d113d | 2012-06-27 21:27:34 | [diff] [blame] | 741 | if (info.primary_pattern == ContentSettingsPattern::Wildcard() && |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 742 | info.secondary_pattern == ContentSettingsPattern::Wildcard()) { |
[email protected] | b1d113d | 2012-06-27 21:27:34 | [diff] [blame] | 743 | permission_info.default_setting = permission_info.setting; |
| 744 | permission_info.setting = CONTENT_SETTING_DEFAULT; |
| 745 | } else { |
| 746 | permission_info.default_setting = |
| 747 | content_settings_->GetDefaultContentSetting(permission_info.type, |
| 748 | NULL); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 749 | } |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 750 | |
palmer | 64a09998 | 2016-03-09 21:26:11 | [diff] [blame] | 751 | if (permission_info.type == CONTENT_SETTINGS_TYPE_KEYGEN && |
| 752 | (permission_info.setting == CONTENT_SETTING_DEFAULT || |
| 753 | permission_info.setting == permission_info.default_setting) && |
| 754 | !tab_specific_content_settings()->IsContentBlocked( |
| 755 | permission_info.type)) { |
| 756 | continue; |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 757 | } |
palmer | 64a09998 | 2016-03-09 21:26:11 | [diff] [blame] | 758 | permission_info_list.push_back(permission_info); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 759 | } |
| 760 | |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 761 | for (const ChooserUIInfo& ui_info : kChooserUIInfo) { |
| 762 | ChooserContextBase* context = ui_info.get_context(profile_); |
reillyg | 36a7fab3 | 2016-01-28 19:15:10 | [diff] [blame] | 763 | const GURL origin = site_url_.GetOrigin(); |
| 764 | auto chosen_objects = context->GetGrantedObjects(origin, origin); |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 765 | for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) { |
reillyg | 85f57db | 2016-01-12 23:14:38 | [diff] [blame] | 766 | chosen_object_info_list.push_back( |
| 767 | new WebsiteSettingsUI::ChosenObjectInfo(ui_info, std::move(object))); |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | ui_->SetPermissionInfo(permission_info_list, chosen_object_info_list); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 772 | } |
| 773 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 774 | void WebsiteSettings::PresentSiteData() { |
| 775 | CookieInfoList cookie_info_list; |
vabr | d5e30cd | 2014-10-02 11:06:03 | [diff] [blame] | 776 | const LocalSharedObjectsCounter& allowed_objects = |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 777 | tab_specific_content_settings()->allowed_local_shared_objects(); |
vabr | d5e30cd | 2014-10-02 11:06:03 | [diff] [blame] | 778 | const LocalSharedObjectsCounter& blocked_objects = |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 779 | tab_specific_content_settings()->blocked_local_shared_objects(); |
| 780 | |
| 781 | // Add first party cookie and site data counts. |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 782 | WebsiteSettingsUI::CookieInfo cookie_info; |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 783 | cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_); |
| 784 | cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_); |
palmer | b14526492 | 2015-08-28 23:53:15 | [diff] [blame] | 785 | cookie_info.is_first_party = true; |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 786 | cookie_info_list.push_back(cookie_info); |
| 787 | |
| 788 | // Add third party cookie counts. |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 789 | cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed; |
| 790 | cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked; |
palmer | b14526492 | 2015-08-28 23:53:15 | [diff] [blame] | 791 | cookie_info.is_first_party = false; |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 792 | cookie_info_list.push_back(cookie_info); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 793 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 794 | ui_->SetCookieInfo(cookie_info_list); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 795 | } |
[email protected] | 16de6de | 2012-04-04 12:24:14 | [diff] [blame] | 796 | |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 797 | void WebsiteSettings::PresentSiteIdentity() { |
palmer | f9b680a | 2015-07-09 18:56:04 | [diff] [blame] | 798 | // After initialization the status about the site's connection and its |
| 799 | // identity must be available. |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 800 | DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN); |
| 801 | DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN); |
| 802 | WebsiteSettingsUI::IdentityInfo info; |
| 803 | if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT) |
| 804 | info.site_identity = UTF16ToUTF8(organization_name()); |
| 805 | else |
jshin | 1fb7646 | 2016-04-05 22:13:03 | [diff] [blame] | 806 | info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_)); |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 807 | |
| 808 | info.connection_status = site_connection_status_; |
| 809 | info.connection_status_description = |
| 810 | UTF16ToUTF8(site_connection_details_); |
| 811 | info.identity_status = site_identity_status_; |
| 812 | info.identity_status_description = |
| 813 | UTF16ToUTF8(site_identity_details_); |
jam | 8ae7cad | 2016-09-08 23:55:21 | [diff] [blame] | 814 | info.certificate = certificate_; |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 815 | info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 816 | ui_->SetIdentityInfo(info); |
| 817 | } |