OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/bind.h" | 11 #include "base/bind.h" |
12 #include "base/prefs/public/pref_change_registrar.h" | 12 #include "base/prefs/public/pref_change_registrar.h" |
13 #include "base/prefs/public/pref_member.h" | 13 #include "base/prefs/public/pref_member.h" |
14 #include "chrome/browser/content_settings/content_settings_utils.h" | 14 #include "chrome/browser/content_settings/content_settings_utils.h" |
| 15 #include "chrome/browser/prefs/pref_registry_simple.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
16 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
17 #include "chrome/common/content_settings.h" | 18 #include "chrome/common/content_settings.h" |
18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
20 #include "net/base/ssl_cipher_suite_names.h" | 21 #include "net/base/ssl_cipher_suite_names.h" |
21 #include "net/base/ssl_config_service.h" | 22 #include "net/base/ssl_config_service.h" |
22 | 23 |
23 using content::BrowserThread; | 24 using content::BrowserThread; |
24 | 25 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 143 |
143 // The manager for holding and updating an SSLConfigServicePref instance. | 144 // The manager for holding and updating an SSLConfigServicePref instance. |
144 class SSLConfigServiceManagerPref | 145 class SSLConfigServiceManagerPref |
145 : public SSLConfigServiceManager { | 146 : public SSLConfigServiceManager { |
146 public: | 147 public: |
147 SSLConfigServiceManagerPref(PrefService* local_state, | 148 SSLConfigServiceManagerPref(PrefService* local_state, |
148 PrefService* user_prefs); | 149 PrefService* user_prefs); |
149 virtual ~SSLConfigServiceManagerPref() {} | 150 virtual ~SSLConfigServiceManagerPref() {} |
150 | 151 |
151 // Register local_state SSL preferences. | 152 // Register local_state SSL preferences. |
152 static void RegisterPrefs(PrefServiceSimple* local_state); | 153 static void RegisterPrefs(PrefRegistrySimple* registry); |
153 | 154 |
154 virtual net::SSLConfigService* Get(); | 155 virtual net::SSLConfigService* Get(); |
155 | 156 |
156 private: | 157 private: |
157 // Callback for preference changes. This will post the changes to the IO | 158 // Callback for preference changes. This will post the changes to the IO |
158 // thread with SetNewSSLConfig. | 159 // thread with SetNewSSLConfig. |
159 void OnPreferenceChanged(PrefServiceBase* prefs, | 160 void OnPreferenceChanged(PrefServiceBase* prefs, |
160 const std::string& pref_name); | 161 const std::string& pref_name); |
161 | 162 |
162 // Store SSL config settings in |config|, directly from the preferences. Must | 163 // Store SSL config settings in |config|, directly from the preferences. Must |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 239 |
239 OnDefaultContentSettingsChange(user_prefs); | 240 OnDefaultContentSettingsChange(user_prefs); |
240 } | 241 } |
241 | 242 |
242 // Initialize from UI thread. This is okay as there shouldn't be anything on | 243 // Initialize from UI thread. This is okay as there shouldn't be anything on |
243 // the IO thread trying to access it yet. | 244 // the IO thread trying to access it yet. |
244 GetSSLConfigFromPrefs(&ssl_config_service_->cached_config_); | 245 GetSSLConfigFromPrefs(&ssl_config_service_->cached_config_); |
245 } | 246 } |
246 | 247 |
247 // static | 248 // static |
248 void SSLConfigServiceManagerPref::RegisterPrefs( | 249 void SSLConfigServiceManagerPref::RegisterPrefs(PrefRegistrySimple* registry) { |
249 PrefServiceSimple* local_state) { | |
250 net::SSLConfig default_config; | 250 net::SSLConfig default_config; |
251 local_state->RegisterBooleanPref(prefs::kCertRevocationCheckingEnabled, | 251 registry->RegisterBooleanPref(prefs::kCertRevocationCheckingEnabled, |
252 default_config.rev_checking_enabled); | 252 default_config.rev_checking_enabled); |
253 std::string version_min_str = | 253 std::string version_min_str = |
254 SSLProtocolVersionToString(default_config.version_min); | 254 SSLProtocolVersionToString(default_config.version_min); |
255 std::string version_max_str = | 255 std::string version_max_str = |
256 SSLProtocolVersionToString(default_config.version_max); | 256 SSLProtocolVersionToString(default_config.version_max); |
257 local_state->RegisterStringPref(prefs::kSSLVersionMin, version_min_str); | 257 registry->RegisterStringPref(prefs::kSSLVersionMin, version_min_str); |
258 local_state->RegisterStringPref(prefs::kSSLVersionMax, version_max_str); | 258 registry->RegisterStringPref(prefs::kSSLVersionMax, version_max_str); |
259 local_state->RegisterBooleanPref(prefs::kEnableOriginBoundCerts, | 259 registry->RegisterBooleanPref(prefs::kEnableOriginBoundCerts, |
260 default_config.channel_id_enabled); | 260 default_config.channel_id_enabled); |
261 local_state->RegisterBooleanPref(prefs::kDisableSSLRecordSplitting, | 261 registry->RegisterBooleanPref(prefs::kDisableSSLRecordSplitting, |
262 !default_config.false_start_enabled); | 262 !default_config.false_start_enabled); |
263 local_state->RegisterListPref(prefs::kCipherSuiteBlacklist); | 263 registry->RegisterListPref(prefs::kCipherSuiteBlacklist); |
264 } | 264 } |
265 | 265 |
266 net::SSLConfigService* SSLConfigServiceManagerPref::Get() { | 266 net::SSLConfigService* SSLConfigServiceManagerPref::Get() { |
267 return ssl_config_service_; | 267 return ssl_config_service_; |
268 } | 268 } |
269 | 269 |
270 void SSLConfigServiceManagerPref::OnPreferenceChanged( | 270 void SSLConfigServiceManagerPref::OnPreferenceChanged( |
271 PrefServiceBase* prefs, | 271 PrefServiceBase* prefs, |
272 const std::string& pref_name_in) { | 272 const std::string& pref_name_in) { |
273 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 273 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 //////////////////////////////////////////////////////////////////////////////// | 346 //////////////////////////////////////////////////////////////////////////////// |
347 // SSLConfigServiceManager | 347 // SSLConfigServiceManager |
348 | 348 |
349 // static | 349 // static |
350 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager( | 350 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager( |
351 PrefService* local_state, PrefService* user_prefs) { | 351 PrefService* local_state, PrefService* user_prefs) { |
352 return new SSLConfigServiceManagerPref(local_state, user_prefs); | 352 return new SSLConfigServiceManagerPref(local_state, user_prefs); |
353 } | 353 } |
354 | 354 |
355 // static | 355 // static |
356 void SSLConfigServiceManager::RegisterPrefs(PrefServiceSimple* prefs) { | 356 void SSLConfigServiceManager::RegisterPrefs(PrefRegistrySimple* registry) { |
357 SSLConfigServiceManagerPref::RegisterPrefs(prefs); | 357 SSLConfigServiceManagerPref::RegisterPrefs(registry); |
358 } | 358 } |
OLD | NEW |