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

Side by Side Diff: chromeos/network/network_configuration_handler.cc

Issue 21046008: Convert all connect code to use NetworkHandler instead of NetworkLibrary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Feedback Round 1 Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/network_configuration_handler.h" 5 #include "chromeos/network/network_configuration_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/format_macros.h" 11 #include "base/format_macros.h"
12 #include "base/json/json_writer.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/stl_util.h" 16 #include "base/stl_util.h"
16 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 #include "chromeos/dbus/dbus_thread_manager.h" 19 #include "chromeos/dbus/dbus_thread_manager.h"
19 #include "chromeos/dbus/shill_manager_client.h" 20 #include "chromeos/dbus/shill_manager_client.h"
20 #include "chromeos/dbus/shill_profile_client.h" 21 #include "chromeos/dbus/shill_profile_client.h"
21 #include "chromeos/dbus/shill_service_client.h" 22 #include "chromeos/dbus/shill_service_client.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 std::string name = NetworkState::GetNameFromProperties(properties); 60 std::string name = NetworkState::GetNameFromProperties(properties);
60 if (!name.empty()) { 61 if (!name.empty()) {
61 properties_copy->SetStringWithoutPathExpansion( 62 properties_copy->SetStringWithoutPathExpansion(
62 flimflam::kNameProperty, name); 63 flimflam::kNameProperty, name);
63 } 64 }
64 network_handler::GetPropertiesCallback( 65 network_handler::GetPropertiesCallback(
65 callback, error_callback, service_path, call_status, 66 callback, error_callback, service_path, call_status,
66 *properties_copy.get()); 67 *properties_copy.get());
67 } 68 }
68 69
70 bool IsPassphrase(const std::string& key) {
71 return key == flimflam::kEapPrivateKeyPasswordProperty ||
72 key == flimflam::kEapPasswordProperty ||
73 key == flimflam::kL2tpIpsecPasswordProperty ||
74 key == flimflam::kOpenVPNPasswordProperty ||
75 key == flimflam::kPassphraseProperty ||
76 key == flimflam::kOpenVPNOTPProperty ||
77 key == flimflam::kEapPrivateKeyProperty ||
78 key == flimflam::kEapPrivateKeyPasswordProperty ||
79 key == flimflam::kEapPinProperty ||
80 key == flimflam::kApnPasswordProperty;
81 }
82
69 } // namespace 83 } // namespace
70 84
71 // Helper class to request from Shill the profile entries associated with a 85 // Helper class to request from Shill the profile entries associated with a
72 // Service and delete the service from each profile. Triggers either 86 // Service and delete the service from each profile. Triggers either
73 // |callback| on success or |error_callback| on failure, and calls 87 // |callback| on success or |error_callback| on failure, and calls
74 // |handler|->ProfileEntryDeleterCompleted() on completion to delete itself. 88 // |handler|->ProfileEntryDeleterCompleted() on completion to delete itself.
75 class NetworkConfigurationHandler::ProfileEntryDeleter 89 class NetworkConfigurationHandler::ProfileEntryDeleter
76 : public base::SupportsWeakPtr<ProfileEntryDeleter> { 90 : public base::SupportsWeakPtr<ProfileEntryDeleter> {
77 public: 91 public:
78 ProfileEntryDeleter(NetworkConfigurationHandler* handler, 92 ProfileEntryDeleter(NetworkConfigurationHandler* handler,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 base::Bind(&GetPropertiesCallback, 196 base::Bind(&GetPropertiesCallback,
183 callback, error_callback, service_path)); 197 callback, error_callback, service_path));
184 } 198 }
185 199
186 void NetworkConfigurationHandler::SetProperties( 200 void NetworkConfigurationHandler::SetProperties(
187 const std::string& service_path, 201 const std::string& service_path,
188 const base::DictionaryValue& properties, 202 const base::DictionaryValue& properties,
189 const base::Closure& callback, 203 const base::Closure& callback,
190 const network_handler::ErrorCallback& error_callback) { 204 const network_handler::ErrorCallback& error_callback) {
191 NET_LOG_USER("SetProperties", service_path); 205 NET_LOG_USER("SetProperties", service_path);
206 for (base::DictionaryValue::Iterator iter(properties);
207 !iter.IsAtEnd(); iter.Advance()) {
208 std::string v = "******";
209 if (!IsPassphrase(iter.key()))
210 base::JSONWriter::Write(&iter.value(), &v);
211 NET_LOG_DEBUG("SetProperty", service_path + "." + iter.key() + "=" + v);
212 }
192 DBusThreadManager::Get()->GetShillServiceClient()->SetProperties( 213 DBusThreadManager::Get()->GetShillServiceClient()->SetProperties(
193 dbus::ObjectPath(service_path), 214 dbus::ObjectPath(service_path),
194 properties, 215 properties,
195 base::Bind(&NetworkConfigurationHandler::SetPropertiesSuccessCallback, 216 base::Bind(&NetworkConfigurationHandler::SetPropertiesSuccessCallback,
196 AsWeakPtr(), service_path, callback), 217 AsWeakPtr(), service_path, callback),
197 base::Bind(&NetworkConfigurationHandler::SetPropertiesErrorCallback, 218 base::Bind(&NetworkConfigurationHandler::SetPropertiesErrorCallback,
198 AsWeakPtr(), service_path, error_callback)); 219 AsWeakPtr(), service_path, error_callback));
199 } 220 }
200 221
201 void NetworkConfigurationHandler::ClearProperties( 222 void NetworkConfigurationHandler::ClearProperties(
202 const std::string& service_path, 223 const std::string& service_path,
203 const std::vector<std::string>& names, 224 const std::vector<std::string>& names,
204 const base::Closure& callback, 225 const base::Closure& callback,
205 const network_handler::ErrorCallback& error_callback) { 226 const network_handler::ErrorCallback& error_callback) {
206 NET_LOG_USER("ClearProperties", service_path); 227 NET_LOG_USER("ClearProperties", service_path);
228 for (std::vector<std::string>::const_iterator iter = names.begin();
229 iter != names.end(); ++iter) {
230 NET_LOG_DEBUG("ClearProperty", service_path + "." + *iter);
231 }
207 DBusThreadManager::Get()->GetShillServiceClient()->ClearProperties( 232 DBusThreadManager::Get()->GetShillServiceClient()->ClearProperties(
208 dbus::ObjectPath(service_path), 233 dbus::ObjectPath(service_path),
209 names, 234 names,
210 base::Bind(&NetworkConfigurationHandler::ClearPropertiesSuccessCallback, 235 base::Bind(&NetworkConfigurationHandler::ClearPropertiesSuccessCallback,
211 AsWeakPtr(), service_path, names, callback, error_callback), 236 AsWeakPtr(), service_path, names, callback, error_callback),
212 base::Bind(&NetworkConfigurationHandler::ClearPropertiesErrorCallback, 237 base::Bind(&NetworkConfigurationHandler::ClearPropertiesErrorCallback,
213 AsWeakPtr(), service_path, error_callback)); 238 AsWeakPtr(), service_path, error_callback));
214 } 239 }
215 240
216 void NetworkConfigurationHandler::CreateConfiguration( 241 void NetworkConfigurationHandler::CreateConfiguration(
217 const base::DictionaryValue& properties, 242 const base::DictionaryValue& properties,
218 const network_handler::StringResultCallback& callback, 243 const network_handler::StringResultCallback& callback,
219 const network_handler::ErrorCallback& error_callback) { 244 const network_handler::ErrorCallback& error_callback) {
220 ShillManagerClient* manager = 245 ShillManagerClient* manager =
221 DBusThreadManager::Get()->GetShillManagerClient(); 246 DBusThreadManager::Get()->GetShillManagerClient();
222
223 std::string type; 247 std::string type;
224 properties.GetStringWithoutPathExpansion(flimflam::kTypeProperty, &type); 248 properties.GetStringWithoutPathExpansion(flimflam::kTypeProperty, &type);
249
250 NET_LOG_USER("CreateConfiguration", type);
251 for (base::DictionaryValue::Iterator iter(properties);
252 !iter.IsAtEnd(); iter.Advance()) {
253 std::string v = "******";
254 if (!IsPassphrase(iter.key()))
255 base::JSONWriter::Write(&iter.value(), &v);
256 NET_LOG_DEBUG("Configure", type + "." + iter.key() + "=" + v);
257 }
258
225 // Shill supports ConfigureServiceForProfile only for network type WiFi. In 259 // Shill supports ConfigureServiceForProfile only for network type WiFi. In
226 // all other cases, we have to rely on GetService for now. This is 260 // all other cases, we have to rely on GetService for now. This is
227 // unproblematic for VPN (user profile only), but will lead to inconsistencies 261 // unproblematic for VPN (user profile only), but will lead to inconsistencies
228 // with WiMax, for example. 262 // with WiMax, for example.
229 if (type == flimflam::kTypeWifi) { 263 if (type == flimflam::kTypeWifi) {
230 std::string profile; 264 std::string profile;
231 properties.GetStringWithoutPathExpansion(flimflam::kProfileProperty, 265 properties.GetStringWithoutPathExpansion(flimflam::kProfileProperty,
232 &profile); 266 &profile);
233 manager->ConfigureServiceForProfile( 267 manager->ConfigureServiceForProfile(
234 dbus::ObjectPath(profile), 268 dbus::ObjectPath(profile),
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 410
377 // static 411 // static
378 NetworkConfigurationHandler* NetworkConfigurationHandler::InitializeForTest( 412 NetworkConfigurationHandler* NetworkConfigurationHandler::InitializeForTest(
379 NetworkStateHandler* network_state_handler) { 413 NetworkStateHandler* network_state_handler) {
380 NetworkConfigurationHandler* handler = new NetworkConfigurationHandler(); 414 NetworkConfigurationHandler* handler = new NetworkConfigurationHandler();
381 handler->Init(network_state_handler); 415 handler->Init(network_state_handler);
382 return handler; 416 return handler;
383 } 417 }
384 418
385 } // namespace chromeos 419 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698