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

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

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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) 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/values.h" 11 #include "base/values.h"
11 #include "chrome/browser/chromeos/net/onc_utils.h" 12 #include "chrome/browser/chromeos/net/onc_utils.h"
12 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
13 #include "chromeos/dbus/dbus_thread_manager.h" 14 #include "chromeos/dbus/dbus_thread_manager.h"
14 #include "chromeos/dbus/shill_service_client.h" 15 #include "chromeos/dbus/shill_service_client.h"
15 #include "chromeos/network/network_handler_callbacks.h" 16 #include "chromeos/network/network_handler_callbacks.h"
16 #include "chromeos/network/network_profile.h" 17 #include "chromeos/network/network_profile.h"
17 #include "chromeos/network/network_profile_handler.h" 18 #include "chromeos/network/network_profile_handler.h"
18 #include "chromeos/network/network_state.h" 19 #include "chromeos/network/network_state.h"
19 #include "chromeos/network/network_state_handler.h" 20 #include "chromeos/network/network_state_handler.h"
(...skipping 12 matching lines...) Expand all
32 if (NetworkHandler::IsInitialized()) { 33 if (NetworkHandler::IsInitialized()) {
33 NetworkHandler::Get()->network_state_handler()->RequestUpdateForNetwork( 34 NetworkHandler::Get()->network_state_handler()->RequestUpdateForNetwork(
34 service_path); 35 service_path);
35 } 36 }
36 } 37 }
37 38
38 } // namespace 39 } // namespace
39 40
40 namespace proxy_config { 41 namespace proxy_config {
41 42
42 scoped_ptr<ProxyConfigDictionary> GetProxyConfigForNetwork( 43 std::unique_ptr<ProxyConfigDictionary> GetProxyConfigForNetwork(
43 const PrefService* profile_prefs, 44 const PrefService* profile_prefs,
44 const PrefService* local_state_prefs, 45 const PrefService* local_state_prefs,
45 const NetworkState& network, 46 const NetworkState& network,
46 ::onc::ONCSource* onc_source) { 47 ::onc::ONCSource* onc_source) {
47 const base::DictionaryValue* network_policy = 48 const base::DictionaryValue* network_policy =
48 onc::GetPolicyForNetwork( 49 onc::GetPolicyForNetwork(
49 profile_prefs, local_state_prefs, network, onc_source); 50 profile_prefs, local_state_prefs, network, onc_source);
50 51
51 if (network_policy) { 52 if (network_policy) {
52 const base::DictionaryValue* proxy_policy = NULL; 53 const base::DictionaryValue* proxy_policy = NULL;
53 network_policy->GetDictionaryWithoutPathExpansion( 54 network_policy->GetDictionaryWithoutPathExpansion(
54 ::onc::network_config::kProxySettings, &proxy_policy); 55 ::onc::network_config::kProxySettings, &proxy_policy);
55 if (!proxy_policy) { 56 if (!proxy_policy) {
56 // 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
57 // disallows changes by the user. 58 // disallows changes by the user.
58 return scoped_ptr<ProxyConfigDictionary>(); 59 return std::unique_ptr<ProxyConfigDictionary>();
59 } 60 }
60 61
61 scoped_ptr<base::DictionaryValue> proxy_dict = 62 std::unique_ptr<base::DictionaryValue> proxy_dict =
62 onc::ConvertOncProxySettingsToProxyConfig(*proxy_policy); 63 onc::ConvertOncProxySettingsToProxyConfig(*proxy_policy);
63 return make_scoped_ptr(new ProxyConfigDictionary(proxy_dict.get())); 64 return base::WrapUnique(new ProxyConfigDictionary(proxy_dict.get()));
64 } 65 }
65 66
66 if (network.profile_path().empty()) 67 if (network.profile_path().empty())
67 return scoped_ptr<ProxyConfigDictionary>(); 68 return std::unique_ptr<ProxyConfigDictionary>();
68 69
69 const NetworkProfile* profile = NetworkHandler::Get() 70 const NetworkProfile* profile = NetworkHandler::Get()
70 ->network_profile_handler()->GetProfileForPath(network.profile_path()); 71 ->network_profile_handler()->GetProfileForPath(network.profile_path());
71 if (!profile) { 72 if (!profile) {
72 VLOG(1) << "Unknown profile_path '" << network.profile_path() << "'."; 73 VLOG(1) << "Unknown profile_path '" << network.profile_path() << "'.";
73 return scoped_ptr<ProxyConfigDictionary>(); 74 return std::unique_ptr<ProxyConfigDictionary>();
74 } 75 }
75 if (!profile_prefs && profile->type() == NetworkProfile::TYPE_USER) { 76 if (!profile_prefs && profile->type() == NetworkProfile::TYPE_USER) {
76 // 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
77 // 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
78 // 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
79 // settings. 80 // settings.
80 VLOG(1) 81 VLOG(1)
81 << "Don't use unshared settings for system context or signin screen."; 82 << "Don't use unshared settings for system context or signin screen.";
82 return scoped_ptr<ProxyConfigDictionary>(); 83 return std::unique_ptr<ProxyConfigDictionary>();
83 } 84 }
84 85
85 // 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
86 // unshared) configuration. 87 // unshared) configuration.
87 // 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
88 // still rely on Shill storing it. 89 // still rely on Shill storing it.
89 const base::DictionaryValue& value = network.proxy_config(); 90 const base::DictionaryValue& value = network.proxy_config();
90 if (value.empty()) 91 if (value.empty())
91 return scoped_ptr<ProxyConfigDictionary>(); 92 return std::unique_ptr<ProxyConfigDictionary>();
92 return make_scoped_ptr(new ProxyConfigDictionary(&value)); 93 return base::WrapUnique(new ProxyConfigDictionary(&value));
93 } 94 }
94 95
95 void SetProxyConfigForNetwork(const ProxyConfigDictionary& proxy_config, 96 void SetProxyConfigForNetwork(const ProxyConfigDictionary& proxy_config,
96 const NetworkState& network) { 97 const NetworkState& network) {
97 chromeos::ShillServiceClient* shill_service_client = 98 chromeos::ShillServiceClient* shill_service_client =
98 DBusThreadManager::Get()->GetShillServiceClient(); 99 DBusThreadManager::Get()->GetShillServiceClient();
99 100
100 // 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
101 // still rely on Shill storing it. 102 // still rely on Shill storing it.
102 ProxyPrefs::ProxyMode mode; 103 ProxyPrefs::ProxyMode mode;
(...skipping 29 matching lines...) Expand all
132 133
133 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { 134 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
134 registry->RegisterBooleanPref(prefs::kUseSharedProxies, false); 135 registry->RegisterBooleanPref(prefs::kUseSharedProxies, false);
135 136
136 registry->RegisterListPref(prefs::kOpenNetworkConfiguration); 137 registry->RegisterListPref(prefs::kOpenNetworkConfiguration);
137 } 138 }
138 139
139 } // namespace proxy_config 140 } // namespace proxy_config
140 141
141 } // namespace chromeos 142 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/net/proxy_config_handler.h ('k') | chrome/browser/chromeos/net/wake_on_wifi_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698