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