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