| 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 19 matching lines...) Expand all Loading... |
| 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. | 35 // The |network_guid| parameter is storing the service path. |
| 36 std::string service_path = params->network_guid; | 36 std::string service_path = params->network_guid; |
| 37 | 37 |
| 38 ManagedNetworkConfigurationHandler::Get()->GetProperties( | 38 ManagedNetworkConfigurationHandler::Get()->GetProperties( |
| 39 service_path, | 39 service_path, |
| 40 base::Bind( | 40 base::Bind(&NetworkingPrivateGetPropertiesFunction::GetPropertiesSuccess, |
| 41 &NetworkingPrivateGetPropertiesFunction::GetPropertiesSuccess, | 41 this), |
| 42 this), | |
| 43 base::Bind(&NetworkingPrivateGetPropertiesFunction::GetPropertiesFailed, | 42 base::Bind(&NetworkingPrivateGetPropertiesFunction::GetPropertiesFailed, |
| 44 this)); | 43 this)); |
| 45 return true; | 44 return true; |
| 46 } | 45 } |
| 47 | 46 |
| 48 void NetworkingPrivateGetPropertiesFunction::GetPropertiesSuccess( | 47 void NetworkingPrivateGetPropertiesFunction::GetPropertiesSuccess( |
| 49 const std::string& service_path, | 48 const std::string& service_path, |
| 50 const base::DictionaryValue& dictionary) { | 49 const base::DictionaryValue& dictionary) { |
| 51 base::DictionaryValue* network_properties = dictionary.DeepCopy(); | 50 base::DictionaryValue* network_properties = dictionary.DeepCopy(); |
| 52 network_properties->SetStringWithoutPathExpansion(onc::network_config::kGUID, | 51 network_properties->SetStringWithoutPathExpansion(onc::network_config::kGUID, |
| 53 service_path); | 52 service_path); |
| 54 SetResult(network_properties); | 53 SetResult(network_properties); |
| 55 SendResponse(true); | 54 SendResponse(true); |
| 56 } | 55 } |
| 57 | 56 |
| 58 void NetworkingPrivateGetPropertiesFunction::GetPropertiesFailed( | 57 void NetworkingPrivateGetPropertiesFunction::GetPropertiesFailed( |
| 59 const std::string& error_name, | 58 const std::string& error_name, |
| 60 scoped_ptr<base::DictionaryValue> error_data) { | 59 scoped_ptr<base::DictionaryValue> error_data) { |
| 61 error_ = error_name; | 60 error_ = error_name; |
| 62 SendResponse(false); | 61 SendResponse(false); |
| 63 } | 62 } |
| 64 | 63 |
| 65 //////////////////////////////////////////////////////////////////////////////// | 64 //////////////////////////////////////////////////////////////////////////////// |
| 65 // NetworkingPrivateGetManagedPropertiesFunction |
| 66 |
| 67 NetworkingPrivateGetManagedPropertiesFunction:: |
| 68 ~NetworkingPrivateGetManagedPropertiesFunction() { |
| 69 } |
| 70 |
| 71 bool NetworkingPrivateGetManagedPropertiesFunction::RunImpl() { |
| 72 scoped_ptr<api::GetManagedProperties::Params> params = |
| 73 api::GetManagedProperties::Params::Create(*args_); |
| 74 EXTENSION_FUNCTION_VALIDATE(params); |
| 75 // The |network_guid| parameter is storing the service path. |
| 76 std::string service_path = params->network_guid; |
| 77 |
| 78 ManagedNetworkConfigurationHandler::Get()->GetManagedProperties( |
| 79 service_path, |
| 80 base::Bind(&NetworkingPrivateGetManagedPropertiesFunction::Success, |
| 81 this), |
| 82 base::Bind(&NetworkingPrivateGetManagedPropertiesFunction::Failure, |
| 83 this)); |
| 84 return true; |
| 85 } |
| 86 |
| 87 void NetworkingPrivateGetManagedPropertiesFunction::Success( |
| 88 const std::string& service_path, |
| 89 const base::DictionaryValue& dictionary) { |
| 90 base::DictionaryValue* network_properties = dictionary.DeepCopy(); |
| 91 network_properties->SetStringWithoutPathExpansion(onc::network_config::kGUID, |
| 92 service_path); |
| 93 SetResult(network_properties); |
| 94 SendResponse(true); |
| 95 } |
| 96 |
| 97 void NetworkingPrivateGetManagedPropertiesFunction::Failure( |
| 98 const std::string& error_name, |
| 99 scoped_ptr<base::DictionaryValue> error_data) { |
| 100 error_ = error_name; |
| 101 SendResponse(false); |
| 102 } |
| 103 |
| 104 //////////////////////////////////////////////////////////////////////////////// |
| 66 // NetworkingPrivateGetStateFunction | 105 // NetworkingPrivateGetStateFunction |
| 67 | 106 |
| 68 NetworkingPrivateGetStateFunction:: | 107 NetworkingPrivateGetStateFunction:: |
| 69 ~NetworkingPrivateGetStateFunction() { | 108 ~NetworkingPrivateGetStateFunction() { |
| 70 } | 109 } |
| 71 | 110 |
| 72 bool NetworkingPrivateGetStateFunction::RunImpl() { | 111 bool NetworkingPrivateGetStateFunction::RunImpl() { |
| 73 scoped_ptr<api::GetState::Params> params = | 112 scoped_ptr<api::GetState::Params> params = |
| 74 api::GetState::Params::Create(*args_); | 113 api::GetState::Params::Create(*args_); |
| 75 EXTENSION_FUNCTION_VALIDATE(params); | 114 EXTENSION_FUNCTION_VALIDATE(params); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 102 } | 141 } |
| 103 | 142 |
| 104 bool NetworkingPrivateSetPropertiesFunction::RunImpl() { | 143 bool NetworkingPrivateSetPropertiesFunction::RunImpl() { |
| 105 scoped_ptr<api::SetProperties::Params> params = | 144 scoped_ptr<api::SetProperties::Params> params = |
| 106 api::SetProperties::Params::Create(*args_); | 145 api::SetProperties::Params::Create(*args_); |
| 107 EXTENSION_FUNCTION_VALIDATE(params); | 146 EXTENSION_FUNCTION_VALIDATE(params); |
| 108 | 147 |
| 109 scoped_ptr<base::DictionaryValue> properties_dict( | 148 scoped_ptr<base::DictionaryValue> properties_dict( |
| 110 params->properties.ToValue()); | 149 params->properties.ToValue()); |
| 111 | 150 |
| 151 // The |network_guid| parameter is storing the service path. |
| 152 std::string service_path = params->network_guid; |
| 153 |
| 112 ManagedNetworkConfigurationHandler::Get()->SetProperties( | 154 ManagedNetworkConfigurationHandler::Get()->SetProperties( |
| 113 params->network_guid, | 155 service_path, |
| 114 *properties_dict, | 156 *properties_dict, |
| 115 base::Bind(&NetworkingPrivateSetPropertiesFunction::ResultCallback, | 157 base::Bind(&NetworkingPrivateSetPropertiesFunction::ResultCallback, |
| 116 this), | 158 this), |
| 117 base::Bind(&NetworkingPrivateSetPropertiesFunction::ErrorCallback, | 159 base::Bind(&NetworkingPrivateSetPropertiesFunction::ErrorCallback, |
| 118 this)); | 160 this)); |
| 119 return true; | 161 return true; |
| 120 } | 162 } |
| 121 | 163 |
| 122 void NetworkingPrivateSetPropertiesFunction::ErrorCallback( | 164 void NetworkingPrivateSetPropertiesFunction::ErrorCallback( |
| 123 const std::string& error_name, | 165 const std::string& error_name, |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 const std::string& result) { | 403 const std::string& result) { |
| 362 results_ = api::VerifyAndEncryptData::Results::Create(result); | 404 results_ = api::VerifyAndEncryptData::Results::Create(result); |
| 363 SendResponse(true); | 405 SendResponse(true); |
| 364 } | 406 } |
| 365 | 407 |
| 366 void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback( | 408 void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback( |
| 367 const std::string& error_name, const std::string& error) { | 409 const std::string& error_name, const std::string& error) { |
| 368 error_ = error_name; | 410 error_ = error_name; |
| 369 SendResponse(false); | 411 SendResponse(false); |
| 370 } | 412 } |
| OLD | NEW |