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 "chrome/browser/net/pref_proxy_config_tracker_impl.h" | 5 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/prefs/pref_registry_simple.h" | 8 #include "base/prefs/pref_registry_simple.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 return net::ProxyConfigService::CONFIG_VALID; | 195 return net::ProxyConfigService::CONFIG_VALID; |
196 } | 196 } |
197 | 197 |
198 *effective_config_state = ProxyPrefs::CONFIG_SYSTEM; | 198 *effective_config_state = ProxyPrefs::CONFIG_SYSTEM; |
199 *effective_config = system_config; | 199 *effective_config = system_config; |
200 return system_availability; | 200 return system_availability; |
201 } | 201 } |
202 | 202 |
203 // static | 203 // static |
204 void PrefProxyConfigTrackerImpl::RegisterPrefs(PrefRegistrySimple* registry) { | 204 void PrefProxyConfigTrackerImpl::RegisterPrefs(PrefRegistrySimple* registry) { |
205 DictionaryValue* default_settings = ProxyConfigDictionary::CreateSystem(); | 205 base::DictionaryValue* default_settings = |
| 206 ProxyConfigDictionary::CreateSystem(); |
206 registry->RegisterDictionaryPref(prefs::kProxy, default_settings); | 207 registry->RegisterDictionaryPref(prefs::kProxy, default_settings); |
207 } | 208 } |
208 | 209 |
209 // static | 210 // static |
210 void PrefProxyConfigTrackerImpl::RegisterProfilePrefs( | 211 void PrefProxyConfigTrackerImpl::RegisterProfilePrefs( |
211 user_prefs::PrefRegistrySyncable* pref_service) { | 212 user_prefs::PrefRegistrySyncable* pref_service) { |
212 DictionaryValue* default_settings = ProxyConfigDictionary::CreateSystem(); | 213 base::DictionaryValue* default_settings = |
| 214 ProxyConfigDictionary::CreateSystem(); |
213 pref_service->RegisterDictionaryPref( | 215 pref_service->RegisterDictionaryPref( |
214 prefs::kProxy, | 216 prefs::kProxy, |
215 default_settings, | 217 default_settings, |
216 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 218 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
217 } | 219 } |
218 | 220 |
219 // static | 221 // static |
220 ProxyPrefs::ConfigState PrefProxyConfigTrackerImpl::ReadPrefConfig( | 222 ProxyPrefs::ConfigState PrefProxyConfigTrackerImpl::ReadPrefConfig( |
221 const PrefService* pref_service, | 223 const PrefService* pref_service, |
222 net::ProxyConfig* config) { | 224 net::ProxyConfig* config) { |
223 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
224 | 226 |
225 // Clear the configuration and source. | 227 // Clear the configuration and source. |
226 *config = net::ProxyConfig(); | 228 *config = net::ProxyConfig(); |
227 ProxyPrefs::ConfigState config_state = ProxyPrefs::CONFIG_UNSET; | 229 ProxyPrefs::ConfigState config_state = ProxyPrefs::CONFIG_UNSET; |
228 | 230 |
229 const PrefService::Preference* pref = | 231 const PrefService::Preference* pref = |
230 pref_service->FindPreference(prefs::kProxy); | 232 pref_service->FindPreference(prefs::kProxy); |
231 DCHECK(pref); | 233 DCHECK(pref); |
232 | 234 |
233 const DictionaryValue* dict = pref_service->GetDictionary(prefs::kProxy); | 235 const base::DictionaryValue* dict = |
| 236 pref_service->GetDictionary(prefs::kProxy); |
234 DCHECK(dict); | 237 DCHECK(dict); |
235 ProxyConfigDictionary proxy_dict(dict); | 238 ProxyConfigDictionary proxy_dict(dict); |
236 | 239 |
237 if (PrefConfigToNetConfig(proxy_dict, config)) { | 240 if (PrefConfigToNetConfig(proxy_dict, config)) { |
238 if (!pref->IsUserModifiable() || pref->HasUserSetting()) { | 241 if (!pref->IsUserModifiable() || pref->HasUserSetting()) { |
239 if (pref->IsManaged()) | 242 if (pref->IsManaged()) |
240 config_state = ProxyPrefs::CONFIG_POLICY; | 243 config_state = ProxyPrefs::CONFIG_POLICY; |
241 else if (pref->IsExtensionControlled()) | 244 else if (pref->IsExtensionControlled()) |
242 config_state = ProxyPrefs::CONFIG_EXTENSION; | 245 config_state = ProxyPrefs::CONFIG_EXTENSION; |
243 else | 246 else |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 (config_state_ != ProxyPrefs::CONFIG_UNSET && | 348 (config_state_ != ProxyPrefs::CONFIG_UNSET && |
346 !pref_config_.Equals(new_config))) { | 349 !pref_config_.Equals(new_config))) { |
347 config_state_ = config_state; | 350 config_state_ = config_state; |
348 if (config_state_ != ProxyPrefs::CONFIG_UNSET) | 351 if (config_state_ != ProxyPrefs::CONFIG_UNSET) |
349 pref_config_ = new_config; | 352 pref_config_ = new_config; |
350 update_pending_ = true; | 353 update_pending_ = true; |
351 } | 354 } |
352 if (update_pending_) | 355 if (update_pending_) |
353 OnProxyConfigChanged(config_state, new_config); | 356 OnProxyConfigChanged(config_state, new_config); |
354 } | 357 } |
OLD | NEW |