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

Side by Side Diff: chrome/browser/chromeos/net/proxy_config_handler.cc

Issue 2257103002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/chromeos/net/proxy_config_handler.h" 5 #include "chrome/browser/chromeos/net/proxy_config_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 network_policy->GetDictionaryWithoutPathExpansion( 54 network_policy->GetDictionaryWithoutPathExpansion(
55 ::onc::network_config::kProxySettings, &proxy_policy); 55 ::onc::network_config::kProxySettings, &proxy_policy);
56 if (!proxy_policy) { 56 if (!proxy_policy) {
57 // This policy doesn't set a proxy for this network. Nonetheless, this 57 // This policy doesn't set a proxy for this network. Nonetheless, this
58 // disallows changes by the user. 58 // disallows changes by the user.
59 return std::unique_ptr<ProxyConfigDictionary>(); 59 return std::unique_ptr<ProxyConfigDictionary>();
60 } 60 }
61 61
62 std::unique_ptr<base::DictionaryValue> proxy_dict = 62 std::unique_ptr<base::DictionaryValue> proxy_dict =
63 onc::ConvertOncProxySettingsToProxyConfig(*proxy_policy); 63 onc::ConvertOncProxySettingsToProxyConfig(*proxy_policy);
64 return base::WrapUnique(new ProxyConfigDictionary(proxy_dict.get())); 64 return base::MakeUnique<ProxyConfigDictionary>(proxy_dict.get());
65 } 65 }
66 66
67 if (network.profile_path().empty()) 67 if (network.profile_path().empty())
68 return std::unique_ptr<ProxyConfigDictionary>(); 68 return std::unique_ptr<ProxyConfigDictionary>();
69 69
70 const NetworkProfile* profile = NetworkHandler::Get() 70 const NetworkProfile* profile = NetworkHandler::Get()
71 ->network_profile_handler()->GetProfileForPath(network.profile_path()); 71 ->network_profile_handler()->GetProfileForPath(network.profile_path());
72 if (!profile) { 72 if (!profile) {
73 VLOG(1) << "Unknown profile_path '" << network.profile_path() << "'."; 73 VLOG(1) << "Unknown profile_path '" << network.profile_path() << "'.";
74 return std::unique_ptr<ProxyConfigDictionary>(); 74 return std::unique_ptr<ProxyConfigDictionary>();
75 } 75 }
76 if (!profile_prefs && profile->type() == NetworkProfile::TYPE_USER) { 76 if (!profile_prefs && profile->type() == NetworkProfile::TYPE_USER) {
77 // This case occurs, for example, if called from the proxy config tracker 77 // This case occurs, for example, if called from the proxy config tracker
78 // created for the system request context and the signin screen. Both don't 78 // created for the system request context and the signin screen. Both don't
79 // use profile prefs and shouldn't depend on the user's not shared proxy 79 // use profile prefs and shouldn't depend on the user's not shared proxy
80 // settings. 80 // settings.
81 VLOG(1) 81 VLOG(1)
82 << "Don't use unshared settings for system context or signin screen."; 82 << "Don't use unshared settings for system context or signin screen.";
83 return std::unique_ptr<ProxyConfigDictionary>(); 83 return std::unique_ptr<ProxyConfigDictionary>();
84 } 84 }
85 85
86 // No policy set for this network, read instead the user's (shared or 86 // No policy set for this network, read instead the user's (shared or
87 // unshared) configuration. 87 // unshared) configuration.
88 // The user's proxy setting is not stored in the Chrome preference yet. We 88 // The user's proxy setting is not stored in the Chrome preference yet. We
89 // still rely on Shill storing it. 89 // still rely on Shill storing it.
90 const base::DictionaryValue& value = network.proxy_config(); 90 const base::DictionaryValue& value = network.proxy_config();
91 if (value.empty()) 91 if (value.empty())
92 return std::unique_ptr<ProxyConfigDictionary>(); 92 return std::unique_ptr<ProxyConfigDictionary>();
93 return base::WrapUnique(new ProxyConfigDictionary(&value)); 93 return base::MakeUnique<ProxyConfigDictionary>(&value);
94 } 94 }
95 95
96 void SetProxyConfigForNetwork(const ProxyConfigDictionary& proxy_config, 96 void SetProxyConfigForNetwork(const ProxyConfigDictionary& proxy_config,
97 const NetworkState& network) { 97 const NetworkState& network) {
98 chromeos::ShillServiceClient* shill_service_client = 98 chromeos::ShillServiceClient* shill_service_client =
99 DBusThreadManager::Get()->GetShillServiceClient(); 99 DBusThreadManager::Get()->GetShillServiceClient();
100 100
101 // The user's proxy setting is not stored in the Chrome preference yet. We 101 // The user's proxy setting is not stored in the Chrome preference yet. We
102 // still rely on Shill storing it. 102 // still rely on Shill storing it.
103 ProxyPrefs::ProxyMode mode; 103 ProxyPrefs::ProxyMode mode;
(...skipping 29 matching lines...) Expand all
133 133
134 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { 134 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
135 registry->RegisterBooleanPref(prefs::kUseSharedProxies, false); 135 registry->RegisterBooleanPref(prefs::kUseSharedProxies, false);
136 136
137 registry->RegisterListPref(prefs::kOpenNetworkConfiguration); 137 registry->RegisterListPref(prefs::kOpenNetworkConfiguration);
138 } 138 }
139 139
140 } // namespace proxy_config 140 } // namespace proxy_config
141 141
142 } // namespace chromeos 142 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698