Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 #include "chrome/browser/net/ssl_config_service_manager.h" | 4 #include "chrome/browser/net/ssl_config_service_manager.h" |
| 5 | 5 |
| 6 #include <algorithm> | 6 #include <algorithm> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/command_line.h" | |
| 11 #include "chrome/browser/prefs/pref_change_registrar.h" | 12 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 12 #include "chrome/browser/prefs/pref_member.h" | 13 #include "chrome/browser/prefs/pref_member.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "chrome/common/chrome_switches.h" | |
| 15 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 16 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
| 17 #include "content/common/notification_details.h" | 19 #include "content/common/notification_details.h" |
| 18 #include "content/common/notification_source.h" | 20 #include "content/common/notification_source.h" |
| 19 #include "net/base/ssl_cipher_suite_names.h" | 21 #include "net/base/ssl_cipher_suite_names.h" |
| 20 #include "net/base/ssl_config_service.h" | 22 #include "net/base/ssl_config_service.h" |
| 21 | 23 |
| 22 namespace { | 24 namespace { |
| 23 | 25 |
| 24 // Converts a ListValue of StringValues into a vector of strings. Any Values | 26 // Converts a ListValue of StringValues into a vector of strings. Any Values |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 void GetSSLConfigFromPrefs(net::SSLConfig* config); | 129 void GetSSLConfigFromPrefs(net::SSLConfig* config); |
| 128 | 130 |
| 129 // Processes changes to the disabled cipher suites preference, updating the | 131 // Processes changes to the disabled cipher suites preference, updating the |
| 130 // cached list of parsed SSL/TLS cipher suites that are disabled. | 132 // cached list of parsed SSL/TLS cipher suites that are disabled. |
| 131 void OnDisabledCipherSuitesChange(PrefService* prefs); | 133 void OnDisabledCipherSuitesChange(PrefService* prefs); |
| 132 | 134 |
| 133 PrefChangeRegistrar pref_change_registrar_; | 135 PrefChangeRegistrar pref_change_registrar_; |
| 134 | 136 |
| 135 // The prefs (should only be accessed from UI thread) | 137 // The prefs (should only be accessed from UI thread) |
| 136 BooleanPrefMember rev_checking_enabled_; | 138 BooleanPrefMember rev_checking_enabled_; |
| 137 BooleanPrefMember ssl3_enabled_; | |
| 138 BooleanPrefMember tls1_enabled_; | |
| 139 | 139 |
| 140 // The cached list of disabled SSL cipher suites. | 140 // The cached list of disabled SSL cipher suites. |
| 141 std::vector<uint16> disabled_cipher_suites_; | 141 std::vector<uint16> disabled_cipher_suites_; |
|
wtc
2011/08/24 19:37:30
It seems strange that ssl3_enabled_ and tls1_enabl
| |
| 142 | 142 |
| 143 scoped_refptr<SSLConfigServicePref> ssl_config_service_; | 143 scoped_refptr<SSLConfigServicePref> ssl_config_service_; |
| 144 | 144 |
| 145 DISALLOW_COPY_AND_ASSIGN(SSLConfigServiceManagerPref); | 145 DISALLOW_COPY_AND_ASSIGN(SSLConfigServiceManagerPref); |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 SSLConfigServiceManagerPref::SSLConfigServiceManagerPref( | 148 SSLConfigServiceManagerPref::SSLConfigServiceManagerPref( |
| 149 PrefService* local_state) | 149 PrefService* local_state) |
| 150 : ssl_config_service_(new SSLConfigServicePref()) { | 150 : ssl_config_service_(new SSLConfigServicePref()) { |
| 151 DCHECK(local_state); | 151 DCHECK(local_state); |
| 152 | 152 |
| 153 rev_checking_enabled_.Init(prefs::kCertRevocationCheckingEnabled, | 153 rev_checking_enabled_.Init(prefs::kCertRevocationCheckingEnabled, |
| 154 local_state, this); | 154 local_state, this); |
| 155 ssl3_enabled_.Init(prefs::kSSL3Enabled, local_state, this); | |
| 156 tls1_enabled_.Init(prefs::kTLS1Enabled, local_state, this); | |
| 157 pref_change_registrar_.Init(local_state); | 155 pref_change_registrar_.Init(local_state); |
| 158 pref_change_registrar_.Add(prefs::kCipherSuiteBlacklist, this); | 156 pref_change_registrar_.Add(prefs::kCipherSuiteBlacklist, this); |
| 159 | 157 |
| 160 OnDisabledCipherSuitesChange(local_state); | 158 OnDisabledCipherSuitesChange(local_state); |
| 161 // Initialize from UI thread. This is okay as there shouldn't be anything on | 159 // Initialize from UI thread. This is okay as there shouldn't be anything on |
| 162 // the IO thread trying to access it yet. | 160 // the IO thread trying to access it yet. |
| 163 GetSSLConfigFromPrefs(&ssl_config_service_->cached_config_); | 161 GetSSLConfigFromPrefs(&ssl_config_service_->cached_config_); |
| 164 } | 162 } |
| 165 | 163 |
| 166 // static | 164 // static |
| 167 void SSLConfigServiceManagerPref::RegisterPrefs(PrefService* prefs) { | 165 void SSLConfigServiceManagerPref::RegisterPrefs(PrefService* prefs) { |
| 168 net::SSLConfig default_config; | 166 net::SSLConfig default_config; |
| 169 prefs->RegisterBooleanPref(prefs::kCertRevocationCheckingEnabled, | 167 prefs->RegisterBooleanPref(prefs::kCertRevocationCheckingEnabled, |
| 170 default_config.rev_checking_enabled); | 168 default_config.rev_checking_enabled); |
| 171 prefs->RegisterBooleanPref(prefs::kSSL3Enabled, | |
| 172 default_config.ssl3_enabled); | |
| 173 prefs->RegisterBooleanPref(prefs::kTLS1Enabled, | |
| 174 default_config.tls1_enabled); | |
| 175 prefs->RegisterListPref(prefs::kCipherSuiteBlacklist); | 169 prefs->RegisterListPref(prefs::kCipherSuiteBlacklist); |
| 176 } | 170 } |
| 177 | 171 |
| 178 net::SSLConfigService* SSLConfigServiceManagerPref::Get() { | 172 net::SSLConfigService* SSLConfigServiceManagerPref::Get() { |
| 179 return ssl_config_service_; | 173 return ssl_config_service_; |
| 180 } | 174 } |
| 181 | 175 |
| 182 void SSLConfigServiceManagerPref::Observe(int type, | 176 void SSLConfigServiceManagerPref::Observe(int type, |
| 183 const NotificationSource& source, | 177 const NotificationSource& source, |
| 184 const NotificationDetails& details) { | 178 const NotificationDetails& details) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 201 NewRunnableMethod( | 195 NewRunnableMethod( |
| 202 ssl_config_service_.get(), | 196 ssl_config_service_.get(), |
| 203 &SSLConfigServicePref::SetNewSSLConfig, | 197 &SSLConfigServicePref::SetNewSSLConfig, |
| 204 new_config)); | 198 new_config)); |
| 205 } | 199 } |
| 206 } | 200 } |
| 207 | 201 |
| 208 void SSLConfigServiceManagerPref::GetSSLConfigFromPrefs( | 202 void SSLConfigServiceManagerPref::GetSSLConfigFromPrefs( |
| 209 net::SSLConfig* config) { | 203 net::SSLConfig* config) { |
| 210 config->rev_checking_enabled = rev_checking_enabled_.GetValue(); | 204 config->rev_checking_enabled = rev_checking_enabled_.GetValue(); |
| 211 config->ssl3_enabled = ssl3_enabled_.GetValue(); | 205 |
| 212 config->tls1_enabled = tls1_enabled_.GetValue(); | 206 config->ssl3_enabled = |
| 207 !(CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableSSL3)); | |
| 208 config->tls1_enabled = | |
| 209 !(CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableTLS1)); | |
|
wtc
2011/08/24 19:37:30
Nit: omit the outer parentheses ().
Line 207 and
| |
| 210 | |
| 213 config->disabled_cipher_suites = disabled_cipher_suites_; | 211 config->disabled_cipher_suites = disabled_cipher_suites_; |
| 214 SSLConfigServicePref::SetSSLConfigFlags(config); | 212 SSLConfigServicePref::SetSSLConfigFlags(config); |
| 215 } | 213 } |
| 216 | 214 |
| 217 void SSLConfigServiceManagerPref::OnDisabledCipherSuitesChange( | 215 void SSLConfigServiceManagerPref::OnDisabledCipherSuitesChange( |
| 218 PrefService* prefs) { | 216 PrefService* prefs) { |
| 219 const ListValue* value = prefs->GetList(prefs::kCipherSuiteBlacklist); | 217 const ListValue* value = prefs->GetList(prefs::kCipherSuiteBlacklist); |
| 220 disabled_cipher_suites_ = ParseCipherSuites(ListValueToStringVector(value)); | 218 disabled_cipher_suites_ = ParseCipherSuites(ListValueToStringVector(value)); |
| 221 } | 219 } |
| 222 | 220 |
| 223 //////////////////////////////////////////////////////////////////////////////// | 221 //////////////////////////////////////////////////////////////////////////////// |
| 224 // SSLConfigServiceManager | 222 // SSLConfigServiceManager |
| 225 | 223 |
| 226 // static | 224 // static |
| 227 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager( | 225 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager( |
| 228 PrefService* local_state) { | 226 PrefService* local_state) { |
| 229 return new SSLConfigServiceManagerPref(local_state); | 227 return new SSLConfigServiceManagerPref(local_state); |
| 230 } | 228 } |
| 231 | 229 |
| 232 // static | 230 // static |
| 233 void SSLConfigServiceManager::RegisterPrefs(PrefService* prefs) { | 231 void SSLConfigServiceManager::RegisterPrefs(PrefService* prefs) { |
| 234 SSLConfigServiceManagerPref::RegisterPrefs(prefs); | 232 SSLConfigServiceManagerPref::RegisterPrefs(prefs); |
| 235 } | 233 } |
| OLD | NEW |