| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/chromeos/extensions/networking_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/networking_private_api.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "chrome/browser/extensions/extension_function_registry.h" | 10 #include "chrome/browser/extensions/extension_function_registry.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // NetworkingPrivateGetPropertiesFunction | 25 // NetworkingPrivateGetPropertiesFunction |
| 26 | 26 |
| 27 NetworkingPrivateGetPropertiesFunction:: | 27 NetworkingPrivateGetPropertiesFunction:: |
| 28 ~NetworkingPrivateGetPropertiesFunction() { | 28 ~NetworkingPrivateGetPropertiesFunction() { |
| 29 } | 29 } |
| 30 | 30 |
| 31 bool NetworkingPrivateGetPropertiesFunction::RunImpl() { | 31 bool NetworkingPrivateGetPropertiesFunction::RunImpl() { |
| 32 scoped_ptr<api::GetProperties::Params> params = | 32 scoped_ptr<api::GetProperties::Params> params = |
| 33 api::GetProperties::Params::Create(*args_); | 33 api::GetProperties::Params::Create(*args_); |
| 34 EXTENSION_FUNCTION_VALIDATE(params); | 34 EXTENSION_FUNCTION_VALIDATE(params); |
| 35 // The |network_guid| parameter is storing the service path. | |
| 36 std::string service_path = params->network_guid; | |
| 37 | 35 |
| 38 ManagedNetworkConfigurationHandler::Get()->GetProperties( | 36 ManagedNetworkConfigurationHandler::Get()->GetProperties( |
| 39 service_path, | 37 params->network_guid, // service path |
| 40 base::Bind( | 38 base::Bind(&NetworkingPrivateGetPropertiesFunction::GetPropertiesSuccess, |
| 41 &NetworkingPrivateGetPropertiesFunction::GetPropertiesSuccess, | 39 this), |
| 42 this), | |
| 43 base::Bind(&NetworkingPrivateGetPropertiesFunction::GetPropertiesFailed, | 40 base::Bind(&NetworkingPrivateGetPropertiesFunction::GetPropertiesFailed, |
| 44 this)); | 41 this)); |
| 45 return true; | 42 return true; |
| 46 } | 43 } |
| 47 | 44 |
| 48 void NetworkingPrivateGetPropertiesFunction::GetPropertiesSuccess( | 45 void NetworkingPrivateGetPropertiesFunction::GetPropertiesSuccess( |
| 49 const std::string& service_path, | 46 const std::string& service_path, |
| 50 const base::DictionaryValue& dictionary) { | 47 const base::DictionaryValue& dictionary) { |
| 51 base::DictionaryValue* network_properties = dictionary.DeepCopy(); | 48 base::DictionaryValue* network_properties = dictionary.DeepCopy(); |
| 52 network_properties->SetStringWithoutPathExpansion(onc::network_config::kGUID, | 49 network_properties->SetStringWithoutPathExpansion(onc::network_config::kGUID, |
| 53 service_path); | 50 service_path); |
| 54 SetResult(network_properties); | 51 SetResult(network_properties); |
| 55 SendResponse(true); | 52 SendResponse(true); |
| 56 } | 53 } |
| 57 | 54 |
| 58 void NetworkingPrivateGetPropertiesFunction::GetPropertiesFailed( | 55 void NetworkingPrivateGetPropertiesFunction::GetPropertiesFailed( |
| 59 const std::string& error_name, | 56 const std::string& error_name, |
| 60 scoped_ptr<base::DictionaryValue> error_data) { | 57 scoped_ptr<base::DictionaryValue> error_data) { |
| 61 error_ = error_name; | 58 error_ = error_name; |
| 62 SendResponse(false); | 59 SendResponse(false); |
| 63 } | 60 } |
| 64 | 61 |
| 65 //////////////////////////////////////////////////////////////////////////////// | 62 //////////////////////////////////////////////////////////////////////////////// |
| 63 // NetworkingPrivateGetManagedPropertiesFunction |
| 64 |
| 65 NetworkingPrivateGetManagedPropertiesFunction:: |
| 66 ~NetworkingPrivateGetManagedPropertiesFunction() { |
| 67 } |
| 68 |
| 69 bool NetworkingPrivateGetManagedPropertiesFunction::RunImpl() { |
| 70 scoped_ptr<api::GetManagedProperties::Params> params = |
| 71 api::GetManagedProperties::Params::Create(*args_); |
| 72 EXTENSION_FUNCTION_VALIDATE(params); |
| 73 |
| 74 ManagedNetworkConfigurationHandler::Get()->GetManagedProperties( |
| 75 params->network_guid, // service path |
| 76 base::Bind(&NetworkingPrivateGetManagedPropertiesFunction::Success, |
| 77 this), |
| 78 base::Bind(&NetworkingPrivateGetManagedPropertiesFunction::Failure, |
| 79 this)); |
| 80 return true; |
| 81 } |
| 82 |
| 83 void NetworkingPrivateGetManagedPropertiesFunction::Success( |
| 84 const std::string& service_path, |
| 85 const base::DictionaryValue& dictionary) { |
| 86 base::DictionaryValue* network_properties = dictionary.DeepCopy(); |
| 87 network_properties->SetStringWithoutPathExpansion(onc::network_config::kGUID, |
| 88 service_path); |
| 89 SetResult(network_properties); |
| 90 SendResponse(true); |
| 91 } |
| 92 |
| 93 void NetworkingPrivateGetManagedPropertiesFunction::Failure( |
| 94 const std::string& error_name, |
| 95 scoped_ptr<base::DictionaryValue> error_data) { |
| 96 error_ = error_name; |
| 97 SendResponse(false); |
| 98 } |
| 99 |
| 100 //////////////////////////////////////////////////////////////////////////////// |
| 66 // NetworkingPrivateGetStateFunction | 101 // NetworkingPrivateGetStateFunction |
| 67 | 102 |
| 68 NetworkingPrivateGetStateFunction:: | 103 NetworkingPrivateGetStateFunction:: |
| 69 ~NetworkingPrivateGetStateFunction() { | 104 ~NetworkingPrivateGetStateFunction() { |
| 70 } | 105 } |
| 71 | 106 |
| 72 bool NetworkingPrivateGetStateFunction::RunImpl() { | 107 bool NetworkingPrivateGetStateFunction::RunImpl() { |
| 73 scoped_ptr<api::GetState::Params> params = | 108 scoped_ptr<api::GetState::Params> params = |
| 74 api::GetState::Params::Create(*args_); | 109 api::GetState::Params::Create(*args_); |
| 75 EXTENSION_FUNCTION_VALIDATE(params); | 110 EXTENSION_FUNCTION_VALIDATE(params); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 103 | 138 |
| 104 bool NetworkingPrivateSetPropertiesFunction::RunImpl() { | 139 bool NetworkingPrivateSetPropertiesFunction::RunImpl() { |
| 105 scoped_ptr<api::SetProperties::Params> params = | 140 scoped_ptr<api::SetProperties::Params> params = |
| 106 api::SetProperties::Params::Create(*args_); | 141 api::SetProperties::Params::Create(*args_); |
| 107 EXTENSION_FUNCTION_VALIDATE(params); | 142 EXTENSION_FUNCTION_VALIDATE(params); |
| 108 | 143 |
| 109 scoped_ptr<base::DictionaryValue> properties_dict( | 144 scoped_ptr<base::DictionaryValue> properties_dict( |
| 110 params->properties.ToValue()); | 145 params->properties.ToValue()); |
| 111 | 146 |
| 112 ManagedNetworkConfigurationHandler::Get()->SetProperties( | 147 ManagedNetworkConfigurationHandler::Get()->SetProperties( |
| 113 params->network_guid, | 148 params->network_guid, // service path |
| 114 *properties_dict, | 149 *properties_dict, |
| 115 base::Bind(&NetworkingPrivateSetPropertiesFunction::ResultCallback, | 150 base::Bind(&NetworkingPrivateSetPropertiesFunction::ResultCallback, |
| 116 this), | 151 this), |
| 117 base::Bind(&NetworkingPrivateSetPropertiesFunction::ErrorCallback, | 152 base::Bind(&NetworkingPrivateSetPropertiesFunction::ErrorCallback, |
| 118 this)); | 153 this)); |
| 119 return true; | 154 return true; |
| 120 } | 155 } |
| 121 | 156 |
| 122 void NetworkingPrivateSetPropertiesFunction::ErrorCallback( | 157 void NetworkingPrivateSetPropertiesFunction::ErrorCallback( |
| 123 const std::string& error_name, | 158 const std::string& error_name, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 const scoped_ptr<base::DictionaryValue> error_data) { | 238 const scoped_ptr<base::DictionaryValue> error_data) { |
| 204 error_ = error_name; | 239 error_ = error_name; |
| 205 SendResponse(false); | 240 SendResponse(false); |
| 206 } | 241 } |
| 207 | 242 |
| 208 bool NetworkingPrivateStartConnectFunction::RunImpl() { | 243 bool NetworkingPrivateStartConnectFunction::RunImpl() { |
| 209 scoped_ptr<api::StartConnect::Params> params = | 244 scoped_ptr<api::StartConnect::Params> params = |
| 210 api::StartConnect::Params::Create(*args_); | 245 api::StartConnect::Params::Create(*args_); |
| 211 EXTENSION_FUNCTION_VALIDATE(params); | 246 EXTENSION_FUNCTION_VALIDATE(params); |
| 212 | 247 |
| 213 // The |network_guid| parameter is storing the service path. | |
| 214 std::string service_path = params->network_guid; | |
| 215 | |
| 216 ManagedNetworkConfigurationHandler::Get()->Connect( | 248 ManagedNetworkConfigurationHandler::Get()->Connect( |
| 217 service_path, | 249 params->network_guid, // service path |
| 218 base::Bind( | 250 base::Bind( |
| 219 &NetworkingPrivateStartConnectFunction::ConnectionStartSuccess, | 251 &NetworkingPrivateStartConnectFunction::ConnectionStartSuccess, |
| 220 this), | 252 this), |
| 221 base::Bind( | 253 base::Bind( |
| 222 &NetworkingPrivateStartConnectFunction::ConnectionStartFailed, | 254 &NetworkingPrivateStartConnectFunction::ConnectionStartFailed, |
| 223 this)); | 255 this)); |
| 224 return true; | 256 return true; |
| 225 } | 257 } |
| 226 | 258 |
| 227 //////////////////////////////////////////////////////////////////////////////// | 259 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 12 matching lines...) Expand all Loading... |
| 240 const scoped_ptr<base::DictionaryValue> error_data) { | 272 const scoped_ptr<base::DictionaryValue> error_data) { |
| 241 error_ = error_name; | 273 error_ = error_name; |
| 242 SendResponse(false); | 274 SendResponse(false); |
| 243 } | 275 } |
| 244 | 276 |
| 245 bool NetworkingPrivateStartDisconnectFunction::RunImpl() { | 277 bool NetworkingPrivateStartDisconnectFunction::RunImpl() { |
| 246 scoped_ptr<api::StartDisconnect::Params> params = | 278 scoped_ptr<api::StartDisconnect::Params> params = |
| 247 api::StartDisconnect::Params::Create(*args_); | 279 api::StartDisconnect::Params::Create(*args_); |
| 248 EXTENSION_FUNCTION_VALIDATE(params); | 280 EXTENSION_FUNCTION_VALIDATE(params); |
| 249 | 281 |
| 250 // The |network_guid| parameter is storing the service path. | |
| 251 std::string service_path = params->network_guid; | |
| 252 | |
| 253 ManagedNetworkConfigurationHandler::Get()->Disconnect( | 282 ManagedNetworkConfigurationHandler::Get()->Disconnect( |
| 254 service_path, | 283 params->network_guid, // service path |
| 255 base::Bind( | 284 base::Bind( |
| 256 &NetworkingPrivateStartDisconnectFunction::DisconnectionStartSuccess, | 285 &NetworkingPrivateStartDisconnectFunction::DisconnectionStartSuccess, |
| 257 this), | 286 this), |
| 258 base::Bind( | 287 base::Bind( |
| 259 &NetworkingPrivateStartDisconnectFunction::DisconnectionStartFailed, | 288 &NetworkingPrivateStartDisconnectFunction::DisconnectionStartFailed, |
| 260 this)); | 289 this)); |
| 261 return true; | 290 return true; |
| 262 } | 291 } |
| 263 | 292 |
| 264 //////////////////////////////////////////////////////////////////////////////// | 293 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 const std::string& result) { | 402 const std::string& result) { |
| 374 results_ = api::VerifyAndEncryptData::Results::Create(result); | 403 results_ = api::VerifyAndEncryptData::Results::Create(result); |
| 375 SendResponse(true); | 404 SendResponse(true); |
| 376 } | 405 } |
| 377 | 406 |
| 378 void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback( | 407 void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback( |
| 379 const std::string& error_name, const std::string& error) { | 408 const std::string& error_name, const std::string& error) { |
| 380 error_ = error_name; | 409 error_ = error_name; |
| 381 SendResponse(false); | 410 SendResponse(false); |
| 382 } | 411 } |
| OLD | NEW |