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

Side by Side Diff: chromeos/network/proxy/proxy_config_handler.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) 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 "chromeos/network/proxy/proxy_config_handler.h" 5 #include "chromeos/network/proxy/proxy_config_handler.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
9 #include "base/logging.h" 11 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
11 #include "base/values.h" 13 #include "base/values.h"
12 #include "chromeos/dbus/dbus_thread_manager.h" 14 #include "chromeos/dbus/dbus_thread_manager.h"
13 #include "chromeos/dbus/shill_service_client.h" 15 #include "chromeos/dbus/shill_service_client.h"
14 #include "chromeos/network/network_handler_callbacks.h" 16 #include "chromeos/network/network_handler_callbacks.h"
15 #include "chromeos/network/network_profile.h" 17 #include "chromeos/network/network_profile.h"
16 #include "chromeos/network/network_profile_handler.h" 18 #include "chromeos/network/network_profile_handler.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 network_policy->GetDictionaryWithoutPathExpansion( 55 network_policy->GetDictionaryWithoutPathExpansion(
54 ::onc::network_config::kProxySettings, &proxy_policy); 56 ::onc::network_config::kProxySettings, &proxy_policy);
55 if (!proxy_policy) { 57 if (!proxy_policy) {
56 // This policy doesn't set a proxy for this network. Nonetheless, this 58 // This policy doesn't set a proxy for this network. Nonetheless, this
57 // disallows changes by the user. 59 // disallows changes by the user.
58 return std::unique_ptr<ProxyConfigDictionary>(); 60 return std::unique_ptr<ProxyConfigDictionary>();
59 } 61 }
60 62
61 std::unique_ptr<base::DictionaryValue> proxy_dict = 63 std::unique_ptr<base::DictionaryValue> proxy_dict =
62 onc::ConvertOncProxySettingsToProxyConfig(*proxy_policy); 64 onc::ConvertOncProxySettingsToProxyConfig(*proxy_policy);
63 return base::MakeUnique<ProxyConfigDictionary>(proxy_dict.get()); 65 return base::MakeUnique<ProxyConfigDictionary>(std::move(proxy_dict));
64 } 66 }
65 67
66 if (network.profile_path().empty()) 68 if (network.profile_path().empty())
67 return std::unique_ptr<ProxyConfigDictionary>(); 69 return std::unique_ptr<ProxyConfigDictionary>();
68 70
69 const NetworkProfile* profile = 71 const NetworkProfile* profile =
70 NetworkHandler::Get()->network_profile_handler()->GetProfileForPath( 72 NetworkHandler::Get()->network_profile_handler()->GetProfileForPath(
71 network.profile_path()); 73 network.profile_path());
72 if (!profile) { 74 if (!profile) {
73 VLOG(1) << "Unknown profile_path '" << network.profile_path() << "'."; 75 VLOG(1) << "Unknown profile_path '" << network.profile_path() << "'.";
74 return std::unique_ptr<ProxyConfigDictionary>(); 76 return std::unique_ptr<ProxyConfigDictionary>();
75 } 77 }
76 if (!profile_prefs && profile->type() == NetworkProfile::TYPE_USER) { 78 if (!profile_prefs && profile->type() == NetworkProfile::TYPE_USER) {
77 // This case occurs, for example, if called from the proxy config tracker 79 // 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 80 // 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 81 // use profile prefs and shouldn't depend on the user's not shared proxy
80 // settings. 82 // settings.
81 VLOG(1) 83 VLOG(1)
82 << "Don't use unshared settings for system context or signin screen."; 84 << "Don't use unshared settings for system context or signin screen.";
83 return std::unique_ptr<ProxyConfigDictionary>(); 85 return std::unique_ptr<ProxyConfigDictionary>();
84 } 86 }
85 87
86 // No policy set for this network, read instead the user's (shared or 88 // No policy set for this network, read instead the user's (shared or
87 // unshared) configuration. 89 // unshared) configuration.
88 // The user's proxy setting is not stored in the Chrome preference yet. We 90 // The user's proxy setting is not stored in the Chrome preference yet. We
89 // still rely on Shill storing it. 91 // still rely on Shill storing it.
90 const base::DictionaryValue& value = network.proxy_config(); 92 const base::DictionaryValue& value = network.proxy_config();
91 if (value.empty()) 93 if (value.empty())
92 return std::unique_ptr<ProxyConfigDictionary>(); 94 return std::unique_ptr<ProxyConfigDictionary>();
93 return base::MakeUnique<ProxyConfigDictionary>(&value); 95 return base::MakeUnique<ProxyConfigDictionary>(value.CreateDeepCopy());
94 } 96 }
95 97
96 void SetProxyConfigForNetwork(const ProxyConfigDictionary& proxy_config, 98 void SetProxyConfigForNetwork(const ProxyConfigDictionary& proxy_config,
97 const NetworkState& network) { 99 const NetworkState& network) {
98 chromeos::ShillServiceClient* shill_service_client = 100 chromeos::ShillServiceClient* shill_service_client =
99 DBusThreadManager::Get()->GetShillServiceClient(); 101 DBusThreadManager::Get()->GetShillServiceClient();
100 102
101 // The user's proxy setting is not stored in the Chrome preference yet. We 103 // The user's proxy setting is not stored in the Chrome preference yet. We
102 // still rely on Shill storing it. 104 // still rely on Shill storing it.
103 ProxyPrefs::ProxyMode mode; 105 ProxyPrefs::ProxyMode mode;
(...skipping 15 matching lines...) Expand all
119 base::Bind(&NotifyNetworkStateHandler, network.path()), 121 base::Bind(&NotifyNetworkStateHandler, network.path()),
120 base::Bind(&network_handler::ShillErrorCallbackFunction, 122 base::Bind(&network_handler::ShillErrorCallbackFunction,
121 "SetProxyConfig.SetProperty Failed", network.path(), 123 "SetProxyConfig.SetProperty Failed", network.path(),
122 network_handler::ErrorCallback())); 124 network_handler::ErrorCallback()));
123 } 125 }
124 } 126 }
125 127
126 } // namespace proxy_config 128 } // namespace proxy_config
127 129
128 } // namespace chromeos 130 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698