OLD | NEW |
---|---|
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/json/json_writer.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "chromeos/dbus/dbus_thread_manager.h" | 19 #include "chromeos/dbus/dbus_thread_manager.h" |
20 #include "chromeos/dbus/shill_manager_client.h" | 20 #include "chromeos/dbus/shill_manager_client.h" |
21 #include "chromeos/dbus/shill_profile_client.h" | 21 #include "chromeos/dbus/shill_profile_client.h" |
22 #include "chromeos/dbus/shill_service_client.h" | 22 #include "chromeos/dbus/shill_service_client.h" |
23 #include "chromeos/network/network_event_log.h" | 23 #include "chromeos/network/network_event_log.h" |
24 #include "chromeos/network/network_state.h" | |
24 #include "chromeos/network/network_state_handler.h" | 25 #include "chromeos/network/network_state_handler.h" |
25 #include "chromeos/network/shill_property_util.h" | 26 #include "chromeos/network/shill_property_util.h" |
26 #include "dbus/object_path.h" | 27 #include "dbus/object_path.h" |
27 #include "third_party/cros_system_api/dbus/service_constants.h" | 28 #include "third_party/cros_system_api/dbus/service_constants.h" |
28 | 29 |
29 namespace chromeos { | 30 namespace chromeos { |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
33 // Strip surrounding "" from keys (if present). | 34 // Strip surrounding "" from keys (if present). |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 "", | 297 "", |
297 error_callback)); | 298 error_callback)); |
298 } | 299 } |
299 | 300 |
300 void NetworkConfigurationHandler::RemoveConfiguration( | 301 void NetworkConfigurationHandler::RemoveConfiguration( |
301 const std::string& service_path, | 302 const std::string& service_path, |
302 const base::Closure& callback, | 303 const base::Closure& callback, |
303 const network_handler::ErrorCallback& error_callback) { | 304 const network_handler::ErrorCallback& error_callback) { |
304 // Service.Remove is not reliable. Instead, request the profile entries | 305 // Service.Remove is not reliable. Instead, request the profile entries |
305 // for the service and remove each entry. | 306 // for the service and remove each entry. |
306 if (ContainsKey(profile_entry_deleters_,service_path)) { | 307 if (ContainsKey(profile_entry_deleters_, service_path)) { |
307 InvokeErrorCallback( | 308 InvokeErrorCallback( |
308 service_path, error_callback, "RemoveConfigurationInProgress"); | 309 service_path, error_callback, "RemoveConfigurationInProgress"); |
309 return; | 310 return; |
310 } | 311 } |
312 const NetworkState* network = network_state_handler_->GetNetworkState( | |
313 service_path); | |
314 std::string type = network ? network->type() : ""; | |
315 if (type.empty() || (type != shill::kTypeWifi && type != shill::kTypeWimax && | |
316 type != shill::kTypeVPN)) { | |
317 InvokeErrorCallback( | |
pneubeck (no reviews)
2014/07/07 09:14:26
Why is that restriction necessary?
I guess this i
stevenjb
2014/07/07 23:40:21
This is intended to enforce Shill behavior, i.e. d
pneubeck (no reviews)
2014/07/08 07:55:27
AFAIK, it's not an error to remove the ProfileEntr
stevenjb
2014/07/08 17:13:04
This restriction is inherited from early days of F
| |
318 service_path, error_callback, "UnsupportedRemoveType"); | |
319 } | |
320 | |
311 NET_LOG_USER("Remove Configuration", service_path); | 321 NET_LOG_USER("Remove Configuration", service_path); |
312 ProfileEntryDeleter* deleter = | 322 ProfileEntryDeleter* deleter = |
313 new ProfileEntryDeleter(this, service_path, callback, error_callback); | 323 new ProfileEntryDeleter(this, service_path, callback, error_callback); |
314 profile_entry_deleters_[service_path] = deleter; | 324 profile_entry_deleters_[service_path] = deleter; |
315 deleter->Run(); | 325 deleter->Run(); |
316 } | 326 } |
317 | 327 |
318 void NetworkConfigurationHandler::SetNetworkProfile( | 328 void NetworkConfigurationHandler::SetNetworkProfile( |
319 const std::string& service_path, | 329 const std::string& service_path, |
320 const std::string& profile_path, | 330 const std::string& profile_path, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 | 438 |
429 // static | 439 // static |
430 NetworkConfigurationHandler* NetworkConfigurationHandler::InitializeForTest( | 440 NetworkConfigurationHandler* NetworkConfigurationHandler::InitializeForTest( |
431 NetworkStateHandler* network_state_handler) { | 441 NetworkStateHandler* network_state_handler) { |
432 NetworkConfigurationHandler* handler = new NetworkConfigurationHandler(); | 442 NetworkConfigurationHandler* handler = new NetworkConfigurationHandler(); |
433 handler->Init(network_state_handler); | 443 handler->Init(network_state_handler); |
434 return handler; | 444 return handler; |
435 } | 445 } |
436 | 446 |
437 } // namespace chromeos | 447 } // namespace chromeos |
OLD | NEW |