| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 const scoped_ptr<base::DictionaryValue> error_data) { | 226 const scoped_ptr<base::DictionaryValue> error_data) { |
| 192 error_ = error_name; | 227 error_ = error_name; |
| 193 SendResponse(false); | 228 SendResponse(false); |
| 194 } | 229 } |
| 195 | 230 |
| 196 bool NetworkingPrivateStartConnectFunction::RunImpl() { | 231 bool NetworkingPrivateStartConnectFunction::RunImpl() { |
| 197 scoped_ptr<api::StartConnect::Params> params = | 232 scoped_ptr<api::StartConnect::Params> params = |
| 198 api::StartConnect::Params::Create(*args_); | 233 api::StartConnect::Params::Create(*args_); |
| 199 EXTENSION_FUNCTION_VALIDATE(params); | 234 EXTENSION_FUNCTION_VALIDATE(params); |
| 200 | 235 |
| 201 // The |network_guid| parameter is storing the service path. | |
| 202 std::string service_path = params->network_guid; | |
| 203 | |
| 204 ManagedNetworkConfigurationHandler::Get()->Connect( | 236 ManagedNetworkConfigurationHandler::Get()->Connect( |
| 205 service_path, | 237 params->network_guid, // service path |
| 206 base::Bind( | 238 base::Bind( |
| 207 &NetworkingPrivateStartConnectFunction::ConnectionStartSuccess, | 239 &NetworkingPrivateStartConnectFunction::ConnectionStartSuccess, |
| 208 this), | 240 this), |
| 209 base::Bind( | 241 base::Bind( |
| 210 &NetworkingPrivateStartConnectFunction::ConnectionStartFailed, | 242 &NetworkingPrivateStartConnectFunction::ConnectionStartFailed, |
| 211 this)); | 243 this)); |
| 212 return true; | 244 return true; |
| 213 } | 245 } |
| 214 | 246 |
| 215 //////////////////////////////////////////////////////////////////////////////// | 247 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 12 matching lines...) Expand all Loading... |
| 228 const scoped_ptr<base::DictionaryValue> error_data) { | 260 const scoped_ptr<base::DictionaryValue> error_data) { |
| 229 error_ = error_name; | 261 error_ = error_name; |
| 230 SendResponse(false); | 262 SendResponse(false); |
| 231 } | 263 } |
| 232 | 264 |
| 233 bool NetworkingPrivateStartDisconnectFunction::RunImpl() { | 265 bool NetworkingPrivateStartDisconnectFunction::RunImpl() { |
| 234 scoped_ptr<api::StartDisconnect::Params> params = | 266 scoped_ptr<api::StartDisconnect::Params> params = |
| 235 api::StartDisconnect::Params::Create(*args_); | 267 api::StartDisconnect::Params::Create(*args_); |
| 236 EXTENSION_FUNCTION_VALIDATE(params); | 268 EXTENSION_FUNCTION_VALIDATE(params); |
| 237 | 269 |
| 238 // The |network_guid| parameter is storing the service path. | |
| 239 std::string service_path = params->network_guid; | |
| 240 | |
| 241 ManagedNetworkConfigurationHandler::Get()->Disconnect( | 270 ManagedNetworkConfigurationHandler::Get()->Disconnect( |
| 242 service_path, | 271 params->network_guid, // service path |
| 243 base::Bind( | 272 base::Bind( |
| 244 &NetworkingPrivateStartDisconnectFunction::DisconnectionStartSuccess, | 273 &NetworkingPrivateStartDisconnectFunction::DisconnectionStartSuccess, |
| 245 this), | 274 this), |
| 246 base::Bind( | 275 base::Bind( |
| 247 &NetworkingPrivateStartDisconnectFunction::DisconnectionStartFailed, | 276 &NetworkingPrivateStartDisconnectFunction::DisconnectionStartFailed, |
| 248 this)); | 277 this)); |
| 249 return true; | 278 return true; |
| 250 } | 279 } |
| 251 | 280 |
| 252 //////////////////////////////////////////////////////////////////////////////// | 281 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 const std::string& result) { | 390 const std::string& result) { |
| 362 results_ = api::VerifyAndEncryptData::Results::Create(result); | 391 results_ = api::VerifyAndEncryptData::Results::Create(result); |
| 363 SendResponse(true); | 392 SendResponse(true); |
| 364 } | 393 } |
| 365 | 394 |
| 366 void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback( | 395 void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback( |
| 367 const std::string& error_name, const std::string& error) { | 396 const std::string& error_name, const std::string& error) { |
| 368 error_ = error_name; | 397 error_ = error_name; |
| 369 SendResponse(false); | 398 SendResponse(false); |
| 370 } | 399 } |
| OLD | NEW |