| 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 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 21 | 21 |
| 22 namespace chromeos { | 22 namespace chromeos { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 const char kLogModule[] = "NetworkConfigurationHandler"; | |
| 27 | |
| 28 NetworkConfigurationHandler* g_configuration_handler_instance = NULL; | 26 NetworkConfigurationHandler* g_configuration_handler_instance = NULL; |
| 29 | 27 |
| 30 // None of these error messages are user-facing: they should only appear in | 28 // None of these error messages are user-facing: they should only appear in |
| 31 // logs. | 29 // logs. |
| 32 const char kErrorsListTag[] = "errors"; | 30 const char kErrorsListTag[] = "errors"; |
| 33 const char kClearPropertiesFailedError[] = "Error.ClearPropertiesFailed"; | 31 const char kClearPropertiesFailedError[] = "Error.ClearPropertiesFailed"; |
| 34 const char kClearPropertiesFailedErrorMessage[] = "Clear properties failed"; | 32 const char kClearPropertiesFailedErrorMessage[] = "Clear properties failed"; |
| 35 const char kDBusFailedError[] = "Error.DBusFailed"; | 33 const char kDBusFailedError[] = "Error.DBusFailed"; |
| 36 const char kDBusFailedErrorMessage[] = "DBus call failed."; | 34 const char kDBusFailedErrorMessage[] = "DBus call failed."; |
| 37 | 35 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 139 |
| 142 void NetworkConfigurationHandler::SetProperties( | 140 void NetworkConfigurationHandler::SetProperties( |
| 143 const std::string& service_path, | 141 const std::string& service_path, |
| 144 const base::DictionaryValue& properties, | 142 const base::DictionaryValue& properties, |
| 145 const base::Closure& callback, | 143 const base::Closure& callback, |
| 146 const network_handler::ErrorCallback& error_callback) const { | 144 const network_handler::ErrorCallback& error_callback) const { |
| 147 DBusThreadManager::Get()->GetShillManagerClient()->ConfigureService( | 145 DBusThreadManager::Get()->GetShillManagerClient()->ConfigureService( |
| 148 properties, | 146 properties, |
| 149 base::Bind(&IgnoreObjectPathCallback, callback), | 147 base::Bind(&IgnoreObjectPathCallback, callback), |
| 150 base::Bind(&network_handler::ShillErrorCallbackFunction, | 148 base::Bind(&network_handler::ShillErrorCallbackFunction, |
| 151 kLogModule, service_path, error_callback)); | 149 service_path, error_callback)); |
| 152 } | 150 } |
| 153 | 151 |
| 154 void NetworkConfigurationHandler::ClearProperties( | 152 void NetworkConfigurationHandler::ClearProperties( |
| 155 const std::string& service_path, | 153 const std::string& service_path, |
| 156 const std::vector<std::string>& names, | 154 const std::vector<std::string>& names, |
| 157 const base::Closure& callback, | 155 const base::Closure& callback, |
| 158 const network_handler::ErrorCallback& error_callback) { | 156 const network_handler::ErrorCallback& error_callback) { |
| 159 DBusThreadManager::Get()->GetShillServiceClient()->ClearProperties( | 157 DBusThreadManager::Get()->GetShillServiceClient()->ClearProperties( |
| 160 dbus::ObjectPath(service_path), | 158 dbus::ObjectPath(service_path), |
| 161 names, | 159 names, |
| 162 base::Bind(&ClearPropertiesCallback, | 160 base::Bind(&ClearPropertiesCallback, |
| 163 names, | 161 names, |
| 164 service_path, | 162 service_path, |
| 165 callback, | 163 callback, |
| 166 error_callback), | 164 error_callback), |
| 167 base::Bind(&network_handler::ShillErrorCallbackFunction, | 165 base::Bind(&network_handler::ShillErrorCallbackFunction, |
| 168 kLogModule, service_path, error_callback)); | 166 service_path, error_callback)); |
| 169 } | 167 } |
| 170 | 168 |
| 171 void NetworkConfigurationHandler::CreateConfiguration( | 169 void NetworkConfigurationHandler::CreateConfiguration( |
| 172 const base::DictionaryValue& properties, | 170 const base::DictionaryValue& properties, |
| 173 const network_handler::StringResultCallback& callback, | 171 const network_handler::StringResultCallback& callback, |
| 174 const network_handler::ErrorCallback& error_callback) const { | 172 const network_handler::ErrorCallback& error_callback) const { |
| 175 ShillManagerClient* manager = | 173 ShillManagerClient* manager = |
| 176 DBusThreadManager::Get()->GetShillManagerClient(); | 174 DBusThreadManager::Get()->GetShillManagerClient(); |
| 177 | 175 |
| 178 std::string type; | 176 std::string type; |
| 179 properties.GetStringWithoutPathExpansion(flimflam::kTypeProperty, &type); | 177 properties.GetStringWithoutPathExpansion(flimflam::kTypeProperty, &type); |
| 180 // Shill supports ConfigureServiceForProfile only for network type WiFi. In | 178 // Shill supports ConfigureServiceForProfile only for network type WiFi. In |
| 181 // all other cases, we have to rely on GetService for now. This is | 179 // all other cases, we have to rely on GetService for now. This is |
| 182 // unproblematic for VPN (user profile only), but will lead to inconsistencies | 180 // unproblematic for VPN (user profile only), but will lead to inconsistencies |
| 183 // with WiMax, for example. | 181 // with WiMax, for example. |
| 184 if (type == flimflam::kTypeWifi) { | 182 if (type == flimflam::kTypeWifi) { |
| 185 std::string profile; | 183 std::string profile; |
| 186 properties.GetStringWithoutPathExpansion(flimflam::kProfileProperty, | 184 properties.GetStringWithoutPathExpansion(flimflam::kProfileProperty, |
| 187 &profile); | 185 &profile); |
| 188 manager->ConfigureServiceForProfile( | 186 manager->ConfigureServiceForProfile( |
| 189 dbus::ObjectPath(profile), | 187 dbus::ObjectPath(profile), |
| 190 properties, | 188 properties, |
| 191 base::Bind(&RunCreateNetworkCallback, callback), | 189 base::Bind(&RunCreateNetworkCallback, callback), |
| 192 base::Bind(&network_handler::ShillErrorCallbackFunction, | 190 base::Bind(&network_handler::ShillErrorCallbackFunction, |
| 193 kLogModule, "", error_callback)); | 191 "", error_callback)); |
| 194 } else { | 192 } else { |
| 195 manager->GetService( | 193 manager->GetService( |
| 196 properties, | 194 properties, |
| 197 base::Bind(&RunCreateNetworkCallback, callback), | 195 base::Bind(&RunCreateNetworkCallback, callback), |
| 198 base::Bind(&network_handler::ShillErrorCallbackFunction, | 196 base::Bind(&network_handler::ShillErrorCallbackFunction, |
| 199 kLogModule, "", error_callback)); | 197 "", error_callback)); |
| 200 } | 198 } |
| 201 } | 199 } |
| 202 | 200 |
| 203 void NetworkConfigurationHandler::RemoveConfiguration( | 201 void NetworkConfigurationHandler::RemoveConfiguration( |
| 204 const std::string& service_path, | 202 const std::string& service_path, |
| 205 const base::Closure& callback, | 203 const base::Closure& callback, |
| 206 const network_handler::ErrorCallback& error_callback) const { | 204 const network_handler::ErrorCallback& error_callback) const { |
| 207 DBusThreadManager::Get()->GetShillServiceClient()->Remove( | 205 DBusThreadManager::Get()->GetShillServiceClient()->Remove( |
| 208 dbus::ObjectPath(service_path), | 206 dbus::ObjectPath(service_path), |
| 209 callback, | 207 callback, |
| 210 base::Bind(&network_handler::ShillErrorCallbackFunction, | 208 base::Bind(&network_handler::ShillErrorCallbackFunction, |
| 211 kLogModule, service_path, error_callback)); | 209 service_path, error_callback)); |
| 212 } | 210 } |
| 213 | 211 |
| 214 NetworkConfigurationHandler::NetworkConfigurationHandler() { | 212 NetworkConfigurationHandler::NetworkConfigurationHandler() { |
| 215 } | 213 } |
| 216 | 214 |
| 217 NetworkConfigurationHandler::~NetworkConfigurationHandler() { | 215 NetworkConfigurationHandler::~NetworkConfigurationHandler() { |
| 218 } | 216 } |
| 219 | 217 |
| 220 } // namespace chromeos | 218 } // namespace chromeos |
| OLD | NEW |