[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] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 5 | #include "chrome/browser/website_settings.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 6 | |
| 7 | #include <string> |
| 8 | #include <vector> |
| 9 | |
| 10 | #include "base/string_number_conversions.h" |
| 11 | #include "base/utf_string_conversions.h" |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 12 | #include "base/values.h" |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 13 | #include "chrome/browser/browsing_data_cookie_helper.h" |
| 14 | #include "chrome/browser/browsing_data_database_helper.h" |
| 15 | #include "chrome/browser/browsing_data_local_storage_helper.h" |
| 16 | #include "chrome/browser/browsing_data_indexed_db_helper.h" |
| 17 | #include "chrome/browser/browsing_data_file_system_helper.h" |
| 18 | #include "chrome/browser/browsing_data_server_bound_cert_helper.h" |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 19 | #include "chrome/browser/content_settings/content_settings_utils.h" |
| 20 | #include "chrome/browser/content_settings/host_content_settings_map.h" |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 21 | #include "chrome/browser/content_settings/local_shared_objects_container.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 22 | #include "chrome/browser/profiles/profile.h" |
| 23 | #include "chrome/browser/ssl/ssl_error_info.h" |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 24 | #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 25 | #include "chrome/browser/ui/website_settings_ui.h" |
| 26 | #include "chrome/common/content_settings_pattern.h" |
| 27 | #include "content/public/browser/browser_thread.h" |
[email protected] | b59c6cf0 | 2012-03-12 20:51:42 | [diff] [blame] | 28 | #include "content/public/browser/cert_store.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 29 | #include "content/public/common/ssl_status.h" |
| 30 | #include "content/public/common/url_constants.h" |
| 31 | #include "grit/chromium_strings.h" |
| 32 | #include "grit/generated_resources.h" |
| 33 | #include "net/base/cert_status_flags.h" |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame^] | 34 | #include "net/base/registry_controlled_domain.h" |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 35 | #include "net/base/ssl_cipher_suite_names.h" |
| 36 | #include "net/base/ssl_connection_status_flags.h" |
| 37 | #include "net/base/x509_certificate.h" |
| 38 | #include "ui/base/l10n/l10n_util.h" |
| 39 | #include "ui/base/resource/resource_bundle.h" |
| 40 | |
[email protected] | 745ba583 | 2012-04-05 00:31:34 | [diff] [blame] | 41 | #if defined(TOOLKIT_GTK) |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 42 | #include "chrome/browser/ui/gtk/website_settings_popup_gtk.h" |
| 43 | #endif |
| 44 | |
| 45 | using content::BrowserThread; |
| 46 | |
| 47 | namespace { |
| 48 | |
| 49 | ContentSettingsType kPermissionType[] = { |
| 50 | CONTENT_SETTINGS_TYPE_POPUPS, |
| 51 | CONTENT_SETTINGS_TYPE_PLUGINS, |
| 52 | CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 53 | CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 54 | }; |
| 55 | |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 56 | } // namespace |
| 57 | |
| 58 | WebsiteSettings::WebsiteSettings( |
| 59 | WebsiteSettingsUI* ui, |
| 60 | Profile* profile, |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 61 | TabSpecificContentSettings* tab_specific_content_settings, |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 62 | const GURL& url, |
| 63 | const content::SSLStatus& ssl, |
| 64 | content::CertStore* cert_store) |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 65 | : TabSpecificContentSettings::SiteDataObserver( |
| 66 | tab_specific_content_settings), |
| 67 | ui_(ui), |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 68 | site_url_(url), |
| 69 | site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN), |
[email protected] | f61c1ce | 2012-05-09 13:55:11 | [diff] [blame] | 70 | cert_id_(0), |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 71 | site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN), |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 72 | cert_store_(cert_store), |
| 73 | content_settings_(profile->GetHostContentSettingsMap()) { |
| 74 | ui_->SetPresenter(this); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 75 | Init(profile, url, ssl); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 76 | |
| 77 | PresentSitePermissions(); |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 78 | PresentSiteData(); |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 79 | PresentSiteIdentity(); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 80 | } |
| 81 | |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 82 | WebsiteSettings::~WebsiteSettings() { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 83 | } |
| 84 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 85 | void WebsiteSettings::OnUIClosing() { |
| 86 | ui_->SetPresenter(NULL); |
| 87 | delete this; |
| 88 | } |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 89 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 90 | void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type, |
| 91 | ContentSetting setting) { |
| 92 | ContentSettingsPattern primary_pattern; |
| 93 | ContentSettingsPattern secondary_pattern; |
| 94 | switch (type) { |
| 95 | case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 96 | // TODO(markusheintz): The rule we create here should also change the |
| 97 | // location permission for iframed content. |
| 98 | primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_); |
| 99 | secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_); |
| 100 | break; |
| 101 | case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 102 | primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_); |
| 103 | secondary_pattern = ContentSettingsPattern::Wildcard(); |
| 104 | break; |
| 105 | case CONTENT_SETTINGS_TYPE_PLUGINS: |
| 106 | case CONTENT_SETTINGS_TYPE_POPUPS: |
| 107 | primary_pattern = ContentSettingsPattern::FromURL(site_url_); |
| 108 | secondary_pattern = ContentSettingsPattern::Wildcard(); |
| 109 | break; |
| 110 | default: |
| 111 | NOTREACHED() << "ContentSettingsType " << type << "is not supported."; |
| 112 | break; |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 113 | } |
| 114 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 115 | // Permission settings are specified via rules. There exists always at least |
| 116 | // one rule for the default setting. Get the rule that currently defines |
| 117 | // the permission for the given permission |type|. Then test whether the |
| 118 | // existing rule is more specific than the rule we are about to create. If |
| 119 | // the existing rule is more specific, than change the existing rule instead |
| 120 | // of creating a new rule that would be hidden behind the existing rule. |
| 121 | content_settings::SettingInfo info; |
| 122 | scoped_ptr<Value> v(content_settings_->GetWebsiteSetting( |
| 123 | site_url_, site_url_, type, "", &info)); |
| 124 | DCHECK(info.source == content_settings::SETTING_SOURCE_USER); |
| 125 | ContentSettingsPattern::Relation r1 = |
| 126 | info.primary_pattern.Compare(primary_pattern); |
| 127 | DCHECK(r1 != ContentSettingsPattern::DISJOINT_ORDER_POST && |
| 128 | r1 != ContentSettingsPattern::DISJOINT_ORDER_PRE); |
| 129 | if (r1 == ContentSettingsPattern::PREDECESSOR) { |
| 130 | primary_pattern = info.primary_pattern; |
| 131 | } else if (r1 == ContentSettingsPattern::IDENTITY) { |
| 132 | ContentSettingsPattern::Relation r2 = |
| 133 | info.secondary_pattern.Compare(secondary_pattern); |
| 134 | DCHECK(r2 != ContentSettingsPattern::DISJOINT_ORDER_POST && |
| 135 | r2 != ContentSettingsPattern::DISJOINT_ORDER_PRE); |
| 136 | if (r2 == ContentSettingsPattern::PREDECESSOR) |
| 137 | secondary_pattern = info.secondary_pattern; |
| 138 | } |
| 139 | |
| 140 | Value* value = NULL; |
| 141 | if (setting != CONTENT_SETTING_DEFAULT) |
| 142 | value = Value::CreateIntegerValue(setting); |
| 143 | content_settings_->SetWebsiteSetting( |
| 144 | primary_pattern, secondary_pattern, type, "", value); |
| 145 | } |
| 146 | |
| 147 | void WebsiteSettings::OnSiteDataAccessed() { |
| 148 | PresentSiteData(); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | void WebsiteSettings::Init(Profile* profile, |
| 152 | const GURL& url, |
| 153 | const content::SSLStatus& ssl) { |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 154 | if (url.SchemeIs(chrome::kChromeUIScheme)) { |
| 155 | site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE; |
| 156 | site_identity_details_ = |
| 157 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE); |
| 158 | site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE; |
| 159 | return; |
| 160 | } |
| 161 | |
| 162 | scoped_refptr<net::X509Certificate> cert; |
| 163 | |
| 164 | // Identity section. |
| 165 | string16 subject_name(UTF8ToUTF16(url.host())); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 166 | if (subject_name.empty()) { |
| 167 | subject_name.assign( |
| 168 | l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 169 | } |
| 170 | |
[email protected] | f61c1ce | 2012-05-09 13:55:11 | [diff] [blame] | 171 | cert_id_ = ssl.cert_id; |
| 172 | |
[email protected] | 03ef4b2a | 2012-03-06 15:04:20 | [diff] [blame] | 173 | if (ssl.cert_id && |
| 174 | cert_store_->RetrieveCert(ssl.cert_id, &cert) && |
| 175 | (!net::IsCertStatusError(ssl.cert_status) || |
| 176 | net::IsCertStatusMinorError(ssl.cert_status))) { |
| 177 | // There are no major errors. Check for minor errors. |
| 178 | if (net::IsCertStatusMinorError(ssl.cert_status)) { |
| 179 | site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN; |
| 180 | string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName())); |
| 181 | if (issuer_name.empty()) { |
| 182 | issuer_name.assign(l10n_util::GetStringUTF16( |
| 183 | IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 184 | } |
| 185 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
| 186 | IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name)); |
| 187 | |
| 188 | site_identity_details_ += ASCIIToUTF16("\n\n"); |
| 189 | if (ssl.cert_status & net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) { |
| 190 | site_identity_details_ += l10n_util::GetStringUTF16( |
| 191 | IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION); |
| 192 | } else if (ssl.cert_status & net::CERT_STATUS_NO_REVOCATION_MECHANISM) { |
| 193 | site_identity_details_ += l10n_util::GetStringUTF16( |
| 194 | IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM); |
| 195 | } else { |
| 196 | NOTREACHED() << "Need to specify string for this warning"; |
| 197 | } |
| 198 | } else if (ssl.cert_status & net::CERT_STATUS_IS_EV) { |
| 199 | // EV HTTPS page. |
| 200 | site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT; |
| 201 | DCHECK(!cert->subject().organization_names.empty()); |
| 202 | organization_name_ = UTF8ToUTF16(cert->subject().organization_names[0]); |
| 203 | // An EV Cert is required to have a city (localityName) and country but |
| 204 | // state is "if any". |
| 205 | DCHECK(!cert->subject().locality_name.empty()); |
| 206 | DCHECK(!cert->subject().country_name.empty()); |
| 207 | string16 locality; |
| 208 | if (!cert->subject().state_or_province_name.empty()) { |
| 209 | locality = l10n_util::GetStringFUTF16( |
| 210 | IDS_PAGEINFO_ADDRESS, |
| 211 | UTF8ToUTF16(cert->subject().locality_name), |
| 212 | UTF8ToUTF16(cert->subject().state_or_province_name), |
| 213 | UTF8ToUTF16(cert->subject().country_name)); |
| 214 | } else { |
| 215 | locality = l10n_util::GetStringFUTF16( |
| 216 | IDS_PAGEINFO_PARTIAL_ADDRESS, |
| 217 | UTF8ToUTF16(cert->subject().locality_name), |
| 218 | UTF8ToUTF16(cert->subject().country_name)); |
| 219 | } |
| 220 | DCHECK(!cert->subject().organization_names.empty()); |
| 221 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
| 222 | IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV, |
| 223 | UTF8ToUTF16(cert->subject().organization_names[0]), |
| 224 | locality, |
| 225 | UTF8ToUTF16(cert->issuer().GetDisplayName()))); |
| 226 | } else if (ssl.cert_status & net::CERT_STATUS_IS_DNSSEC) { |
| 227 | // DNSSEC authenticated page. |
| 228 | site_identity_status_ = SITE_IDENTITY_STATUS_DNSSEC_CERT; |
| 229 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
| 230 | IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, UTF8ToUTF16("DNSSEC"))); |
| 231 | } else { |
| 232 | // Non-EV OK HTTPS page. |
| 233 | site_identity_status_ = SITE_IDENTITY_STATUS_CERT; |
| 234 | string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName())); |
| 235 | if (issuer_name.empty()) { |
| 236 | issuer_name.assign(l10n_util::GetStringUTF16( |
| 237 | IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 238 | } |
| 239 | site_identity_details_.assign(l10n_util::GetStringFUTF16( |
| 240 | IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name)); |
| 241 | } |
| 242 | } else { |
| 243 | // HTTP or HTTPS with errors (not warnings). |
| 244 | site_identity_details_.assign(l10n_util::GetStringUTF16( |
| 245 | IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY)); |
| 246 | if (ssl.security_style == content::SECURITY_STYLE_UNAUTHENTICATED) |
| 247 | site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT; |
| 248 | else |
| 249 | site_identity_status_ = SITE_IDENTITY_STATUS_ERROR; |
| 250 | |
| 251 | const string16 bullet = UTF8ToUTF16("\n • "); |
| 252 | std::vector<SSLErrorInfo> errors; |
| 253 | SSLErrorInfo::GetErrorsForCertStatus(ssl.cert_id, ssl.cert_status, |
| 254 | url, &errors); |
| 255 | for (size_t i = 0; i < errors.size(); ++i) { |
| 256 | site_identity_details_ += bullet; |
| 257 | site_identity_details_ += errors[i].short_description(); |
| 258 | } |
| 259 | |
| 260 | if (ssl.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) { |
| 261 | site_identity_details_ += ASCIIToUTF16("\n\n"); |
| 262 | site_identity_details_ += l10n_util::GetStringUTF16( |
| 263 | IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME); |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | // Site Connection |
| 268 | // We consider anything less than 80 bits encryption to be weak encryption. |
| 269 | // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and |
| 270 | // weakly encrypted connections. |
| 271 | site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN; |
| 272 | |
| 273 | if (!ssl.cert_id) { |
| 274 | // Not HTTPS. |
| 275 | DCHECK_EQ(ssl.security_style, content::SECURITY_STYLE_UNAUTHENTICATED); |
| 276 | if (ssl.security_style == content::SECURITY_STYLE_UNAUTHENTICATED) |
| 277 | site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED; |
| 278 | else |
| 279 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; |
| 280 | |
| 281 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 282 | IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, |
| 283 | subject_name)); |
| 284 | } else if (ssl.security_bits < 0) { |
| 285 | // Security strength is unknown. Say nothing. |
| 286 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; |
| 287 | } else if (ssl.security_bits == 0) { |
| 288 | DCHECK_NE(ssl.security_style, content::SECURITY_STYLE_UNAUTHENTICATED); |
| 289 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; |
| 290 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 291 | IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, |
| 292 | subject_name)); |
| 293 | } else if (ssl.security_bits < 80) { |
| 294 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; |
| 295 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 296 | IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT, |
| 297 | subject_name)); |
| 298 | } else { |
| 299 | site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED; |
| 300 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 301 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, |
| 302 | subject_name, |
| 303 | base::IntToString16(ssl.security_bits))); |
| 304 | if (ssl.content_status) { |
| 305 | bool ran_insecure_content = |
| 306 | !!(ssl.content_status & content::SSLStatus::RAN_INSECURE_CONTENT); |
| 307 | site_connection_status_ = ran_insecure_content ? |
| 308 | SITE_CONNECTION_STATUS_ENCRYPTED_ERROR |
| 309 | : SITE_CONNECTION_STATUS_MIXED_CONTENT; |
| 310 | site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 311 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, |
| 312 | site_connection_details_, |
| 313 | l10n_util::GetStringUTF16(ran_insecure_content ? |
| 314 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR : |
| 315 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING))); |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | uint16 cipher_suite = |
| 320 | net::SSLConnectionStatusToCipherSuite(ssl.connection_status); |
| 321 | if (ssl.security_bits > 0 && cipher_suite) { |
| 322 | int ssl_version = |
| 323 | net::SSLConnectionStatusToVersion(ssl.connection_status); |
| 324 | const char* ssl_version_str; |
| 325 | net::SSLVersionToString(&ssl_version_str, ssl_version); |
| 326 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
| 327 | site_connection_details_ += l10n_util::GetStringFUTF16( |
| 328 | IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, |
| 329 | ASCIIToUTF16(ssl_version_str)); |
| 330 | |
| 331 | bool did_fallback = (ssl.connection_status & |
| 332 | net::SSL_CONNECTION_SSL3_FALLBACK) != 0; |
| 333 | bool no_renegotiation = |
| 334 | (ssl.connection_status & |
| 335 | net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0; |
| 336 | const char *key_exchange, *cipher, *mac; |
| 337 | net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, cipher_suite); |
| 338 | |
| 339 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
| 340 | site_connection_details_ += l10n_util::GetStringFUTF16( |
| 341 | IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, |
| 342 | ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange)); |
| 343 | |
| 344 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
| 345 | uint8 compression_id = |
| 346 | net::SSLConnectionStatusToCompression(ssl.connection_status); |
| 347 | if (compression_id) { |
| 348 | const char* compression; |
| 349 | net::SSLCompressionToString(&compression, compression_id); |
| 350 | site_connection_details_ += l10n_util::GetStringFUTF16( |
| 351 | IDS_PAGE_INFO_SECURITY_TAB_COMPRESSION_DETAILS, |
| 352 | ASCIIToUTF16(compression)); |
| 353 | } else { |
| 354 | site_connection_details_ += l10n_util::GetStringUTF16( |
| 355 | IDS_PAGE_INFO_SECURITY_TAB_NO_COMPRESSION); |
| 356 | } |
| 357 | |
| 358 | if (did_fallback) { |
| 359 | // For now, only SSLv3 fallback will trigger a warning icon. |
| 360 | if (site_connection_status_ < SITE_CONNECTION_STATUS_MIXED_CONTENT) |
| 361 | site_connection_status_ = SITE_CONNECTION_STATUS_MIXED_CONTENT; |
| 362 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
| 363 | site_connection_details_ += l10n_util::GetStringUTF16( |
| 364 | IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE); |
| 365 | } |
| 366 | if (no_renegotiation) { |
| 367 | site_connection_details_ += ASCIIToUTF16("\n\n"); |
| 368 | site_connection_details_ += l10n_util::GetStringUTF16( |
| 369 | IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE); |
| 370 | } |
| 371 | } |
| 372 | } |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 373 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 374 | void WebsiteSettings::PresentSitePermissions() { |
| 375 | PermissionInfoList permission_info_list; |
| 376 | |
| 377 | WebsiteSettingsUI::PermissionInfo permission_info; |
| 378 | for (size_t i = 0; i < arraysize(kPermissionType); ++i) { |
| 379 | permission_info.type = kPermissionType[i]; |
| 380 | |
| 381 | content_settings::SettingInfo info; |
| 382 | scoped_ptr<Value> value(content_settings_->GetWebsiteSetting( |
| 383 | site_url_, site_url_, permission_info.type, "", &info)); |
| 384 | DCHECK(value.get()); |
| 385 | permission_info.setting = |
| 386 | content_settings::ValueToContentSetting(value.get()); |
| 387 | |
| 388 | if (permission_info.setting != CONTENT_SETTING_ASK) { |
| 389 | if (info.primary_pattern == ContentSettingsPattern::Wildcard() && |
| 390 | info.secondary_pattern == ContentSettingsPattern::Wildcard()) { |
| 391 | permission_info.default_setting = permission_info.setting; |
| 392 | permission_info.setting = CONTENT_SETTING_DEFAULT; |
| 393 | } else { |
| 394 | permission_info.default_setting = |
| 395 | content_settings_->GetDefaultContentSetting(permission_info.type, |
| 396 | NULL); |
| 397 | } |
| 398 | permission_info_list.push_back(permission_info); |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | ui_->SetPermissionInfo(permission_info_list); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 403 | } |
| 404 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 405 | void WebsiteSettings::PresentSiteData() { |
| 406 | CookieInfoList cookie_info_list; |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame^] | 407 | const LocalSharedObjectsContainer& allowed_objects = |
| 408 | tab_specific_content_settings()->allowed_local_shared_objects(); |
| 409 | const LocalSharedObjectsContainer& blocked_objects = |
| 410 | tab_specific_content_settings()->blocked_local_shared_objects(); |
| 411 | |
| 412 | // Add first party cookie and site data counts. |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 413 | WebsiteSettingsUI::CookieInfo cookie_info; |
[email protected] | e0ac3589 | 2012-05-15 12:53:34 | [diff] [blame^] | 414 | std::string cookie_source = |
| 415 | net::RegistryControlledDomainService::GetDomainAndRegistry(site_url_); |
| 416 | if (cookie_source.empty()) |
| 417 | cookie_source = site_url_.host(); |
| 418 | cookie_info.cookie_source = cookie_source; |
| 419 | cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_); |
| 420 | cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_); |
| 421 | cookie_info_list.push_back(cookie_info); |
| 422 | |
| 423 | // Add third party cookie counts. |
| 424 | cookie_info.cookie_source = l10n_util::GetStringUTF8( |
| 425 | IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA); |
| 426 | cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed; |
| 427 | cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked; |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 428 | cookie_info_list.push_back(cookie_info); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 429 | |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 430 | ui_->SetCookieInfo(cookie_info_list); |
[email protected] | 0b9fdd7 | 2012-04-04 10:00:33 | [diff] [blame] | 431 | } |
[email protected] | 16de6de | 2012-04-04 12:24:14 | [diff] [blame] | 432 | |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 433 | void WebsiteSettings::PresentSiteIdentity() { |
| 434 | // After initialization the status about the site's connection |
| 435 | // and it's identity must be available. |
| 436 | DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN); |
| 437 | DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN); |
| 438 | WebsiteSettingsUI::IdentityInfo info; |
| 439 | if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT) |
| 440 | info.site_identity = UTF16ToUTF8(organization_name()); |
| 441 | else |
| 442 | info.site_identity = site_url_.host(); |
| 443 | |
| 444 | info.connection_status = site_connection_status_; |
| 445 | info.connection_status_description = |
| 446 | UTF16ToUTF8(site_connection_details_); |
| 447 | info.identity_status = site_identity_status_; |
| 448 | info.identity_status_description = |
| 449 | UTF16ToUTF8(site_identity_details_); |
[email protected] | f61c1ce | 2012-05-09 13:55:11 | [diff] [blame] | 450 | info.cert_id = cert_id_; |
[email protected] | 24c8818c | 2012-04-25 09:57:41 | [diff] [blame] | 451 | ui_->SetIdentityInfo(info); |
| 452 | } |
| 453 | |
[email protected] | 16de6de | 2012-04-04 12:24:14 | [diff] [blame] | 454 | // static |
| 455 | void WebsiteSettings::Show(gfx::NativeWindow parent, |
| 456 | Profile* profile, |
| 457 | TabContentsWrapper* tab_contents_wrapper, |
| 458 | const GURL& url, |
| 459 | const content::SSLStatus& ssl) { |
[email protected] | 745ba583 | 2012-04-05 00:31:34 | [diff] [blame] | 460 | #if defined(TOOLKIT_GTK) |
[email protected] | 16de6de | 2012-04-04 12:24:14 | [diff] [blame] | 461 | // The WebsiteSettingsModel will delete itself after the UI is closed. |
| 462 | new WebsiteSettings(new WebsiteSettingsPopupGtk(parent, |
| 463 | profile, |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 464 | tab_contents_wrapper), |
[email protected] | 16de6de | 2012-04-04 12:24:14 | [diff] [blame] | 465 | profile, |
[email protected] | df81827 | 2012-04-20 13:10:50 | [diff] [blame] | 466 | tab_contents_wrapper->content_settings(), |
[email protected] | 16de6de | 2012-04-04 12:24:14 | [diff] [blame] | 467 | url, |
| 468 | ssl, |
| 469 | content::CertStore::GetInstance()); |
| 470 | #endif |
| 471 | } |