| 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/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chromeos/dbus/dbus_method_call_status.h" | 15 #include "chromeos/dbus/dbus_method_call_status.h" |
| 16 #include "chromeos/dbus/dbus_thread_manager.h" | 16 #include "chromeos/dbus/dbus_thread_manager.h" |
| 17 #include "chromeos/dbus/shill_manager_client.h" | 17 #include "chromeos/dbus/shill_manager_client.h" |
| 18 #include "chromeos/dbus/shill_service_client.h" | 18 #include "chromeos/dbus/shill_service_client.h" |
| 19 #include "dbus/object_path.h" | 19 #include "dbus/object_path.h" |
| 20 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 20 | 21 |
| 21 namespace chromeos { | 22 namespace chromeos { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 const char kLogModule[] = "NetworkConfigurationHandler"; | 26 const char kLogModule[] = "NetworkConfigurationHandler"; |
| 26 | 27 |
| 27 NetworkConfigurationHandler* g_configuration_handler_instance = NULL; | 28 NetworkConfigurationHandler* g_configuration_handler_instance = NULL; |
| 28 | 29 |
| 29 // None of these error messages are user-facing: they should only appear in | 30 // None of these error messages are user-facing: they should only appear in |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 dbus::ObjectPath(service_path), | 187 dbus::ObjectPath(service_path), |
| 187 callback, | 188 callback, |
| 188 base::Bind(&network_handler::ShillErrorCallbackFunction, | 189 base::Bind(&network_handler::ShillErrorCallbackFunction, |
| 189 kLogModule, service_path, error_callback)); | 190 kLogModule, service_path, error_callback)); |
| 190 } | 191 } |
| 191 | 192 |
| 192 void NetworkConfigurationHandler::CreateConfiguration( | 193 void NetworkConfigurationHandler::CreateConfiguration( |
| 193 const base::DictionaryValue& properties, | 194 const base::DictionaryValue& properties, |
| 194 const network_handler::StringResultCallback& callback, | 195 const network_handler::StringResultCallback& callback, |
| 195 const network_handler::ErrorCallback& error_callback) const { | 196 const network_handler::ErrorCallback& error_callback) const { |
| 196 DBusThreadManager::Get()->GetShillManagerClient()->GetService( | 197 ShillManagerClient* manager = |
| 197 properties, | 198 DBusThreadManager::Get()->GetShillManagerClient(); |
| 198 base::Bind(&RunCreateNetworkCallback, callback), | 199 |
| 199 base::Bind(&network_handler::ShillErrorCallbackFunction, | 200 std::string type; |
| 200 kLogModule, "", error_callback)); | 201 properties.GetStringWithoutPathExpansion(flimflam::kTypeProperty, &type); |
| 202 if (type == flimflam::kTypeWifi) { |
| 203 std::string profile; |
| 204 properties.GetStringWithoutPathExpansion(flimflam::kProfileProperty, |
| 205 &profile); |
| 206 manager->ConfigureServiceForProfile( |
| 207 dbus::ObjectPath(profile), |
| 208 properties, |
| 209 base::Bind(&RunCreateNetworkCallback, callback), |
| 210 base::Bind(&network_handler::ShillErrorCallbackFunction, |
| 211 kLogModule, "", error_callback)); |
| 212 } else { |
| 213 manager->GetService( |
| 214 properties, |
| 215 base::Bind(&RunCreateNetworkCallback, callback), |
| 216 base::Bind(&network_handler::ShillErrorCallbackFunction, |
| 217 kLogModule, "", error_callback)); |
| 218 } |
| 201 } | 219 } |
| 202 | 220 |
| 203 void NetworkConfigurationHandler::RemoveConfiguration( | 221 void NetworkConfigurationHandler::RemoveConfiguration( |
| 204 const std::string& service_path, | 222 const std::string& service_path, |
| 205 const base::Closure& callback, | 223 const base::Closure& callback, |
| 206 const network_handler::ErrorCallback& error_callback) const { | 224 const network_handler::ErrorCallback& error_callback) const { |
| 207 DBusThreadManager::Get()->GetShillServiceClient()->Remove( | 225 DBusThreadManager::Get()->GetShillServiceClient()->Remove( |
| 208 dbus::ObjectPath(service_path), | 226 dbus::ObjectPath(service_path), |
| 209 callback, | 227 callback, |
| 210 base::Bind(&network_handler::ShillErrorCallbackFunction, | 228 base::Bind(&network_handler::ShillErrorCallbackFunction, |
| 211 kLogModule, service_path, error_callback)); | 229 kLogModule, service_path, error_callback)); |
| 212 } | 230 } |
| 213 | 231 |
| 214 NetworkConfigurationHandler::NetworkConfigurationHandler() { | 232 NetworkConfigurationHandler::NetworkConfigurationHandler() { |
| 215 } | 233 } |
| 216 | 234 |
| 217 NetworkConfigurationHandler::~NetworkConfigurationHandler() { | 235 NetworkConfigurationHandler::~NetworkConfigurationHandler() { |
| 218 } | 236 } |
| 219 | 237 |
| 220 } // namespace chromeos | 238 } // namespace chromeos |
| OLD | NEW |