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