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 | 4 |
5 #include "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/threading/thread.h" | 6 #include "base/threading/thread.h" |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/io_thread.h" | 8 #include "chrome/browser/io_thread.h" |
9 #include "chrome/browser/net/ssl_config_service_manager.h" | 9 #include "chrome/browser/net/ssl_config_service_manager.h" |
10 #include "chrome/browser/prefs/pref_member.h" | 10 #include "chrome/browser/prefs/pref_member.h" |
11 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 13 #include "content/common/content_notification_types.h" |
13 #include "content/common/notification_details.h" | 14 #include "content/common/notification_details.h" |
14 #include "content/common/notification_source.h" | 15 #include "content/common/notification_source.h" |
15 #include "content/common/notification_type.h" | |
16 #include "net/base/ssl_config_service.h" | 16 #include "net/base/ssl_config_service.h" |
17 | 17 |
18 //////////////////////////////////////////////////////////////////////////////// | 18 //////////////////////////////////////////////////////////////////////////////// |
19 // SSLConfigServicePref | 19 // SSLConfigServicePref |
20 | 20 |
21 // An SSLConfigService which stores a cached version of the current SSLConfig | 21 // An SSLConfigService which stores a cached version of the current SSLConfig |
22 // prefs, which are updated by SSLConfigServiceManagerPref when the prefs | 22 // prefs, which are updated by SSLConfigServiceManagerPref when the prefs |
23 // change. | 23 // change. |
24 class SSLConfigServicePref : public net::SSLConfigService { | 24 class SSLConfigServicePref : public net::SSLConfigService { |
25 public: | 25 public: |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 virtual ~SSLConfigServiceManagerPref() {} | 66 virtual ~SSLConfigServiceManagerPref() {} |
67 | 67 |
68 virtual net::SSLConfigService* Get(); | 68 virtual net::SSLConfigService* Get(); |
69 | 69 |
70 private: | 70 private: |
71 // Register local_state SSL preferences. | 71 // Register local_state SSL preferences. |
72 static void RegisterPrefs(PrefService* prefs); | 72 static void RegisterPrefs(PrefService* prefs); |
73 | 73 |
74 // Callback for preference changes. This will post the changes to the IO | 74 // Callback for preference changes. This will post the changes to the IO |
75 // thread with SetNewSSLConfig. | 75 // thread with SetNewSSLConfig. |
76 virtual void Observe(NotificationType type, | 76 virtual void Observe(int type, |
77 const NotificationSource& source, | 77 const NotificationSource& source, |
78 const NotificationDetails& details); | 78 const NotificationDetails& details); |
79 | 79 |
80 // Store SSL config settings in |config|, directly from the preferences. Must | 80 // Store SSL config settings in |config|, directly from the preferences. Must |
81 // only be called from UI thread. | 81 // only be called from UI thread. |
82 void GetSSLConfigFromPrefs(net::SSLConfig* config); | 82 void GetSSLConfigFromPrefs(net::SSLConfig* config); |
83 | 83 |
84 // The prefs (should only be accessed from UI thread) | 84 // The prefs (should only be accessed from UI thread) |
85 BooleanPrefMember rev_checking_enabled_; | 85 BooleanPrefMember rev_checking_enabled_; |
86 BooleanPrefMember ssl3_enabled_; | 86 BooleanPrefMember ssl3_enabled_; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 if (!prefs->FindPreference(prefs::kTLS1Enabled)) { | 122 if (!prefs->FindPreference(prefs::kTLS1Enabled)) { |
123 prefs->RegisterBooleanPref(prefs::kTLS1Enabled, | 123 prefs->RegisterBooleanPref(prefs::kTLS1Enabled, |
124 default_config.tls1_enabled); | 124 default_config.tls1_enabled); |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 net::SSLConfigService* SSLConfigServiceManagerPref::Get() { | 128 net::SSLConfigService* SSLConfigServiceManagerPref::Get() { |
129 return ssl_config_service_; | 129 return ssl_config_service_; |
130 } | 130 } |
131 | 131 |
132 void SSLConfigServiceManagerPref::Observe(NotificationType type, | 132 void SSLConfigServiceManagerPref::Observe(int type, |
133 const NotificationSource& source, | 133 const NotificationSource& source, |
134 const NotificationDetails& details) { | 134 const NotificationDetails& details) { |
135 base::Thread* io_thread = g_browser_process->io_thread(); | 135 base::Thread* io_thread = g_browser_process->io_thread(); |
136 if (io_thread) { | 136 if (io_thread) { |
137 net::SSLConfig new_config; | 137 net::SSLConfig new_config; |
138 GetSSLConfigFromPrefs(&new_config); | 138 GetSSLConfigFromPrefs(&new_config); |
139 | 139 |
140 // Post a task to |io_loop| with the new configuration, so it can | 140 // Post a task to |io_loop| with the new configuration, so it can |
141 // update |cached_config_|. | 141 // update |cached_config_|. |
142 io_thread->message_loop()->PostTask( | 142 io_thread->message_loop()->PostTask( |
(...skipping 14 matching lines...) Expand all Loading... |
157 } | 157 } |
158 | 158 |
159 //////////////////////////////////////////////////////////////////////////////// | 159 //////////////////////////////////////////////////////////////////////////////// |
160 // SSLConfigServiceManager | 160 // SSLConfigServiceManager |
161 | 161 |
162 // static | 162 // static |
163 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager( | 163 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager( |
164 PrefService* local_state) { | 164 PrefService* local_state) { |
165 return new SSLConfigServiceManagerPref(local_state); | 165 return new SSLConfigServiceManagerPref(local_state); |
166 } | 166 } |
OLD | NEW |