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/pref_change_registrar.h" | 12 #include "base/prefs/pref_change_registrar.h" |
13 #include "base/prefs/pref_member.h" | 13 #include "base/prefs/pref_member.h" |
14 #include "base/prefs/pref_registry_simple.h" | 14 #include "base/prefs/pref_registry_simple.h" |
15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
17 #include "chrome/browser/content_settings/content_settings_utils.h" | 17 #include "chrome/browser/content_settings/content_settings_utils.h" |
18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
19 #include "components/content_settings/core/common/content_settings.h" | 19 #include "components/content_settings/core/common/content_settings.h" |
20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "net/cert/ct_ev_whitelist.h" |
21 #include "net/ssl/ssl_cipher_suite_names.h" | 22 #include "net/ssl/ssl_cipher_suite_names.h" |
22 #include "net/ssl/ssl_config_service.h" | 23 #include "net/ssl/ssl_config_service.h" |
23 | 24 |
24 using content::BrowserThread; | 25 using content::BrowserThread; |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 // Converts a ListValue of StringValues into a vector of strings. Any Values | 29 // Converts a ListValue of StringValues into a vector of strings. Any Values |
29 // which cannot be converted will be skipped. | 30 // which cannot be converted will be skipped. |
30 std::vector<std::string> ListValueToStringVector(const base::ListValue* value) { | 31 std::vector<std::string> ListValueToStringVector(const base::ListValue* value) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // An SSLConfigService which stores a cached version of the current SSLConfig | 105 // An SSLConfigService which stores a cached version of the current SSLConfig |
105 // prefs, which are updated by SSLConfigServiceManagerPref when the prefs | 106 // prefs, which are updated by SSLConfigServiceManagerPref when the prefs |
106 // change. | 107 // change. |
107 class SSLConfigServicePref : public net::SSLConfigService { | 108 class SSLConfigServicePref : public net::SSLConfigService { |
108 public: | 109 public: |
109 SSLConfigServicePref() {} | 110 SSLConfigServicePref() {} |
110 | 111 |
111 // Store SSL config settings in |config|. Must only be called from IO thread. | 112 // Store SSL config settings in |config|. Must only be called from IO thread. |
112 virtual void GetSSLConfig(net::SSLConfig* config) OVERRIDE; | 113 virtual void GetSSLConfig(net::SSLConfig* config) OVERRIDE; |
113 | 114 |
| 115 // Sets and gets the current, global EV certificates whitelist |
| 116 virtual void SetEVCertsWhitelist( |
| 117 scoped_refptr<net::ct::EVCertsWhitelist> ev_whitelist) OVERRIDE; |
| 118 |
114 private: | 119 private: |
115 // Allow the pref watcher to update our internal state. | 120 // Allow the pref watcher to update our internal state. |
116 friend class SSLConfigServiceManagerPref; | 121 friend class SSLConfigServiceManagerPref; |
117 | 122 |
118 virtual ~SSLConfigServicePref() {} | 123 virtual ~SSLConfigServicePref() {} |
119 | 124 |
120 // This method is posted to the IO thread from the browser thread to carry the | 125 // This method is posted to the IO thread from the browser thread to carry the |
121 // new config information. | 126 // new config information. |
122 void SetNewSSLConfig(const net::SSLConfig& new_config); | 127 void SetNewSSLConfig(const net::SSLConfig& new_config); |
123 | 128 |
124 // Cached value of prefs, should only be accessed from IO thread. | 129 // Cached value of prefs, should only be accessed from IO thread. |
125 net::SSLConfig cached_config_; | 130 net::SSLConfig cached_config_; |
126 | 131 |
127 DISALLOW_COPY_AND_ASSIGN(SSLConfigServicePref); | 132 DISALLOW_COPY_AND_ASSIGN(SSLConfigServicePref); |
128 }; | 133 }; |
129 | 134 |
130 void SSLConfigServicePref::GetSSLConfig(net::SSLConfig* config) { | 135 void SSLConfigServicePref::GetSSLConfig(net::SSLConfig* config) { |
131 *config = cached_config_; | 136 *config = cached_config_; |
132 } | 137 } |
133 | 138 |
134 void SSLConfigServicePref::SetNewSSLConfig( | 139 void SSLConfigServicePref::SetNewSSLConfig( |
135 const net::SSLConfig& new_config) { | 140 const net::SSLConfig& new_config) { |
136 net::SSLConfig orig_config = cached_config_; | 141 net::SSLConfig orig_config = cached_config_; |
137 cached_config_ = new_config; | 142 cached_config_ = new_config; |
138 ProcessConfigUpdate(orig_config, new_config); | 143 ProcessConfigUpdate(orig_config, new_config); |
139 } | 144 } |
140 | 145 |
| 146 void SSLConfigServicePref::SetEVCertsWhitelist( |
| 147 scoped_refptr<net::ct::EVCertsWhitelist> ev_whitelist) { |
| 148 cached_config_.ev_certs_whitelist = ev_whitelist; |
| 149 } |
| 150 |
141 //////////////////////////////////////////////////////////////////////////////// | 151 //////////////////////////////////////////////////////////////////////////////// |
142 // SSLConfigServiceManagerPref | 152 // SSLConfigServiceManagerPref |
143 | 153 |
144 // The manager for holding and updating an SSLConfigServicePref instance. | 154 // The manager for holding and updating an SSLConfigServicePref instance. |
145 class SSLConfigServiceManagerPref | 155 class SSLConfigServiceManagerPref |
146 : public SSLConfigServiceManager { | 156 : public SSLConfigServiceManager { |
147 public: | 157 public: |
148 explicit SSLConfigServiceManagerPref(PrefService* local_state); | 158 explicit SSLConfigServiceManagerPref(PrefService* local_state); |
149 virtual ~SSLConfigServiceManagerPref() {} | 159 virtual ~SSLConfigServiceManagerPref() {} |
150 | 160 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 // static | 321 // static |
312 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager( | 322 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager( |
313 PrefService* local_state) { | 323 PrefService* local_state) { |
314 return new SSLConfigServiceManagerPref(local_state); | 324 return new SSLConfigServiceManagerPref(local_state); |
315 } | 325 } |
316 | 326 |
317 // static | 327 // static |
318 void SSLConfigServiceManager::RegisterPrefs(PrefRegistrySimple* registry) { | 328 void SSLConfigServiceManager::RegisterPrefs(PrefRegistrySimple* registry) { |
319 SSLConfigServiceManagerPref::RegisterPrefs(registry); | 329 SSLConfigServiceManagerPref::RegisterPrefs(registry); |
320 } | 330 } |
OLD | NEW |