| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/networking_private/networking_private_api.h" | 5 #include "extensions/browser/api/networking_private/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 "components/onc/onc_constants.h" | 10 #include "components/onc/onc_constants.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 NetworkingPrivateSetPropertiesFunction:: | 140 NetworkingPrivateSetPropertiesFunction:: |
| 141 ~NetworkingPrivateSetPropertiesFunction() { | 141 ~NetworkingPrivateSetPropertiesFunction() { |
| 142 } | 142 } |
| 143 | 143 |
| 144 bool NetworkingPrivateSetPropertiesFunction::RunAsync() { | 144 bool NetworkingPrivateSetPropertiesFunction::RunAsync() { |
| 145 scoped_ptr<private_api::SetProperties::Params> params = | 145 scoped_ptr<private_api::SetProperties::Params> params = |
| 146 private_api::SetProperties::Params::Create(*args_); | 146 private_api::SetProperties::Params::Create(*args_); |
| 147 EXTENSION_FUNCTION_VALIDATE(params); | 147 EXTENSION_FUNCTION_VALIDATE(params); |
| 148 | 148 |
| 149 // TODO(stevenjb): Switch this back to params->properties.ToValue() once we | |
| 150 // introduce types to the IDL. crbug.com/470262. | |
| 151 scoped_ptr<base::DictionaryValue> properties_dict( | 149 scoped_ptr<base::DictionaryValue> properties_dict( |
| 152 params->properties.additional_properties.DeepCopy()); | 150 params->properties.ToValue()); |
| 153 | 151 |
| 154 GetDelegate(browser_context()) | 152 GetDelegate(browser_context()) |
| 155 ->SetProperties( | 153 ->SetProperties( |
| 156 params->network_guid, properties_dict.Pass(), | 154 params->network_guid, properties_dict.Pass(), |
| 157 base::Bind(&NetworkingPrivateSetPropertiesFunction::Success, this), | 155 base::Bind(&NetworkingPrivateSetPropertiesFunction::Success, this), |
| 158 base::Bind(&NetworkingPrivateSetPropertiesFunction::Failure, this)); | 156 base::Bind(&NetworkingPrivateSetPropertiesFunction::Failure, this)); |
| 159 return true; | 157 return true; |
| 160 } | 158 } |
| 161 | 159 |
| 162 void NetworkingPrivateSetPropertiesFunction::Success() { | 160 void NetworkingPrivateSetPropertiesFunction::Success() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 173 | 171 |
| 174 NetworkingPrivateCreateNetworkFunction:: | 172 NetworkingPrivateCreateNetworkFunction:: |
| 175 ~NetworkingPrivateCreateNetworkFunction() { | 173 ~NetworkingPrivateCreateNetworkFunction() { |
| 176 } | 174 } |
| 177 | 175 |
| 178 bool NetworkingPrivateCreateNetworkFunction::RunAsync() { | 176 bool NetworkingPrivateCreateNetworkFunction::RunAsync() { |
| 179 scoped_ptr<private_api::CreateNetwork::Params> params = | 177 scoped_ptr<private_api::CreateNetwork::Params> params = |
| 180 private_api::CreateNetwork::Params::Create(*args_); | 178 private_api::CreateNetwork::Params::Create(*args_); |
| 181 EXTENSION_FUNCTION_VALIDATE(params); | 179 EXTENSION_FUNCTION_VALIDATE(params); |
| 182 | 180 |
| 183 // TODO(stevenjb): Switch this back to params->properties.ToValue() once we | |
| 184 // introduce types to the IDL. crbug.com/470262. | |
| 185 scoped_ptr<base::DictionaryValue> properties_dict( | 181 scoped_ptr<base::DictionaryValue> properties_dict( |
| 186 params->properties.additional_properties.DeepCopy()); | 182 params->properties.ToValue()); |
| 187 | 183 |
| 188 GetDelegate(browser_context()) | 184 GetDelegate(browser_context()) |
| 189 ->CreateNetwork( | 185 ->CreateNetwork( |
| 190 params->shared, properties_dict.Pass(), | 186 params->shared, properties_dict.Pass(), |
| 191 base::Bind(&NetworkingPrivateCreateNetworkFunction::Success, this), | 187 base::Bind(&NetworkingPrivateCreateNetworkFunction::Success, this), |
| 192 base::Bind(&NetworkingPrivateCreateNetworkFunction::Failure, this)); | 188 base::Bind(&NetworkingPrivateCreateNetworkFunction::Failure, this)); |
| 193 return true; | 189 return true; |
| 194 } | 190 } |
| 195 | 191 |
| 196 void NetworkingPrivateCreateNetworkFunction::Success(const std::string& guid) { | 192 void NetworkingPrivateCreateNetworkFunction::Success(const std::string& guid) { |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 SendResponse(true); | 676 SendResponse(true); |
| 681 } | 677 } |
| 682 | 678 |
| 683 void NetworkingPrivateGetCaptivePortalStatusFunction::Failure( | 679 void NetworkingPrivateGetCaptivePortalStatusFunction::Failure( |
| 684 const std::string& error) { | 680 const std::string& error) { |
| 685 error_ = error; | 681 error_ = error; |
| 686 SendResponse(false); | 682 SendResponse(false); |
| 687 } | 683 } |
| 688 | 684 |
| 689 } // namespace extensions | 685 } // namespace extensions |
| OLD | NEW |