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