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 | 4 |
5 #include "net/base/ssl_config_service.h" | 5 #include "net/base/ssl_config_service.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "net/base/crl_set.h" | 10 #include "net/base/crl_set.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 } | 59 } |
60 return false; | 60 return false; |
61 } | 61 } |
62 | 62 |
63 SSLConfigService::SSLConfigService() | 63 SSLConfigService::SSLConfigService() |
64 : observer_list_(ObserverList<Observer>::NOTIFY_EXISTING_ONLY) { | 64 : observer_list_(ObserverList<Observer>::NOTIFY_EXISTING_ONLY) { |
65 } | 65 } |
66 | 66 |
67 static bool g_cached_info_enabled = false; | 67 static bool g_cached_info_enabled = false; |
68 static bool g_channel_id_trial = false; | |
69 | 68 |
70 // GlobalCRLSet holds a reference to the global CRLSet. It simply wraps a lock | 69 // GlobalCRLSet holds a reference to the global CRLSet. It simply wraps a lock |
71 // around a scoped_refptr so that getting a reference doesn't race with | 70 // around a scoped_refptr so that getting a reference doesn't race with |
72 // updating the CRLSet. | 71 // updating the CRLSet. |
73 class GlobalCRLSet { | 72 class GlobalCRLSet { |
74 public: | 73 public: |
75 void Set(const scoped_refptr<CRLSet>& new_crl_set) { | 74 void Set(const scoped_refptr<CRLSet>& new_crl_set) { |
76 base::AutoLock locked(lock_); | 75 base::AutoLock locked(lock_); |
77 crl_set_ = new_crl_set; | 76 crl_set_ = new_crl_set; |
78 } | 77 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // static | 116 // static |
118 void SSLConfigService::SetDefaultVersionMax(uint16 version_max) { | 117 void SSLConfigService::SetDefaultVersionMax(uint16 version_max) { |
119 g_default_version_max = version_max; | 118 g_default_version_max = version_max; |
120 } | 119 } |
121 | 120 |
122 // static | 121 // static |
123 uint16 SSLConfigService::default_version_max() { | 122 uint16 SSLConfigService::default_version_max() { |
124 return g_default_version_max; | 123 return g_default_version_max; |
125 } | 124 } |
126 | 125 |
127 // static | |
128 void SSLConfigService::EnableChannelIDTrial() { | |
129 g_channel_id_trial = true; | |
130 } | |
131 | |
132 void SSLConfigService::AddObserver(Observer* observer) { | 126 void SSLConfigService::AddObserver(Observer* observer) { |
133 observer_list_.AddObserver(observer); | 127 observer_list_.AddObserver(observer); |
134 } | 128 } |
135 | 129 |
136 void SSLConfigService::RemoveObserver(Observer* observer) { | 130 void SSLConfigService::RemoveObserver(Observer* observer) { |
137 observer_list_.RemoveObserver(observer); | 131 observer_list_.RemoveObserver(observer); |
138 } | 132 } |
139 | 133 |
140 SSLConfigService::~SSLConfigService() { | 134 SSLConfigService::~SSLConfigService() { |
141 } | 135 } |
142 | 136 |
143 // static | 137 // static |
144 void SSLConfigService::SetSSLConfigFlags(SSLConfig* ssl_config) { | 138 void SSLConfigService::SetSSLConfigFlags(SSLConfig* ssl_config) { |
145 ssl_config->cached_info_enabled = g_cached_info_enabled; | 139 ssl_config->cached_info_enabled = g_cached_info_enabled; |
146 if (g_channel_id_trial) | |
147 ssl_config->channel_id_enabled = true; | |
148 } | 140 } |
149 | 141 |
150 void SSLConfigService::ProcessConfigUpdate(const SSLConfig& orig_config, | 142 void SSLConfigService::ProcessConfigUpdate(const SSLConfig& orig_config, |
151 const SSLConfig& new_config) { | 143 const SSLConfig& new_config) { |
152 bool config_changed = | 144 bool config_changed = |
153 (orig_config.rev_checking_enabled != new_config.rev_checking_enabled) || | 145 (orig_config.rev_checking_enabled != new_config.rev_checking_enabled) || |
154 (orig_config.version_min != new_config.version_min) || | 146 (orig_config.version_min != new_config.version_min) || |
155 (orig_config.version_max != new_config.version_max) || | 147 (orig_config.version_max != new_config.version_max) || |
156 (orig_config.disabled_cipher_suites != | 148 (orig_config.disabled_cipher_suites != |
157 new_config.disabled_cipher_suites) || | 149 new_config.disabled_cipher_suites) || |
158 (orig_config.channel_id_enabled != new_config.channel_id_enabled) || | 150 (orig_config.channel_id_enabled != new_config.channel_id_enabled) || |
159 (orig_config.false_start_enabled != new_config.false_start_enabled); | 151 (orig_config.false_start_enabled != new_config.false_start_enabled); |
160 | 152 |
161 if (config_changed) | 153 if (config_changed) |
162 FOR_EACH_OBSERVER(Observer, observer_list_, OnSSLConfigChanged()); | 154 FOR_EACH_OBSERVER(Observer, observer_list_, OnSSLConfigChanged()); |
163 } | 155 } |
164 | 156 |
165 // static | 157 // static |
166 bool SSLConfigService::IsSNIAvailable(SSLConfigService* service) { | 158 bool SSLConfigService::IsSNIAvailable(SSLConfigService* service) { |
167 if (!service) | 159 if (!service) |
168 return false; | 160 return false; |
169 | 161 |
170 SSLConfig ssl_config; | 162 SSLConfig ssl_config; |
171 service->GetSSLConfig(&ssl_config); | 163 service->GetSSLConfig(&ssl_config); |
172 return ssl_config.version_max >= SSL_PROTOCOL_VERSION_TLS1; | 164 return ssl_config.version_max >= SSL_PROTOCOL_VERSION_TLS1; |
173 } | 165 } |
174 | 166 |
175 } // namespace net | 167 } // namespace net |
OLD | NEW |