[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 | |
| 7 | #include <string> |
| 8 | #include <vector> |
| 9 | |
[email protected] | eb2140c | 2013-07-29 12:37:34 | [diff] [blame] | 10 | #include "base/command_line.h" |
[email protected] | 15b09254 | 2012-05-16 13:08:14 | [diff] [blame] | 11 | #include "base/i18n/time_formatting.h" |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 12 | #include "base/metrics/field_trial.h" |
[email protected] | 3ea1b18 | 2013-02-08 22:38:41 | [diff] [blame] | 13 | #include "base/metrics/histogram.h" |
| 14 | #include "base/strings/string_number_conversions.h" |
jialiul | 02aad2d | 2015-04-01 18:56:03 | [diff] [blame] | 15 | #include "base/strings/stringprintf.h" |
[email protected] | 774cc3c | 2013-06-07 20:26:45 | [diff] [blame] | 16 | #include "base/strings/utf_string_conversions.h" |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 17 | #include "base/values.h" |
jialiul | 02aad2d | 2015-04-01 18:56:03 | [diff] [blame] | 18 | #include "chrome/browser/browser_process.h" |
[email protected] | 6b8a3c74 | 2014-07-25 00:25:35 | [diff] [blame] | 19 | #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" |
[email protected] | b0cb5e8 | 2012-07-19 19:22:47 | [diff] [blame] | 20 | #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
| 21 | #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
| 22 | #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
| 23 | #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
| 24 | #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
[email protected] | 77a91c7 | 2012-08-13 16:19:34 | [diff] [blame] | 25 | #include "chrome/browser/history/history_service_factory.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 26 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 27 | #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" |
| 28 | #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 29 | #include "chrome/browser/ssl/ssl_error_info.h" |
[email protected] | 66f15731 | 2012-08-01 13:50:26 | [diff] [blame] | 30 | #include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h" |
[email protected] | 4237dd5 | 2012-06-05 00:00:32 | [diff] [blame] | 31 | #include "chrome/browser/ui/website_settings/website_settings_ui.h" |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 32 | #include "chrome/common/chrome_switches.h" |
thestig | 884a160 | 2014-08-27 01:29:39 | [diff] [blame] | 33 | #include "chrome/grit/chromium_strings.h" |
| 34 | #include "chrome/grit/generated_resources.h" |
mukai | 8eaec82 | 2014-10-25 17:53:16 | [diff] [blame] | 35 | #include "components/content_settings/core/browser/content_settings_utils.h" |
| 36 | #include "components/content_settings/core/browser/host_content_settings_map.h" |
vabr | 4856559 | 2014-10-08 15:06:02 | [diff] [blame] | 37 | #include "components/content_settings/core/browser/local_shared_objects_counter.h" |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 38 | #include "components/content_settings/core/common/content_settings.h" |
vasilii | f62dbf9 | 2014-09-05 10:23:13 | [diff] [blame] | 39 | #include "components/content_settings/core/common/content_settings_pattern.h" |
jialiul | 02aad2d | 2015-04-01 18:56:03 | [diff] [blame] | 40 | #include "components/rappor/rappor_utils.h" |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 41 | #include "content/public/browser/browser_thread.h" |
[email protected] | b59c6cf0 | 2012-03-12 20:51:42 | [diff] [blame] | 42 | #include "content/public/browser/cert_store.h" |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 43 | #include "content/public/browser/user_metrics.h" |
[email protected] | eb2140c | 2013-07-29 12:37:34 | [diff] [blame] | 44 | #include "content/public/common/content_switches.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 45 | #include "content/public/common/ssl_status.h" |
| 46 | #include "content/public/common/url_constants.h" |
[email protected] | be28b5f4 | 2012-07-20 11:31:25 | [diff] [blame] | 47 | #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
[email protected] | 6e7845ae | 2013-03-29 21:48:11 | [diff] [blame] | 48 | #include "net/cert/cert_status_flags.h" |
| 49 | #include "net/cert/x509_certificate.h" |
[email protected] | 536fd0b | 2013-03-14 17:41:57 | [diff] [blame] | 50 | #include "net/ssl/ssl_cipher_suite_names.h" |
| 51 | #include "net/ssl/ssl_connection_status_flags.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 52 | #include "ui/base/l10n/l10n_util.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 53 | |
[email protected] | 24a9f1c9 | 2013-11-13 12:33:37 | [diff] [blame] | 54 | #if defined(OS_CHROMEOS) |
| 55 | #include "chrome/browser/chromeos/policy/policy_cert_service.h" |
| 56 | #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" |
| 57 | #endif |
| 58 | |
[email protected] | ab6df3b1 | 2013-12-24 23:32:26 | [diff] [blame] | 59 | using base::ASCIIToUTF16; |
| 60 | using base::UTF8ToUTF16; |
[email protected] | f729d7a | 2013-12-26 07:07:56 | [diff] [blame] | 61 | using base::UTF16ToUTF8; |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 62 | using content::BrowserThread; |
| 63 | |
| 64 | namespace { |
| 65 | |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 66 | // Events for UMA. Do not reorder or change! |
| 67 | enum SSLCertificateDecisionsDidRevoke { |
| 68 | USER_CERT_DECISIONS_NOT_REVOKED = 0, |
| 69 | USER_CERT_DECISIONS_REVOKED, |
| 70 | END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM |
| 71 | }; |
| 72 | |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 73 | // The list of content settings types to display on the Website Settings UI. THE |
| 74 | // ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, email |
| 75 | // [email protected]. |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 76 | ContentSettingsType kPermissionType[] = { |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 77 | CONTENT_SETTINGS_TYPE_GEOLOCATION, |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 78 | CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
| 79 | CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 80 | CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 81 | CONTENT_SETTINGS_TYPE_IMAGES, |
| 82 | CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
| 83 | CONTENT_SETTINGS_TYPE_POPUPS, |
| 84 | CONTENT_SETTINGS_TYPE_FULLSCREEN, |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 85 | CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 86 | CONTENT_SETTINGS_TYPE_PLUGINS, |
| 87 | CONTENT_SETTINGS_TYPE_MOUSELOCK, |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 88 | CONTENT_SETTINGS_TYPE_MIDI_SYSEX, |
benwells | a68ed4b | 2014-11-13 03:25:36 | [diff] [blame] | 89 | #if defined(OS_ANDROID) |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 90 | CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, |
benwells | a68ed4b | 2014-11-13 03:25:36 | [diff] [blame] | 91 | #endif |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 92 | }; |
| 93 | |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 94 | bool CertificateTransparencyStatusMatch( |
| 95 | const content::SignedCertificateTimestampIDStatusList& scts, |
| 96 | net::ct::SCTVerifyStatus status) { |
| 97 | for (content::SignedCertificateTimestampIDStatusList::const_iterator it = |
| 98 | scts.begin(); |
| 99 | it != scts.end(); |
| 100 | ++it) { |
| 101 | if (it->status == status) |
| 102 | return true; |
| 103 | } |
| 104 | |
| 105 | return false; |
| 106 | } |
| 107 | |
| 108 | int GetSiteIdentityDetailsMessageByCTInfo( |
| 109 | const content::SignedCertificateTimestampIDStatusList& scts, |
| 110 | bool is_ev) { |
| 111 | // No SCTs - no CT information. |
| 112 | if (scts.empty()) |
| 113 | return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_NO_CT |
| 114 | : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_NO_CT); |
| 115 | |
| 116 | if (CertificateTransparencyStatusMatch(scts, net::ct::SCT_STATUS_OK)) |
| 117 | return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_VERIFIED |
| 118 | : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_VERIFIED); |
| 119 | |
| 120 | if (CertificateTransparencyStatusMatch(scts, net::ct::SCT_STATUS_INVALID)) |
| 121 | return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_INVALID |
| 122 | : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_INVALID); |
| 123 | |
| 124 | // status is SCT_STATUS_LOG_UNKNOWN |
| 125 | return (is_ev ? IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_CT_UNVERIFIED |
| 126 | : IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_CT_UNVERIFIED); |
| 127 | } |
| 128 | |
| 129 | // This function will return SITE_IDENTITY_STATUS_CERT or |
| 130 | // SITE_IDENTITY_STATUS_EV_CERT depending on |is_ev| unless there are SCTs |
| 131 | // which failed verification, in which case it will return |
| 132 | // SITE_IDENTITY_STATUS_ERROR. |
| 133 | WebsiteSettings::SiteIdentityStatus GetSiteIdentityStatusByCTInfo( |
| 134 | const content::SignedCertificateTimestampIDStatusList& scts, |
| 135 | bool is_ev) { |
| 136 | if (CertificateTransparencyStatusMatch(scts, net::ct::SCT_STATUS_INVALID)) |
| 137 | return WebsiteSettings::SITE_IDENTITY_STATUS_ERROR; |
| 138 | |
| 139 | return is_ev ? WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT |
| 140 | : WebsiteSettings::SITE_IDENTITY_STATUS_CERT; |
| 141 | } |
| 142 | |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 143 | } // namespace |
| 144 | |
| 145 | WebsiteSettings::WebsiteSettings( |
| 146 | WebsiteSettingsUI* ui, |
| 147 | Profile* profile, |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 148 | TabSpecificContentSettings* tab_specific_content_settings, |
[email protected] | 4f822f02 | 2012-12-20 19:11:42 | [diff] [blame] | 149 | InfoBarService* infobar_service, |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 150 | const GURL& url, |
| 151 | const content::SSLStatus& ssl, |
| 152 | content::CertStore* cert_store) |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 153 | : TabSpecificContentSettings::SiteDataObserver( |
| 154 | tab_specific_content_settings), |
| 155 | ui_(ui), |
[email protected] | 4f822f02 | 2012-12-20 19:11:42 | [diff] [blame] | 156 | infobar_service_(infobar_service), |
[email protected] | 66f15731 | 2012-08-01 13:50:26 | [diff] [blame] | 157 | show_info_bar_(false), |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 158 | site_url_(url), |
| 159 | site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN), |
[email protected] | f61c1ce | 2012-05-09 13:55:11 | [diff] [blame] | 160 | cert_id_(0), |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 161 | site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN), |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 162 | cert_store_(cert_store), |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 163 | content_settings_(profile->GetHostContentSettingsMap()), |
| 164 | chrome_ssl_host_state_delegate_( |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 165 | ChromeSSLHostStateDelegateFactory::GetForProfile(profile)), |
| 166 | did_revoke_user_ssl_decisions_(false) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 167 | Init(profile, url, ssl); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 168 | |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 169 | PresentSitePermissions(); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 170 | PresentSiteData(); |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 171 | PresentSiteIdentity(); |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 172 | |
| 173 | // Every time the Website Settings UI is opened a |WebsiteSettings| object is |
| 174 | // created. So this counts how ofter the Website Settings UI is opened. |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 175 | RecordWebsiteSettingsAction(WEBSITE_SETTINGS_OPENED); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 176 | } |
| 177 | |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 178 | WebsiteSettings::~WebsiteSettings() { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 179 | } |
| 180 | |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 181 | void WebsiteSettings::RecordWebsiteSettingsAction( |
| 182 | WebsiteSettingsAction action) { |
| 183 | UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", |
| 184 | action, |
| 185 | WEBSITE_SETTINGS_COUNT); |
| 186 | |
| 187 | // Use a separate histogram to record actions if they are done on a page with |
| 188 | // an HTTPS URL. Note that this *disregards* security status. |
palmer | ee0e5af | 2015-06-05 03:10:40 | [diff] [blame] | 189 | // |
| 190 | |
| 191 | // TODO(palmer): Consider adding a new histogram for |
| 192 | // GURL::SchemeIsCryptographic. (We don't want to replace this call with a |
| 193 | // call to that function because we don't want to change the meanings of |
| 194 | // existing metrics.) This would inform the decision to mark non-secure |
| 195 | // origins as Dubious or Non-Secure; the overall bug for that is |
| 196 | // crbug.com/454579. |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 197 | if (site_url_.SchemeIs(url::kHttpsScheme)) { |
| 198 | UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action.HttpsUrl", |
| 199 | action, |
| 200 | WEBSITE_SETTINGS_COUNT); |
| 201 | } |
| 202 | } |
| 203 | |
jialiul | 02aad2d | 2015-04-01 18:56:03 | [diff] [blame] | 204 | // Get corresponding Rappor Metric. |
| 205 | const std::string GetRapporMetric(ContentSettingsType permission) { |
| 206 | std::string permission_str; |
| 207 | switch (permission) { |
| 208 | case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 209 | permission_str = "Geolocation"; |
| 210 | break; |
| 211 | case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 212 | permission_str = "Notifications"; |
| 213 | break; |
| 214 | case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: |
| 215 | permission_str = "Mic"; |
| 216 | break; |
| 217 | case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: |
| 218 | permission_str = "Camera"; |
| 219 | break; |
| 220 | default: |
| 221 | return ""; |
| 222 | } |
| 223 | |
| 224 | return base::StringPrintf("ContentSettings.PermissionActions_%s.Revoked.Url", |
| 225 | permission_str.c_str()); |
| 226 | } |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 227 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 228 | void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type, |
| 229 | ContentSetting setting) { |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 230 | // Count how often a permission for a specific content type is changed using |
| 231 | // the Website Settings UI. |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 232 | ContentSettingsTypeHistogram histogram_value = |
| 233 | ContentSettingTypeToHistogramValue(type); |
| 234 | DCHECK_NE(histogram_value, CONTENT_SETTINGS_TYPE_HISTOGRAM_INVALID) |
| 235 | << "Invalid content setting type specified."; |
| 236 | UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.OriginInfo.PermissionChanged", |
| 237 | histogram_value, |
| 238 | CONTENT_SETTINGS_HISTOGRAM_NUM_TYPES); |
| 239 | |
| 240 | if (setting == ContentSetting::CONTENT_SETTING_ALLOW) { |
| 241 | UMA_HISTOGRAM_ENUMERATION( |
| 242 | "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value, |
| 243 | CONTENT_SETTINGS_HISTOGRAM_NUM_TYPES); |
| 244 | } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) { |
| 245 | UMA_HISTOGRAM_ENUMERATION( |
| 246 | "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value, |
| 247 | CONTENT_SETTINGS_HISTOGRAM_NUM_TYPES); |
jialiul | 02aad2d | 2015-04-01 18:56:03 | [diff] [blame] | 248 | // Trigger Rappor sampling if it is a permission revoke action. |
| 249 | const std::string& rappor_metric = GetRapporMetric(type); |
| 250 | if (!rappor_metric.empty()) { |
| 251 | rappor::SampleDomainAndRegistryFromGURL( |
| 252 | g_browser_process->rappor_service(), rappor_metric, this->site_url_); |
| 253 | } |
sashab | 9debecd | 2014-12-18 04:15:56 | [diff] [blame] | 254 | } |
[email protected] | e22d64f | 2012-09-10 09:03:23 | [diff] [blame] | 255 | |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 256 | // This is technically redundant given the histogram above, but putting the |
| 257 | // total count of permission changes in another histogram makes it easier to |
| 258 | // compare it against other kinds of actions in WebsiteSettings[PopupView]. |
| 259 | RecordWebsiteSettingsAction(WEBSITE_SETTINGS_CHANGED_PERMISSION); |
| 260 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 261 | ContentSettingsPattern primary_pattern; |
| 262 | ContentSettingsPattern secondary_pattern; |
| 263 | switch (type) { |
| 264 | case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
[email protected] | eb2140c | 2013-07-29 12:37:34 | [diff] [blame] | 265 | case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
mlamouri | ab1897c | 2015-02-18 12:09:32 | [diff] [blame] | 266 | case CONTENT_SETTINGS_TYPE_FULLSCREEN: |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 267 | // TODO(markusheintz): The rule we create here should also change the |
| 268 | // location permission for iframed content. |
| 269 | primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_); |
| 270 | secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_); |
| 271 | break; |
| 272 | case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 273 | primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_); |
| 274 | secondary_pattern = ContentSettingsPattern::Wildcard(); |
| 275 | break; |
[email protected] | b1d113d | 2012-06-27 21:27:34 | [diff] [blame] | 276 | case CONTENT_SETTINGS_TYPE_IMAGES: |
| 277 | case CONTENT_SETTINGS_TYPE_JAVASCRIPT: |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 278 | case CONTENT_SETTINGS_TYPE_PLUGINS: |
| 279 | case CONTENT_SETTINGS_TYPE_POPUPS: |
[email protected] | b1d113d | 2012-06-27 21:27:34 | [diff] [blame] | 280 | case CONTENT_SETTINGS_TYPE_MOUSELOCK: |
[email protected] | ad635b1 | 2013-07-22 21:53:27 | [diff] [blame] | 281 | case CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS: |
benwells | a68ed4b | 2014-11-13 03:25:36 | [diff] [blame] | 282 | case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 283 | primary_pattern = ContentSettingsPattern::FromURL(site_url_); |
| 284 | secondary_pattern = ContentSettingsPattern::Wildcard(); |
| 285 | break; |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 286 | case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: |
| 287 | case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: |
[email protected] | 0bacc191 | 2012-12-11 11:05:34 | [diff] [blame] | 288 | primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_); |
| 289 | secondary_pattern = ContentSettingsPattern::Wildcard(); |
[email protected] | 0bacc191 | 2012-12-11 11:05:34 | [diff] [blame] | 290 | break; |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 291 | default: |
| 292 | NOTREACHED() << "ContentSettingsType " << type << "is not supported."; |
| 293 | break; |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 294 | } |
| 295 | |
jialiul | 02aad2d | 2015-04-01 18:56:03 | [diff] [blame] | 296 | // Permission settings are specified via rules. There exists always at least |
| 297 | // one rule for the default setting. Get the rule that currently defines |
| 298 | // the permission for the given permission |type|. Then test whether the |
| 299 | // existing rule is more specific than the rule we are about to create. If |
| 300 | // the existing rule is more specific, than change the existing rule instead |
| 301 | // of creating a new rule that would be hidden behind the existing rule. |
| 302 | content_settings::SettingInfo info; |
| 303 | scoped_ptr<base::Value> v = |
| 304 | content_settings_->GetWebsiteSettingWithoutOverride( |
| 305 | site_url_, site_url_, type, std::string(), &info); |
| 306 | content_settings_->SetNarrowestWebsiteSetting( |
| 307 | primary_pattern, secondary_pattern, type, std::string(), setting, info); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 308 | |
[email protected] | 66f15731 | 2012-08-01 13:50:26 | [diff] [blame] | 309 | show_info_bar_ = true; |
[email protected] | 2f45d54 | 2012-08-22 08:47:24 | [diff] [blame] | 310 | |
[email protected] | 7695593 | 2012-12-06 11:01:10 | [diff] [blame] | 311 | // TODO(markusheintz): This is a temporary hack to fix issue: |
| 312 | // http://crbug.com/144203. |
[email protected] | e379ba4 | 2012-08-22 22:40:25 | [diff] [blame] | 313 | #if defined(OS_MACOSX) |
[email protected] | 2f45d54 | 2012-08-22 08:47:24 | [diff] [blame] | 314 | // Refresh the UI to reflect the new setting. |
| 315 | PresentSitePermissions(); |
[email protected] | e379ba4 | 2012-08-22 22:40:25 | [diff] [blame] | 316 | #endif |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 317 | } |
| 318 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 319 | void WebsiteSettings::OnSiteDataAccessed() { |
| 320 | PresentSiteData(); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 321 | } |
| 322 | |
[email protected] | 66f15731 | 2012-08-01 13:50:26 | [diff] [blame] | 323 | void WebsiteSettings::OnUIClosing() { |
[email protected] | 0be0993 | 2013-01-08 02:03:50 | [diff] [blame] | 324 | if (show_info_bar_) |
[email protected] | ed9bc65 | 2013-07-11 17:17:36 | [diff] [blame] | 325 | WebsiteSettingsInfoBarDelegate::Create(infobar_service_); |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 326 | |
| 327 | SSLCertificateDecisionsDidRevoke user_decision = |
| 328 | did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED |
| 329 | : USER_CERT_DECISIONS_NOT_REVOKED; |
| 330 | |
| 331 | UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions", |
| 332 | user_decision, |
| 333 | END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM); |
| 334 | } |
| 335 | |
| 336 | void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() { |
| 337 | DCHECK(chrome_ssl_host_state_delegate_); |
jww | 6a55df7 | 2014-09-05 19:59:29 | [diff] [blame] | 338 | chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard( |
| 339 | site_url().host()); |
jww | 1ed8ea7 | 2014-09-02 20:43:25 | [diff] [blame] | 340 | did_revoke_user_ssl_decisions_ = true; |
[email protected] | 66f15731 | 2012-08-01 13:50:26 | [diff] [blame] | 341 | } |
| 342 | |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 343 | void WebsiteSettings::Init(Profile* profile, |
| 344 | const GURL& url, |
| 345 | const content::SSLStatus& ssl) { |
sashab | 97894ce | 2014-10-22 10:08:33 | [diff] [blame] | 346 | bool isChromeUINativeScheme = false; |
| 347 | #if defined(OS_ANDROID) |
| 348 | isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme); |
| 349 | #endif |
| 350 | |
| 351 | if (url.SchemeIs(content::kChromeUIScheme) || |
| 352 | url.SchemeIs(url::kAboutScheme) || isChromeUINativeScheme) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 353 | site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE; |
| 354 | site_identity_details_ = |
| 355 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE); |
| 356 | site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE; |
| 357 | return; |
| 358 | } |
| 359 | |
| 360 | scoped_refptr<net::X509Certificate> cert; |
| 361 | |
| 362 | // Identity section. |
[email protected] | a04db82 | 2013-12-11 19:14:40 | [diff] [blame] | 363 | base::string16 subject_name(UTF8ToUTF16(url.host())); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 364 | if (subject_name.empty()) { |
| 365 | subject_name.assign( |
| 366 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 367 | } |
| 368 | |
[email protected] | f61c1ce | 2012-05-09 13:55:11 | [diff] [blame] | 369 | cert_id_ = ssl.cert_id; |
| 370 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 371 | if (ssl.cert_id && |
| 372 | cert_store_->RetrieveCert(ssl.cert_id, &cert) && |
| 373 | (!net::IsCertStatusError(ssl.cert_status) || |
| 374 | net::IsCertStatusMinorError(ssl.cert_status))) { |
| 375 | // There are no major errors. Check for minor errors. |
[email protected] | 24a9f1c9 | 2013-11-13 12:33:37 | [diff] [blame] | 376 | #if defined(OS_CHROMEOS) |
| 377 | policy::PolicyCertService* service = |
| 378 | policy::PolicyCertServiceFactory::GetForProfile(profile); |
| 379 | const bool used_policy_certs = service && service->UsedPolicyCertificates(); |
| 380 | #else |
| 381 | const bool used_policy_certs = false; |
| 382 | #endif |
| 383 | if (used_policy_certs) { |
[email protected] | eaf3f32 | 2013-04-25 21:53:59 | [diff] [blame] | 384 | site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT; |
[email protected] | 24a9f1c9 | 2013-11-13 12:33:37 | [diff] [blame] | 385 | site_identity_details_ = l10n_util::GetStringFUTF16( |
| 386 | IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host())); |
[email protected] | eaf3f32 | 2013-04-25 21:53:59 | [diff] [blame] | 387 | } else if (net::IsCertStatusMinorError(ssl.cert_status)) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 388 | site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN; |
[email protected] | a04db82 | 2013-12-11 19:14:40 | [diff] [blame] | 389 | base::string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName())); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 390 | if (issuer_name.empty()) { |
| 391 | issuer_name.assign(l10n_util::GetStringUTF16( |
| 392 | IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 393 | } |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 394 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 395 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 396 | GetSiteIdentityDetailsMessageByCTInfo( |
| 397 | ssl.signed_certificate_timestamp_ids, false /* not EV */), |
| 398 | issuer_name)); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 399 | |
| 400 | site_identity_details_ += ASCIIToUTF16("\n\n"); |
| 401 | if (ssl.cert_status & net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) { |
| 402 | site_identity_details_ += l10n_util::GetStringUTF16( |
| 403 | IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION); |
| 404 | } else if (ssl.cert_status & net::CERT_STATUS_NO_REVOCATION_MECHANISM) { |
| 405 | site_identity_details_ += l10n_util::GetStringUTF16( |
| 406 | IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM); |
| 407 | } else { |
| 408 | NOTREACHED() << "Need to specify string for this warning"; |
| 409 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 410 | } else { |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 411 | if (ssl.cert_status & net::CERT_STATUS_IS_EV) { |
| 412 | // EV HTTPS page. |
| 413 | site_identity_status_ = GetSiteIdentityStatusByCTInfo( |
| 414 | ssl.signed_certificate_timestamp_ids, true); |
| 415 | DCHECK(!cert->subject().organization_names.empty()); |
| 416 | organization_name_ = UTF8ToUTF16(cert->subject().organization_names[0]); |
| 417 | // An EV Cert is required to have a city (localityName) and country but |
| 418 | // state is "if any". |
| 419 | DCHECK(!cert->subject().locality_name.empty()); |
| 420 | DCHECK(!cert->subject().country_name.empty()); |
| 421 | base::string16 locality; |
| 422 | if (!cert->subject().state_or_province_name.empty()) { |
| 423 | locality = l10n_util::GetStringFUTF16( |
| 424 | IDS_PAGEINFO_ADDRESS, |
| 425 | UTF8ToUTF16(cert->subject().locality_name), |
| 426 | UTF8ToUTF16(cert->subject().state_or_province_name), |
| 427 | UTF8ToUTF16(cert->subject().country_name)); |
| 428 | } else { |
| 429 | locality = l10n_util::GetStringFUTF16( |
| 430 | IDS_PAGEINFO_PARTIAL_ADDRESS, |
| 431 | UTF8ToUTF16(cert->subject().locality_name), |
| 432 | UTF8ToUTF16(cert->subject().country_name)); |
| 433 | } |
| 434 | DCHECK(!cert->subject().organization_names.empty()); |
| 435 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
| 436 | GetSiteIdentityDetailsMessageByCTInfo( |
| 437 | ssl.signed_certificate_timestamp_ids, true /* is EV */), |
| 438 | UTF8ToUTF16(cert->subject().organization_names[0]), |
| 439 | locality, |
| 440 | UTF8ToUTF16(cert->issuer().GetDisplayName()))); |
| 441 | } else { |
| 442 | // Non-EV OK HTTPS page. |
| 443 | site_identity_status_ = GetSiteIdentityStatusByCTInfo( |
| 444 | ssl.signed_certificate_timestamp_ids, false); |
| 445 | base::string16 issuer_name( |
| 446 | UTF8ToUTF16(cert->issuer().GetDisplayName())); |
| 447 | if (issuer_name.empty()) { |
| 448 | issuer_name.assign(l10n_util::GetStringUTF16( |
| 449 | IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 450 | } |
[email protected] | 94c74b4 | 2013-12-02 15:19:49 | [diff] [blame] | 451 | |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 452 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
| 453 | GetSiteIdentityDetailsMessageByCTInfo( |
| 454 | ssl.signed_certificate_timestamp_ids, false /* not EV */), |
| 455 | issuer_name)); |
| 456 | } |
| 457 | // The date after which no new SHA-1 certificates may be issued. |
| 458 | // 2016-01-01 00:00:00 UTC |
| 459 | static const int64_t kSHA1LastIssuanceDate = INT64_C(13096080000000000); |
| 460 | if ((ssl.cert_status & net::CERT_STATUS_SHA1_SIGNATURE_PRESENT) && |
| 461 | cert->valid_expiry() > |
rsleevi | ad6f502 | 2015-04-24 18:57:50 | [diff] [blame] | 462 | base::Time::FromInternalValue(kSHA1LastIssuanceDate)) { |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 463 | site_identity_status_ = |
| 464 | SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM; |
| 465 | site_identity_details_ += |
| 466 | UTF8ToUTF16("\n\n") + |
| 467 | l10n_util::GetStringUTF16( |
| 468 | IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM); |
| 469 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 470 | } |
| 471 | } else { |
| 472 | // HTTP or HTTPS with errors (not warnings). |
| 473 | site_identity_details_.assign(l10n_util::GetStringUTF16( |
| 474 | IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY)); |
| 475 | if (ssl.security_style == content::SECURITY_STYLE_UNAUTHENTICATED) |
| 476 | site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT; |
| 477 | else |
| 478 | site_identity_status_ = SITE_IDENTITY_STATUS_ERROR; |
| 479 | |
[email protected] | a04db82 | 2013-12-11 19:14:40 | [diff] [blame] | 480 | const base::string16 bullet = UTF8ToUTF16("\n • "); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 481 | std::vector<SSLErrorInfo> errors; |
| 482 | SSLErrorInfo::GetErrorsForCertStatus(ssl.cert_id, ssl.cert_status, |
| 483 | url, &errors); |
| 484 | for (size_t i = 0; i < errors.size(); ++i) { |
| 485 | site_identity_details_ += bullet; |
| 486 | site_identity_details_ += errors[i].short_description(); |
| 487 | } |
| 488 | |
| 489 | if (ssl.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) { |
| 490 | site_identity_details_ += ASCIIToUTF16("\n\n"); |
| 491 | site_identity_details_ += l10n_util::GetStringUTF16( |
| 492 | IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME); |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | // Site Connection |
| 497 | // We consider anything less than 80 bits encryption to be weak encryption. |
| 498 | // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and |
| 499 | // weakly encrypted connections. |
| 500 | site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN; |
| 501 | |
[email protected] | 1c1051d | 2014-05-10 11:39:58 | [diff] [blame] | 502 | if (ssl.security_style == content::SECURITY_STYLE_UNKNOWN) { |
| 503 | // Page is still loading, so SSL status is not yet available. Say nothing. |
| 504 | DCHECK_EQ(ssl.security_bits, -1); |
| 505 | site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED; |
| 506 | |
| 507 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 508 | IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, |
| 509 | subject_name)); |
| 510 | } else if (ssl.security_style == content::SECURITY_STYLE_UNAUTHENTICATED) { |
| 511 | // HTTPS without a certificate, or not HTTPS. |
| 512 | DCHECK(!ssl.cert_id); |
| 513 | site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED; |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 514 | |
| 515 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 516 | IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, |
| 517 | subject_name)); |
| 518 | } else if (ssl.security_bits < 0) { |
| 519 | // Security strength is unknown. Say nothing. |
| 520 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; |
| 521 | } else if (ssl.security_bits == 0) { |
| 522 | DCHECK_NE(ssl.security_style, content::SECURITY_STYLE_UNAUTHENTICATED); |
| 523 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; |
| 524 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 525 | IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, |
| 526 | subject_name)); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 527 | } else { |
| 528 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED; |
Adam Langley | 71c2b59b | 2014-11-13 00:34:22 | [diff] [blame] | 529 | |
| 530 | if (net::SSLConnectionStatusToVersion(ssl.connection_status) >= |
| 531 | net::SSL_CONNECTION_VERSION_TLS1_2 && |
| 532 | net::IsSecureTLSCipherSuite( |
| 533 | net::SSLConnectionStatusToCipherSuite(ssl.connection_status))) { |
| 534 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 535 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, |
| 536 | subject_name)); |
| 537 | } else { |
| 538 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 539 | IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT, |
| 540 | subject_name)); |
| 541 | } |
| 542 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 543 | if (ssl.content_status) { |
| 544 | bool ran_insecure_content = |
| 545 | !!(ssl.content_status & content::SSLStatus::RAN_INSECURE_CONTENT); |
| 546 | site_connection_status_ = ran_insecure_content ? |
| 547 | SITE_CONNECTION_STATUS_ENCRYPTED_ERROR |
| 548 | : SITE_CONNECTION_STATUS_MIXED_CONTENT; |
| 549 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 550 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, |
| 551 | site_connection_details_, |
| 552 | l10n_util::GetStringUTF16(ran_insecure_content ? |
| 553 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR : |
| 554 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING))); |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | uint16 cipher_suite = |
| 559 | net::SSLConnectionStatusToCipherSuite(ssl.connection_status); |
| 560 | if (ssl.security_bits > 0 && cipher_suite) { |
| 561 | int ssl_version = |
| 562 | net::SSLConnectionStatusToVersion(ssl.connection_status); |
| 563 | const char* ssl_version_str; |
| 564 | net::SSLVersionToString(&ssl_version_str, ssl_version); |
| 565 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
| 566 | site_connection_details_ += l10n_util::GetStringFUTF16( |
| 567 | IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, |
| 568 | ASCIIToUTF16(ssl_version_str)); |
| 569 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 570 | bool no_renegotiation = |
| 571 | (ssl.connection_status & |
| 572 | net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0; |
| 573 | const char *key_exchange, *cipher, *mac; |
[email protected] | b6c1d9e8 | 2013-06-12 17:26:57 | [diff] [blame] | 574 | bool is_aead; |
| 575 | net::SSLCipherSuiteToStrings( |
| 576 | &key_exchange, &cipher, &mac, &is_aead, cipher_suite); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 577 | |
| 578 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
[email protected] | b6c1d9e8 | 2013-06-12 17:26:57 | [diff] [blame] | 579 | if (is_aead) { |
| 580 | site_connection_details_ += l10n_util::GetStringFUTF16( |
| 581 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD, |
| 582 | ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange)); |
| 583 | } else { |
| 584 | site_connection_details_ += l10n_util::GetStringFUTF16( |
| 585 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, |
| 586 | ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange)); |
| 587 | } |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 588 | |
agl | 078d210 | 2014-10-20 22:03:22 | [diff] [blame] | 589 | if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 && |
| 590 | site_connection_status_ < SITE_CONNECTION_STATUS_MIXED_CONTENT) { |
| 591 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; |
| 592 | } |
| 593 | |
| 594 | const bool did_fallback = |
| 595 | (ssl.connection_status & net::SSL_CONNECTION_VERSION_FALLBACK) != 0; |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 596 | if (did_fallback) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 597 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
| 598 | site_connection_details_ += l10n_util::GetStringUTF16( |
| 599 | IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE); |
| 600 | } |
agl | 078d210 | 2014-10-20 22:03:22 | [diff] [blame] | 601 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 602 | if (no_renegotiation) { |
| 603 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
| 604 | site_connection_details_ += l10n_util::GetStringUTF16( |
| 605 | IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE); |
| 606 | } |
| 607 | } |
[email protected] | e583f75 | 2012-08-30 13:26:21 | [diff] [blame] | 608 | |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 609 | // Check if a user decision has been made to allow or deny certificates with |
| 610 | // errors on this site. |
| 611 | ChromeSSLHostStateDelegate* delegate = |
| 612 | ChromeSSLHostStateDelegateFactory::GetForProfile(profile); |
| 613 | DCHECK(delegate); |
jww | f806c36 | 2015-06-02 02:00:40 | [diff] [blame] | 614 | // Only show an SSL decision revoke button if the user has chosen to bypass |
| 615 | // SSL host errors for this host in the past. |
| 616 | show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host()); |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 617 | |
[email protected] | e583f75 | 2012-08-30 13:26:21 | [diff] [blame] | 618 | // By default select the permissions tab that displays all the site |
| 619 | // permissions. In case of a connection error or an issue with the |
| 620 | // certificate presented by the website, select the connection tab to draw |
| 621 | // the user's attention to the issue. If the site does not provide a |
| 622 | // certificate because it was loaded over an unencrypted connection, don't |
| 623 | // select the connection tab. |
| 624 | WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS; |
| 625 | if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR || |
| 626 | site_connection_status_ == SITE_CONNECTION_STATUS_MIXED_CONTENT || |
| 627 | site_identity_status_ == SITE_IDENTITY_STATUS_ERROR || |
[email protected] | eaf3f32 | 2013-04-25 21:53:59 | [diff] [blame] | 628 | site_identity_status_ == SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN || |
rsleevi | 4f801272 | 2014-09-30 01:28:01 | [diff] [blame] | 629 | site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT || |
| 630 | site_identity_status_ == |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 631 | SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM) { |
[email protected] | e583f75 | 2012-08-30 13:26:21 | [diff] [blame] | 632 | tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION; |
lgarron | 04a9350 | 2014-11-04 22:25:04 | [diff] [blame] | 633 | RecordWebsiteSettingsAction( |
| 634 | WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY); |
| 635 | } |
[email protected] | e583f75 | 2012-08-30 13:26:21 | [diff] [blame] | 636 | ui_->SetSelectedTab(tab_id); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 637 | } |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 638 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 639 | void WebsiteSettings::PresentSitePermissions() { |
| 640 | PermissionInfoList permission_info_list; |
| 641 | |
| 642 | WebsiteSettingsUI::PermissionInfo permission_info; |
| 643 | for (size_t i = 0; i < arraysize(kPermissionType); ++i) { |
| 644 | permission_info.type = kPermissionType[i]; |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 645 | |
| 646 | content_settings::SettingInfo info; |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 647 | scoped_ptr<base::Value> value = |
| 648 | content_settings_->GetWebsiteSettingWithoutOverride( |
| 649 | site_url_, site_url_, permission_info.type, std::string(), &info); |
| 650 | DCHECK(value.get()); |
| 651 | if (value->GetType() == base::Value::TYPE_INTEGER) { |
| 652 | permission_info.setting = |
| 653 | content_settings::ValueToContentSetting(value.get()); |
[email protected] | fe4686a | 2012-10-19 15:38:26 | [diff] [blame] | 654 | } else { |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 655 | NOTREACHED(); |
[email protected] | fe4686a | 2012-10-19 15:38:26 | [diff] [blame] | 656 | } |
| 657 | |
[email protected] | 8bdf45c3 | 2012-08-04 00:12:55 | [diff] [blame] | 658 | permission_info.source = info.source; |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 659 | |
[email protected] | b1d113d | 2012-06-27 21:27:34 | [diff] [blame] | 660 | if (info.primary_pattern == ContentSettingsPattern::Wildcard() && |
sashab | 2b2a314f | 2015-01-17 06:42:21 | [diff] [blame] | 661 | info.secondary_pattern == ContentSettingsPattern::Wildcard()) { |
[email protected] | b1d113d | 2012-06-27 21:27:34 | [diff] [blame] | 662 | permission_info.default_setting = permission_info.setting; |
| 663 | permission_info.setting = CONTENT_SETTING_DEFAULT; |
| 664 | } else { |
| 665 | permission_info.default_setting = |
| 666 | content_settings_->GetDefaultContentSetting(permission_info.type, |
| 667 | NULL); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 668 | } |
palmer | 0da10b3 | 2015-02-11 00:42:19 | [diff] [blame] | 669 | |
| 670 | if (permission_info.setting != CONTENT_SETTING_DEFAULT && |
| 671 | permission_info.setting != permission_info.default_setting) { |
| 672 | permission_info_list.push_back(permission_info); |
| 673 | } |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | ui_->SetPermissionInfo(permission_info_list); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 677 | } |
| 678 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 679 | void WebsiteSettings::PresentSiteData() { |
| 680 | CookieInfoList cookie_info_list; |
vabr | d5e30cd | 2014-10-02 11:06:03 | [diff] [blame] | 681 | const LocalSharedObjectsCounter& allowed_objects = |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 682 | tab_specific_content_settings()->allowed_local_shared_objects(); |
vabr | d5e30cd | 2014-10-02 11:06:03 | [diff] [blame] | 683 | const LocalSharedObjectsCounter& blocked_objects = |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 684 | tab_specific_content_settings()->blocked_local_shared_objects(); |
| 685 | |
| 686 | // Add first party cookie and site data counts. |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 687 | WebsiteSettingsUI::CookieInfo cookie_info; |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 688 | std::string cookie_source = |
[email protected] | ed32c21 | 2013-05-14 20:49:29 | [diff] [blame] | 689 | net::registry_controlled_domains::GetDomainAndRegistry( |
| 690 | site_url_, |
[email protected] | aabe179 | 2014-01-30 21:37:46 | [diff] [blame] | 691 | net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame] | 692 | if (cookie_source.empty()) |
| 693 | cookie_source = site_url_.host(); |
| 694 | cookie_info.cookie_source = cookie_source; |
| 695 | cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_); |
| 696 | cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_); |
| 697 | cookie_info_list.push_back(cookie_info); |
| 698 | |
| 699 | // Add third party cookie counts. |
| 700 | cookie_info.cookie_source = l10n_util::GetStringUTF8( |
| 701 | IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA); |
| 702 | cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed; |
| 703 | cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked; |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 704 | cookie_info_list.push_back(cookie_info); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 705 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 706 | ui_->SetCookieInfo(cookie_info_list); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 707 | } |
[email protected] | 16de6de | 2012-04-04 12:24:14 | [diff] [blame] | 708 | |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 709 | void WebsiteSettings::PresentSiteIdentity() { |
palmer | f9b680a | 2015-07-09 18:56:04 | [diff] [blame^] | 710 | // After initialization the status about the site's connection and its |
| 711 | // identity must be available. |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 712 | DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN); |
| 713 | DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN); |
| 714 | WebsiteSettingsUI::IdentityInfo info; |
| 715 | if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT) |
| 716 | info.site_identity = UTF16ToUTF8(organization_name()); |
| 717 | else |
| 718 | info.site_identity = site_url_.host(); |
| 719 | |
| 720 | info.connection_status = site_connection_status_; |
| 721 | info.connection_status_description = |
| 722 | UTF16ToUTF8(site_connection_details_); |
| 723 | info.identity_status = site_identity_status_; |
| 724 | info.identity_status_description = |
| 725 | UTF16ToUTF8(site_identity_details_); |
[email protected] | f61c1ce | 2012-05-09 13:55:11 | [diff] [blame] | 726 | info.cert_id = cert_id_; |
[email protected] | 71cd5ef | 2014-08-13 21:22:04 | [diff] [blame] | 727 | info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 728 | ui_->SetIdentityInfo(info); |
| 729 | } |