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