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

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: Restore check VPN PassphraseRequred 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 18 matching lines...) Expand all
40 const std::string& path, 41 const std::string& path,
41 const network_handler::ErrorCallback& error_callback) { 42 const network_handler::ErrorCallback& error_callback) {
42 NET_LOG_ERROR(error, path); 43 NET_LOG_ERROR(error, path);
43 if (error_callback.is_null()) 44 if (error_callback.is_null())
44 return; 45 return;
45 scoped_ptr<base::DictionaryValue> error_data( 46 scoped_ptr<base::DictionaryValue> error_data(
46 network_handler::CreateErrorData(path, error, "")); 47 network_handler::CreateErrorData(path, error, ""));
47 error_callback.Run(error, error_data.Pass()); 48 error_callback.Run(error, error_data.Pass());
48 } 49 }
49 50
51 bool IsPassphrase(const std::string& key) {
52 return key == flimflam::kEapPrivateKeyPasswordProperty ||
gauravsh 2013/08/02 23:40:22 Looking at service_constants.h, should the followi
stevenjb 2013/08/06 00:32:48 Added.
53 key == flimflam::kEapPasswordProperty ||
54 key == flimflam::kL2tpIpsecPasswordProperty ||
55 key == flimflam::kOpenVPNPasswordProperty ||
56 key == flimflam::kPassphraseProperty ||
57 key == flimflam::kOpenVPNOTPProperty;
58 }
59
50 } // namespace 60 } // namespace
51 61
52 // Helper class to request from Shill the profile entries associated with a 62 // Helper class to request from Shill the profile entries associated with a
53 // Service and delete the service from each profile. Triggers either 63 // Service and delete the service from each profile. Triggers either
54 // |callback| on success or |error_callback| on failure, and calls 64 // |callback| on success or |error_callback| on failure, and calls
55 // |handler|->ProfileEntryDeleterCompleted() on completion to delete itself. 65 // |handler|->ProfileEntryDeleterCompleted() on completion to delete itself.
56 class NetworkConfigurationHandler::ProfileEntryDeleter 66 class NetworkConfigurationHandler::ProfileEntryDeleter
57 : public base::SupportsWeakPtr<ProfileEntryDeleter> { 67 : public base::SupportsWeakPtr<ProfileEntryDeleter> {
58 public: 68 public:
59 ProfileEntryDeleter(NetworkConfigurationHandler* handler, 69 ProfileEntryDeleter(NetworkConfigurationHandler* handler,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 base::Bind(&network_handler::GetPropertiesCallback, 173 base::Bind(&network_handler::GetPropertiesCallback,
164 callback, error_callback, service_path)); 174 callback, error_callback, service_path));
165 } 175 }
166 176
167 void NetworkConfigurationHandler::SetProperties( 177 void NetworkConfigurationHandler::SetProperties(
168 const std::string& service_path, 178 const std::string& service_path,
169 const base::DictionaryValue& properties, 179 const base::DictionaryValue& properties,
170 const base::Closure& callback, 180 const base::Closure& callback,
171 const network_handler::ErrorCallback& error_callback) { 181 const network_handler::ErrorCallback& error_callback) {
172 NET_LOG_USER("SetProperties", service_path); 182 NET_LOG_USER("SetProperties", service_path);
183 for (base::DictionaryValue::Iterator iter(properties);
184 !iter.IsAtEnd(); iter.Advance()) {
185 std::string v = "******";
186 if (!IsPassphrase(iter.key()))
187 base::JSONWriter::Write(&iter.value(), &v);
188 NET_LOG_DEBUG("SetProperty", service_path + "." + iter.key() + "=" + v);
189 }
173 DBusThreadManager::Get()->GetShillServiceClient()->SetProperties( 190 DBusThreadManager::Get()->GetShillServiceClient()->SetProperties(
174 dbus::ObjectPath(service_path), 191 dbus::ObjectPath(service_path),
175 properties, 192 properties,
176 base::Bind(&NetworkConfigurationHandler::SetPropertiesSuccessCallback, 193 base::Bind(&NetworkConfigurationHandler::SetPropertiesSuccessCallback,
177 AsWeakPtr(), service_path, callback), 194 AsWeakPtr(), service_path, callback),
178 base::Bind(&NetworkConfigurationHandler::SetPropertiesErrorCallback, 195 base::Bind(&NetworkConfigurationHandler::SetPropertiesErrorCallback,
179 AsWeakPtr(), service_path, error_callback)); 196 AsWeakPtr(), service_path, error_callback));
180 } 197 }
181 198
182 void NetworkConfigurationHandler::ClearProperties( 199 void NetworkConfigurationHandler::ClearProperties(
183 const std::string& service_path, 200 const std::string& service_path,
184 const std::vector<std::string>& names, 201 const std::vector<std::string>& names,
185 const base::Closure& callback, 202 const base::Closure& callback,
186 const network_handler::ErrorCallback& error_callback) { 203 const network_handler::ErrorCallback& error_callback) {
187 NET_LOG_USER("ClearProperties", service_path); 204 NET_LOG_USER("ClearProperties", service_path);
205 for (std::vector<std::string>::const_iterator iter = names.begin();
206 iter != names.end(); ++iter) {
207 NET_LOG_DEBUG("ClearProperty", service_path + "." + *iter);
208 }
188 DBusThreadManager::Get()->GetShillServiceClient()->ClearProperties( 209 DBusThreadManager::Get()->GetShillServiceClient()->ClearProperties(
189 dbus::ObjectPath(service_path), 210 dbus::ObjectPath(service_path),
190 names, 211 names,
191 base::Bind(&NetworkConfigurationHandler::ClearPropertiesSuccessCallback, 212 base::Bind(&NetworkConfigurationHandler::ClearPropertiesSuccessCallback,
192 AsWeakPtr(), service_path, names, callback, error_callback), 213 AsWeakPtr(), service_path, names, callback, error_callback),
193 base::Bind(&NetworkConfigurationHandler::ClearPropertiesErrorCallback, 214 base::Bind(&NetworkConfigurationHandler::ClearPropertiesErrorCallback,
194 AsWeakPtr(), service_path, error_callback)); 215 AsWeakPtr(), service_path, error_callback));
195 } 216 }
196 217
197 void NetworkConfigurationHandler::CreateConfiguration( 218 void NetworkConfigurationHandler::CreateConfiguration(
198 const base::DictionaryValue& properties, 219 const base::DictionaryValue& properties,
199 const network_handler::StringResultCallback& callback, 220 const network_handler::StringResultCallback& callback,
200 const network_handler::ErrorCallback& error_callback) { 221 const network_handler::ErrorCallback& error_callback) {
201 ShillManagerClient* manager = 222 ShillManagerClient* manager =
202 DBusThreadManager::Get()->GetShillManagerClient(); 223 DBusThreadManager::Get()->GetShillManagerClient();
203
204 std::string type; 224 std::string type;
205 properties.GetStringWithoutPathExpansion(flimflam::kTypeProperty, &type); 225 properties.GetStringWithoutPathExpansion(flimflam::kTypeProperty, &type);
226
227 NET_LOG_USER("CreateConfiguration", type);
228 for (base::DictionaryValue::Iterator iter(properties);
229 !iter.IsAtEnd(); iter.Advance()) {
230 std::string v = "******";
231 if (!IsPassphrase(iter.key()))
232 base::JSONWriter::Write(&iter.value(), &v);
233 NET_LOG_DEBUG("Configure", type + "." + iter.key() + "=" + v);
234 }
235
206 // Shill supports ConfigureServiceForProfile only for network type WiFi. In 236 // Shill supports ConfigureServiceForProfile only for network type WiFi. In
207 // all other cases, we have to rely on GetService for now. This is 237 // all other cases, we have to rely on GetService for now. This is
208 // unproblematic for VPN (user profile only), but will lead to inconsistencies 238 // unproblematic for VPN (user profile only), but will lead to inconsistencies
209 // with WiMax, for example. 239 // with WiMax, for example.
210 if (type == flimflam::kTypeWifi) { 240 if (type == flimflam::kTypeWifi) {
211 std::string profile; 241 std::string profile;
212 properties.GetStringWithoutPathExpansion(flimflam::kProfileProperty, 242 properties.GetStringWithoutPathExpansion(flimflam::kProfileProperty,
213 &profile); 243 &profile);
214 manager->ConfigureServiceForProfile( 244 manager->ConfigureServiceForProfile(
215 dbus::ObjectPath(profile), 245 dbus::ObjectPath(profile),
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 387
358 // static 388 // static
359 NetworkConfigurationHandler* NetworkConfigurationHandler::InitializeForTest( 389 NetworkConfigurationHandler* NetworkConfigurationHandler::InitializeForTest(
360 NetworkStateHandler* network_state_handler) { 390 NetworkStateHandler* network_state_handler) {
361 NetworkConfigurationHandler* handler = new NetworkConfigurationHandler(); 391 NetworkConfigurationHandler* handler = new NetworkConfigurationHandler();
362 handler->Init(network_state_handler); 392 handler->Init(network_state_handler);
363 return handler; 393 return handler;
364 } 394 }
365 395
366 } // namespace chromeos 396 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698