Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: components/proxy_config/pref_proxy_config_tracker_impl.cc

Issue 2785883003: Use unique_ptr<DictionaryValue> in ProxyConfigDictionary (Closed)
Patch Set: Fix compilation Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/proxy_config/pref_proxy_config_tracker_impl.h" 5 #include "components/proxy_config/pref_proxy_config_tracker_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory>
9 #include <utility> 10 #include <utility>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/location.h" 13 #include "base/location.h"
13 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "components/pref_registry/pref_registry_syncable.h" 16 #include "components/pref_registry/pref_registry_syncable.h"
16 #include "components/prefs/pref_registry_simple.h" 17 #include "components/prefs/pref_registry_simple.h"
17 #include "components/prefs/pref_service.h" 18 #include "components/prefs/pref_service.h"
18 #include "components/proxy_config/proxy_config_dictionary.h" 19 #include "components/proxy_config/proxy_config_dictionary.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 return net::ProxyConfigService::CONFIG_VALID; 201 return net::ProxyConfigService::CONFIG_VALID;
201 } 202 }
202 203
203 *effective_config_state = ProxyPrefs::CONFIG_SYSTEM; 204 *effective_config_state = ProxyPrefs::CONFIG_SYSTEM;
204 *effective_config = system_config; 205 *effective_config = system_config;
205 return system_availability; 206 return system_availability;
206 } 207 }
207 208
208 // static 209 // static
209 void PrefProxyConfigTrackerImpl::RegisterPrefs(PrefRegistrySimple* registry) { 210 void PrefProxyConfigTrackerImpl::RegisterPrefs(PrefRegistrySimple* registry) {
210 std::unique_ptr<base::DictionaryValue> default_settings( 211 std::unique_ptr<base::DictionaryValue> default_settings =
211 ProxyConfigDictionary::CreateSystem()); 212 ProxyConfigDictionary::CreateSystem();
212 registry->RegisterDictionaryPref(proxy_config::prefs::kProxy, 213 registry->RegisterDictionaryPref(proxy_config::prefs::kProxy,
213 std::move(default_settings)); 214 std::move(default_settings));
214 } 215 }
215 216
216 // static 217 // static
217 void PrefProxyConfigTrackerImpl::RegisterProfilePrefs( 218 void PrefProxyConfigTrackerImpl::RegisterProfilePrefs(
218 user_prefs::PrefRegistrySyncable* pref_service) { 219 user_prefs::PrefRegistrySyncable* pref_service) {
219 std::unique_ptr<base::DictionaryValue> default_settings( 220 std::unique_ptr<base::DictionaryValue> default_settings =
220 ProxyConfigDictionary::CreateSystem()); 221 ProxyConfigDictionary::CreateSystem();
221 pref_service->RegisterDictionaryPref(proxy_config::prefs::kProxy, 222 pref_service->RegisterDictionaryPref(proxy_config::prefs::kProxy,
222 std::move(default_settings)); 223 std::move(default_settings));
223 pref_service->RegisterBooleanPref(proxy_config::prefs::kUseSharedProxies, 224 pref_service->RegisterBooleanPref(proxy_config::prefs::kUseSharedProxies,
224 false); 225 false);
225 } 226 }
226 227
227 // static 228 // static
228 ProxyPrefs::ConfigState PrefProxyConfigTrackerImpl::ReadPrefConfig( 229 ProxyPrefs::ConfigState PrefProxyConfigTrackerImpl::ReadPrefConfig(
229 const PrefService* pref_service, 230 const PrefService* pref_service,
230 net::ProxyConfig* config) { 231 net::ProxyConfig* config) {
231 // Clear the configuration and source. 232 // Clear the configuration and source.
232 *config = net::ProxyConfig(); 233 *config = net::ProxyConfig();
233 ProxyPrefs::ConfigState config_state = ProxyPrefs::CONFIG_UNSET; 234 ProxyPrefs::ConfigState config_state = ProxyPrefs::CONFIG_UNSET;
234 235
235 const PrefService::Preference* pref = 236 const PrefService::Preference* pref =
236 pref_service->FindPreference(proxy_config::prefs::kProxy); 237 pref_service->FindPreference(proxy_config::prefs::kProxy);
237 DCHECK(pref); 238 DCHECK(pref);
238 239
239 const base::DictionaryValue* dict = 240 const base::DictionaryValue* dict =
240 pref_service->GetDictionary(proxy_config::prefs::kProxy); 241 pref_service->GetDictionary(proxy_config::prefs::kProxy);
241 DCHECK(dict); 242 DCHECK(dict);
242 ProxyConfigDictionary proxy_dict(dict); 243 ProxyConfigDictionary proxy_dict(dict->CreateDeepCopy());
243 244
244 if (PrefConfigToNetConfig(proxy_dict, config)) { 245 if (PrefConfigToNetConfig(proxy_dict, config)) {
245 if (!pref->IsUserModifiable() || pref->HasUserSetting()) { 246 if (!pref->IsUserModifiable() || pref->HasUserSetting()) {
246 if (pref->IsManaged()) 247 if (pref->IsManaged())
247 config_state = ProxyPrefs::CONFIG_POLICY; 248 config_state = ProxyPrefs::CONFIG_POLICY;
248 else if (pref->IsExtensionControlled()) 249 else if (pref->IsExtensionControlled())
249 config_state = ProxyPrefs::CONFIG_EXTENSION; 250 config_state = ProxyPrefs::CONFIG_EXTENSION;
250 else 251 else
251 config_state = ProxyPrefs::CONFIG_OTHER_PRECEDE; 252 config_state = ProxyPrefs::CONFIG_OTHER_PRECEDE;
252 } else { 253 } else {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 (config_state_ != ProxyPrefs::CONFIG_UNSET && 352 (config_state_ != ProxyPrefs::CONFIG_UNSET &&
352 !pref_config_.Equals(new_config))) { 353 !pref_config_.Equals(new_config))) {
353 config_state_ = config_state; 354 config_state_ = config_state;
354 if (config_state_ != ProxyPrefs::CONFIG_UNSET) 355 if (config_state_ != ProxyPrefs::CONFIG_UNSET)
355 pref_config_ = new_config; 356 pref_config_ = new_config;
356 update_pending_ = true; 357 update_pending_ = true;
357 } 358 }
358 if (update_pending_) 359 if (update_pending_)
359 OnProxyConfigChanged(config_state, new_config); 360 OnProxyConfigChanged(config_state, new_config);
360 } 361 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698