Chromium Code Reviews| 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/chromeos/net/managed_network_configuration_handler.h" | 10 #include "chrome/browser/chromeos/net/managed_network_configuration_handler.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 } | 56 } |
| 57 | 57 |
| 58 void NetworkingPrivateGetPropertiesFunction::GetPropertiesFailed( | 58 void NetworkingPrivateGetPropertiesFunction::GetPropertiesFailed( |
| 59 const std::string& error_name, | 59 const std::string& error_name, |
| 60 scoped_ptr<base::DictionaryValue> error_data) { | 60 scoped_ptr<base::DictionaryValue> error_data) { |
| 61 error_ = error_name; | 61 error_ = error_name; |
| 62 SendResponse(false); | 62 SendResponse(false); |
| 63 } | 63 } |
| 64 | 64 |
| 65 //////////////////////////////////////////////////////////////////////////////// | 65 //////////////////////////////////////////////////////////////////////////////// |
| 66 // NetworkingPrivateGetStateFunction | |
| 67 | |
| 68 NetworkingPrivateGetStateFunction:: | |
| 69 ~NetworkingPrivateGetStateFunction() { | |
| 70 } | |
| 71 | |
| 72 bool NetworkingPrivateGetStateFunction::RunImpl() { | |
| 73 scoped_ptr<api::GetState::Params> params = | |
| 74 api::GetState::Params::Create(*args_); | |
| 75 EXTENSION_FUNCTION_VALIDATE(params); | |
| 76 // The |network_guid| parameter is storing the service path. | |
| 77 std::string service_path = params->network_guid; | |
| 78 | |
| 79 const NetworkState* state = | |
| 80 NetworkStateHandler::Get()->GetNetworkState(service_path); | |
| 81 if (!state) { | |
| 82 error_ = "Error.InvalidParameter"; | |
|
stevenjb
2013/03/07 00:43:22
Should this be "InvalidParameter"? A network might
Greg Spencer (Chromium)
2013/03/07 22:01:23
Well, my thought was that the service path was no
stevenjb
2013/03/08 19:04:16
I guess I was thinking that the service could be "
| |
| 83 SendResponse(false); | |
| 84 } | |
| 85 | |
| 86 scoped_ptr<base::DictionaryValue> result_dict(new base::DictionaryValue); | |
| 87 state->FillDictionary(result_dict.get()); | |
|
pneubeck (no reviews)
2013/03/07 13:06:18
|result_dict| has to be translated to ONC, since "
Greg Spencer (Chromium)
2013/03/07 22:01:23
Ahh, no wonder my results were off...
| |
| 88 SetResult(result_dict.release()); | |
| 89 SendResponse(true); | |
| 90 | |
| 91 return true; | |
| 92 } | |
| 93 | |
| 94 //////////////////////////////////////////////////////////////////////////////// | |
| 95 // NetworkingPrivateSetPropertiesFunction | |
| 96 | |
| 97 NetworkingPrivateSetPropertiesFunction:: | |
| 98 ~NetworkingPrivateSetPropertiesFunction() { | |
|
stevenjb
2013/03/07 00:43:22
No WS at beginning of line here I think
Greg Spencer (Chromium)
2013/03/07 22:01:23
OK. :-) I don't think there's a lot of precedent
stevenjb
2013/03/08 19:04:16
There's not a ton of precedent, but it's what I ha
| |
| 99 } | |
| 100 | |
| 101 bool NetworkingPrivateSetPropertiesFunction::RunImpl() { | |
| 102 scoped_ptr<api::SetProperties::Params> params = | |
| 103 api::SetProperties::Params::Create(*args_); | |
| 104 EXTENSION_FUNCTION_VALIDATE(params); | |
| 105 | |
| 106 scoped_ptr<base::DictionaryValue> properties_dict( | |
| 107 params->properties.ToValue()); | |
| 108 | |
| 109 ManagedNetworkConfigurationHandler::Get()->SetProperties( | |
| 110 params->network_guid, | |
| 111 *properties_dict, | |
| 112 base::Bind(&NetworkingPrivateSetPropertiesFunction::ResultCallback, | |
| 113 this), | |
| 114 base::Bind(&NetworkingPrivateSetPropertiesFunction::ErrorCallback, | |
| 115 this)); | |
| 116 return true; | |
| 117 } | |
| 118 | |
| 119 void NetworkingPrivateSetPropertiesFunction::ErrorCallback( | |
| 120 const std::string& error_name, | |
| 121 const scoped_ptr<base::DictionaryValue> error_data) { | |
| 122 error_ = error_name; | |
| 123 SendResponse(false); | |
| 124 } | |
| 125 | |
| 126 void NetworkingPrivateSetPropertiesFunction::ResultCallback() { | |
| 127 SendResponse(true); | |
| 128 } | |
| 129 | |
| 130 //////////////////////////////////////////////////////////////////////////////// | |
| 66 // NetworkingPrivateGetVisibleNetworksFunction | 131 // NetworkingPrivateGetVisibleNetworksFunction |
| 67 | 132 |
| 68 NetworkingPrivateGetVisibleNetworksFunction:: | 133 NetworkingPrivateGetVisibleNetworksFunction:: |
| 69 ~NetworkingPrivateGetVisibleNetworksFunction() { | 134 ~NetworkingPrivateGetVisibleNetworksFunction() { |
| 70 } | 135 } |
| 71 | 136 |
| 72 bool NetworkingPrivateGetVisibleNetworksFunction::RunImpl() { | 137 bool NetworkingPrivateGetVisibleNetworksFunction::RunImpl() { |
| 73 scoped_ptr<api::GetVisibleNetworks::Params> params = | 138 scoped_ptr<api::GetVisibleNetworks::Params> params = |
| 74 api::GetVisibleNetworks::Params::Create(*args_); | 139 api::GetVisibleNetworks::Params::Create(*args_); |
| 75 EXTENSION_FUNCTION_VALIDATE(params); | 140 EXTENSION_FUNCTION_VALIDATE(params); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 const std::string& result) { | 362 const std::string& result) { |
| 298 results_ = api::VerifyAndEncryptData::Results::Create(result); | 363 results_ = api::VerifyAndEncryptData::Results::Create(result); |
| 299 SendResponse(true); | 364 SendResponse(true); |
| 300 } | 365 } |
| 301 | 366 |
| 302 void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback( | 367 void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback( |
| 303 const std::string& error_name, const std::string& error) { | 368 const std::string& error_name, const std::string& error) { |
| 304 error_ = error_name; | 369 error_ = error_name; |
| 305 SendResponse(false); | 370 SendResponse(false); |
| 306 } | 371 } |
| 372 | |
| OLD | NEW |