| 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 "chrome/browser/extensions/api/networking_private/networking_private_ap
i.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 "chrome/browser/extensions/api/networking_private/networking_private_de
legate.h" | |
| 11 #include "chrome/browser/extensions/api/networking_private/networking_private_de
legate_factory.h" | |
| 12 #include "chrome/common/extensions/api/networking_private.h" | |
| 13 #include "components/onc/onc_constants.h" | 10 #include "components/onc/onc_constants.h" |
| 11 #include "extensions/browser/api/networking_private/networking_private_delegate.
h" |
| 12 #include "extensions/browser/api/networking_private/networking_private_delegate_
factory.h" |
| 14 #include "extensions/browser/extension_function_registry.h" | 13 #include "extensions/browser/extension_function_registry.h" |
| 14 #include "extensions/common/api/networking_private.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 const int kDefaultNetworkListLimit = 1000; | 18 const int kDefaultNetworkListLimit = 1000; |
| 19 | 19 |
| 20 extensions::NetworkingPrivateDelegate* GetDelegate( | 20 extensions::NetworkingPrivateDelegate* GetDelegate( |
| 21 content::BrowserContext* browser_context) { | 21 content::BrowserContext* browser_context) { |
| 22 return extensions::NetworkingPrivateDelegateFactory::GetForBrowserContext( | 22 return extensions::NetworkingPrivateDelegateFactory::GetForBrowserContext( |
| 23 browser_context); | 23 browser_context); |
| 24 } | 24 } |
| 25 | 25 |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 namespace private_api = extensions::api::networking_private; | 28 namespace extensions { |
| 29 | 29 |
| 30 namespace extensions { | 30 namespace private_api = core_api::networking_private; |
| 31 | 31 |
| 32 namespace networking_private { | 32 namespace networking_private { |
| 33 | 33 |
| 34 // static | 34 // static |
| 35 const char kErrorInvalidNetworkGuid[] = "Error.InvalidNetworkGuid"; | 35 const char kErrorInvalidNetworkGuid[] = "Error.InvalidNetworkGuid"; |
| 36 const char kErrorNetworkUnavailable[] = "Error.NetworkUnavailable"; | 36 const char kErrorNetworkUnavailable[] = "Error.NetworkUnavailable"; |
| 37 const char kErrorEncryptionError[] = "Error.EncryptionError"; | 37 const char kErrorEncryptionError[] = "Error.EncryptionError"; |
| 38 const char kErrorNotReady[] = "Error.NotReady"; | 38 const char kErrorNotReady[] = "Error.NotReady"; |
| 39 const char kErrorNotSupported[] = "Error.NotSupported"; | 39 const char kErrorNotSupported[] = "Error.NotSupported"; |
| 40 | 40 |
| 41 } // namespace networking_private | 41 } // namespace networking_private |
| 42 | 42 |
| 43 //////////////////////////////////////////////////////////////////////////////// | 43 //////////////////////////////////////////////////////////////////////////////// |
| 44 // NetworkingPrivateGetPropertiesFunction | 44 // NetworkingPrivateGetPropertiesFunction |
| 45 | 45 |
| 46 NetworkingPrivateGetPropertiesFunction:: | 46 NetworkingPrivateGetPropertiesFunction:: |
| 47 ~NetworkingPrivateGetPropertiesFunction() { | 47 ~NetworkingPrivateGetPropertiesFunction() { |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool NetworkingPrivateGetPropertiesFunction::RunAsync() { | 50 bool NetworkingPrivateGetPropertiesFunction::RunAsync() { |
| 51 scoped_ptr<private_api::GetProperties::Params> params = | 51 scoped_ptr<private_api::GetProperties::Params> params = |
| 52 private_api::GetProperties::Params::Create(*args_); | 52 private_api::GetProperties::Params::Create(*args_); |
| 53 EXTENSION_FUNCTION_VALIDATE(params); | 53 EXTENSION_FUNCTION_VALIDATE(params); |
| 54 | 54 |
| 55 GetDelegate(browser_context())->GetProperties( | 55 GetDelegate(browser_context()) |
| 56 params->network_guid, | 56 ->GetProperties( |
| 57 base::Bind(&NetworkingPrivateGetPropertiesFunction::Success, this), | 57 params->network_guid, |
| 58 base::Bind(&NetworkingPrivateGetPropertiesFunction::Failure, this)); | 58 base::Bind(&NetworkingPrivateGetPropertiesFunction::Success, this), |
| 59 base::Bind(&NetworkingPrivateGetPropertiesFunction::Failure, this)); |
| 59 return true; | 60 return true; |
| 60 } | 61 } |
| 61 | 62 |
| 62 void NetworkingPrivateGetPropertiesFunction::Success( | 63 void NetworkingPrivateGetPropertiesFunction::Success( |
| 63 scoped_ptr<base::DictionaryValue> result) { | 64 scoped_ptr<base::DictionaryValue> result) { |
| 64 SetResult(result.release()); | 65 SetResult(result.release()); |
| 65 SendResponse(true); | 66 SendResponse(true); |
| 66 } | 67 } |
| 67 | 68 |
| 68 void NetworkingPrivateGetPropertiesFunction::Failure(const std::string& error) { | 69 void NetworkingPrivateGetPropertiesFunction::Failure(const std::string& error) { |
| 69 error_ = error; | 70 error_ = error; |
| 70 SendResponse(false); | 71 SendResponse(false); |
| 71 } | 72 } |
| 72 | 73 |
| 73 //////////////////////////////////////////////////////////////////////////////// | 74 //////////////////////////////////////////////////////////////////////////////// |
| 74 // NetworkingPrivateGetManagedPropertiesFunction | 75 // NetworkingPrivateGetManagedPropertiesFunction |
| 75 | 76 |
| 76 NetworkingPrivateGetManagedPropertiesFunction:: | 77 NetworkingPrivateGetManagedPropertiesFunction:: |
| 77 ~NetworkingPrivateGetManagedPropertiesFunction() { | 78 ~NetworkingPrivateGetManagedPropertiesFunction() { |
| 78 } | 79 } |
| 79 | 80 |
| 80 bool NetworkingPrivateGetManagedPropertiesFunction::RunAsync() { | 81 bool NetworkingPrivateGetManagedPropertiesFunction::RunAsync() { |
| 81 scoped_ptr<private_api::GetManagedProperties::Params> params = | 82 scoped_ptr<private_api::GetManagedProperties::Params> params = |
| 82 private_api::GetManagedProperties::Params::Create(*args_); | 83 private_api::GetManagedProperties::Params::Create(*args_); |
| 83 EXTENSION_FUNCTION_VALIDATE(params); | 84 EXTENSION_FUNCTION_VALIDATE(params); |
| 84 | 85 |
| 85 GetDelegate(browser_context())->GetManagedProperties( | 86 GetDelegate(browser_context()) |
| 86 params->network_guid, | 87 ->GetManagedProperties( |
| 87 base::Bind(&NetworkingPrivateGetManagedPropertiesFunction::Success, this), | 88 params->network_guid, |
| 88 base::Bind(&NetworkingPrivateGetManagedPropertiesFunction::Failure, | 89 base::Bind(&NetworkingPrivateGetManagedPropertiesFunction::Success, |
| 89 this)); | 90 this), |
| 91 base::Bind(&NetworkingPrivateGetManagedPropertiesFunction::Failure, |
| 92 this)); |
| 90 return true; | 93 return true; |
| 91 } | 94 } |
| 92 | 95 |
| 93 void NetworkingPrivateGetManagedPropertiesFunction::Success( | 96 void NetworkingPrivateGetManagedPropertiesFunction::Success( |
| 94 scoped_ptr<base::DictionaryValue> result) { | 97 scoped_ptr<base::DictionaryValue> result) { |
| 95 SetResult(result.release()); | 98 SetResult(result.release()); |
| 96 SendResponse(true); | 99 SendResponse(true); |
| 97 } | 100 } |
| 98 | 101 |
| 99 void NetworkingPrivateGetManagedPropertiesFunction::Failure( | 102 void NetworkingPrivateGetManagedPropertiesFunction::Failure( |
| 100 const std::string& error) { | 103 const std::string& error) { |
| 101 error_ = error; | 104 error_ = error; |
| 102 SendResponse(false); | 105 SendResponse(false); |
| 103 } | 106 } |
| 104 | 107 |
| 105 //////////////////////////////////////////////////////////////////////////////// | 108 //////////////////////////////////////////////////////////////////////////////// |
| 106 // NetworkingPrivateGetStateFunction | 109 // NetworkingPrivateGetStateFunction |
| 107 | 110 |
| 108 NetworkingPrivateGetStateFunction::~NetworkingPrivateGetStateFunction() { | 111 NetworkingPrivateGetStateFunction::~NetworkingPrivateGetStateFunction() { |
| 109 } | 112 } |
| 110 | 113 |
| 111 bool NetworkingPrivateGetStateFunction::RunAsync() { | 114 bool NetworkingPrivateGetStateFunction::RunAsync() { |
| 112 scoped_ptr<private_api::GetState::Params> params = | 115 scoped_ptr<private_api::GetState::Params> params = |
| 113 private_api::GetState::Params::Create(*args_); | 116 private_api::GetState::Params::Create(*args_); |
| 114 EXTENSION_FUNCTION_VALIDATE(params); | 117 EXTENSION_FUNCTION_VALIDATE(params); |
| 115 | 118 |
| 116 GetDelegate(browser_context())->GetState( | 119 GetDelegate(browser_context()) |
| 117 params->network_guid, | 120 ->GetState(params->network_guid, |
| 118 base::Bind(&NetworkingPrivateGetStateFunction::Success, this), | 121 base::Bind(&NetworkingPrivateGetStateFunction::Success, this), |
| 119 base::Bind(&NetworkingPrivateGetStateFunction::Failure, this)); | 122 base::Bind(&NetworkingPrivateGetStateFunction::Failure, this)); |
| 120 return true; | 123 return true; |
| 121 } | 124 } |
| 122 | 125 |
| 123 void NetworkingPrivateGetStateFunction::Success( | 126 void NetworkingPrivateGetStateFunction::Success( |
| 124 scoped_ptr<base::DictionaryValue> result) { | 127 scoped_ptr<base::DictionaryValue> result) { |
| 125 SetResult(result.release()); | 128 SetResult(result.release()); |
| 126 SendResponse(true); | 129 SendResponse(true); |
| 127 } | 130 } |
| 128 | 131 |
| 129 void NetworkingPrivateGetStateFunction::Failure(const std::string& error) { | 132 void NetworkingPrivateGetStateFunction::Failure(const std::string& error) { |
| 130 error_ = error; | 133 error_ = error; |
| 131 SendResponse(false); | 134 SendResponse(false); |
| 132 } | 135 } |
| 133 | 136 |
| 134 //////////////////////////////////////////////////////////////////////////////// | 137 //////////////////////////////////////////////////////////////////////////////// |
| 135 // NetworkingPrivateSetPropertiesFunction | 138 // NetworkingPrivateSetPropertiesFunction |
| 136 | 139 |
| 137 NetworkingPrivateSetPropertiesFunction:: | 140 NetworkingPrivateSetPropertiesFunction:: |
| 138 ~NetworkingPrivateSetPropertiesFunction() { | 141 ~NetworkingPrivateSetPropertiesFunction() { |
| 139 } | 142 } |
| 140 | 143 |
| 141 bool NetworkingPrivateSetPropertiesFunction::RunAsync() { | 144 bool NetworkingPrivateSetPropertiesFunction::RunAsync() { |
| 142 scoped_ptr<private_api::SetProperties::Params> params = | 145 scoped_ptr<private_api::SetProperties::Params> params = |
| 143 private_api::SetProperties::Params::Create(*args_); | 146 private_api::SetProperties::Params::Create(*args_); |
| 144 EXTENSION_FUNCTION_VALIDATE(params); | 147 EXTENSION_FUNCTION_VALIDATE(params); |
| 145 | 148 |
| 146 scoped_ptr<base::DictionaryValue> properties_dict( | 149 scoped_ptr<base::DictionaryValue> properties_dict( |
| 147 params->properties.ToValue()); | 150 params->properties.ToValue()); |
| 148 | 151 |
| 149 GetDelegate(browser_context())->SetProperties( | 152 GetDelegate(browser_context()) |
| 150 params->network_guid, | 153 ->SetProperties( |
| 151 properties_dict.Pass(), | 154 params->network_guid, properties_dict.Pass(), |
| 152 base::Bind(&NetworkingPrivateSetPropertiesFunction::Success, this), | 155 base::Bind(&NetworkingPrivateSetPropertiesFunction::Success, this), |
| 153 base::Bind(&NetworkingPrivateSetPropertiesFunction::Failure, this)); | 156 base::Bind(&NetworkingPrivateSetPropertiesFunction::Failure, this)); |
| 154 return true; | 157 return true; |
| 155 } | 158 } |
| 156 | 159 |
| 157 void NetworkingPrivateSetPropertiesFunction::Success() { | 160 void NetworkingPrivateSetPropertiesFunction::Success() { |
| 158 SendResponse(true); | 161 SendResponse(true); |
| 159 } | 162 } |
| 160 | 163 |
| 161 void NetworkingPrivateSetPropertiesFunction::Failure(const std::string& error) { | 164 void NetworkingPrivateSetPropertiesFunction::Failure(const std::string& error) { |
| 162 error_ = error; | 165 error_ = error; |
| 163 SendResponse(false); | 166 SendResponse(false); |
| 164 } | 167 } |
| 165 | 168 |
| 166 //////////////////////////////////////////////////////////////////////////////// | 169 //////////////////////////////////////////////////////////////////////////////// |
| 167 // NetworkingPrivateCreateNetworkFunction | 170 // NetworkingPrivateCreateNetworkFunction |
| 168 | 171 |
| 169 NetworkingPrivateCreateNetworkFunction:: | 172 NetworkingPrivateCreateNetworkFunction:: |
| 170 ~NetworkingPrivateCreateNetworkFunction() { | 173 ~NetworkingPrivateCreateNetworkFunction() { |
| 171 } | 174 } |
| 172 | 175 |
| 173 bool NetworkingPrivateCreateNetworkFunction::RunAsync() { | 176 bool NetworkingPrivateCreateNetworkFunction::RunAsync() { |
| 174 scoped_ptr<private_api::CreateNetwork::Params> params = | 177 scoped_ptr<private_api::CreateNetwork::Params> params = |
| 175 private_api::CreateNetwork::Params::Create(*args_); | 178 private_api::CreateNetwork::Params::Create(*args_); |
| 176 EXTENSION_FUNCTION_VALIDATE(params); | 179 EXTENSION_FUNCTION_VALIDATE(params); |
| 177 | 180 |
| 178 scoped_ptr<base::DictionaryValue> properties_dict( | 181 scoped_ptr<base::DictionaryValue> properties_dict( |
| 179 params->properties.ToValue()); | 182 params->properties.ToValue()); |
| 180 | 183 |
| 181 GetDelegate(browser_context())->CreateNetwork( | 184 GetDelegate(browser_context()) |
| 182 params->shared, | 185 ->CreateNetwork( |
| 183 properties_dict.Pass(), | 186 params->shared, properties_dict.Pass(), |
| 184 base::Bind(&NetworkingPrivateCreateNetworkFunction::Success, this), | 187 base::Bind(&NetworkingPrivateCreateNetworkFunction::Success, this), |
| 185 base::Bind(&NetworkingPrivateCreateNetworkFunction::Failure, this)); | 188 base::Bind(&NetworkingPrivateCreateNetworkFunction::Failure, this)); |
| 186 return true; | 189 return true; |
| 187 } | 190 } |
| 188 | 191 |
| 189 void NetworkingPrivateCreateNetworkFunction::Success(const std::string& guid) { | 192 void NetworkingPrivateCreateNetworkFunction::Success(const std::string& guid) { |
| 190 results_ = private_api::CreateNetwork::Results::Create(guid); | 193 results_ = private_api::CreateNetwork::Results::Create(guid); |
| 191 SendResponse(true); | 194 SendResponse(true); |
| 192 } | 195 } |
| 193 | 196 |
| 194 void NetworkingPrivateCreateNetworkFunction::Failure(const std::string& error) { | 197 void NetworkingPrivateCreateNetworkFunction::Failure(const std::string& error) { |
| 195 error_ = error; | 198 error_ = error; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 208 EXTENSION_FUNCTION_VALIDATE(params); | 211 EXTENSION_FUNCTION_VALIDATE(params); |
| 209 | 212 |
| 210 std::string network_type = private_api::ToString(params->filter.network_type); | 213 std::string network_type = private_api::ToString(params->filter.network_type); |
| 211 const bool configured_only = | 214 const bool configured_only = |
| 212 params->filter.configured ? *params->filter.configured : false; | 215 params->filter.configured ? *params->filter.configured : false; |
| 213 const bool visible_only = | 216 const bool visible_only = |
| 214 params->filter.visible ? *params->filter.visible : false; | 217 params->filter.visible ? *params->filter.visible : false; |
| 215 const int limit = | 218 const int limit = |
| 216 params->filter.limit ? *params->filter.limit : kDefaultNetworkListLimit; | 219 params->filter.limit ? *params->filter.limit : kDefaultNetworkListLimit; |
| 217 | 220 |
| 218 GetDelegate(browser_context())->GetNetworks( | 221 GetDelegate(browser_context()) |
| 219 network_type, | 222 ->GetNetworks( |
| 220 configured_only, | 223 network_type, configured_only, visible_only, limit, |
| 221 visible_only, | 224 base::Bind(&NetworkingPrivateGetNetworksFunction::Success, this), |
| 222 limit, | 225 base::Bind(&NetworkingPrivateGetNetworksFunction::Failure, this)); |
| 223 base::Bind(&NetworkingPrivateGetNetworksFunction::Success, this), | |
| 224 base::Bind(&NetworkingPrivateGetNetworksFunction::Failure, this)); | |
| 225 return true; | 226 return true; |
| 226 } | 227 } |
| 227 | 228 |
| 228 void NetworkingPrivateGetNetworksFunction::Success( | 229 void NetworkingPrivateGetNetworksFunction::Success( |
| 229 scoped_ptr<base::ListValue> network_list) { | 230 scoped_ptr<base::ListValue> network_list) { |
| 230 SetResult(network_list.release()); | 231 SetResult(network_list.release()); |
| 231 SendResponse(true); | 232 SendResponse(true); |
| 232 } | 233 } |
| 233 | 234 |
| 234 void NetworkingPrivateGetNetworksFunction::Failure(const std::string& error) { | 235 void NetworkingPrivateGetNetworksFunction::Failure(const std::string& error) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 245 | 246 |
| 246 bool NetworkingPrivateGetVisibleNetworksFunction::RunAsync() { | 247 bool NetworkingPrivateGetVisibleNetworksFunction::RunAsync() { |
| 247 scoped_ptr<private_api::GetVisibleNetworks::Params> params = | 248 scoped_ptr<private_api::GetVisibleNetworks::Params> params = |
| 248 private_api::GetVisibleNetworks::Params::Create(*args_); | 249 private_api::GetVisibleNetworks::Params::Create(*args_); |
| 249 EXTENSION_FUNCTION_VALIDATE(params); | 250 EXTENSION_FUNCTION_VALIDATE(params); |
| 250 | 251 |
| 251 std::string network_type = private_api::ToString(params->network_type); | 252 std::string network_type = private_api::ToString(params->network_type); |
| 252 const bool configured_only = false; | 253 const bool configured_only = false; |
| 253 const bool visible_only = true; | 254 const bool visible_only = true; |
| 254 | 255 |
| 255 GetDelegate(browser_context())->GetNetworks( | 256 GetDelegate(browser_context()) |
| 256 network_type, | 257 ->GetNetworks( |
| 257 configured_only, | 258 network_type, configured_only, visible_only, kDefaultNetworkListLimit, |
| 258 visible_only, | 259 base::Bind(&NetworkingPrivateGetVisibleNetworksFunction::Success, |
| 259 kDefaultNetworkListLimit, | 260 this), |
| 260 base::Bind(&NetworkingPrivateGetVisibleNetworksFunction::Success, this), | 261 base::Bind(&NetworkingPrivateGetVisibleNetworksFunction::Failure, |
| 261 base::Bind(&NetworkingPrivateGetVisibleNetworksFunction::Failure, this)); | 262 this)); |
| 262 return true; | 263 return true; |
| 263 } | 264 } |
| 264 | 265 |
| 265 void NetworkingPrivateGetVisibleNetworksFunction::Success( | 266 void NetworkingPrivateGetVisibleNetworksFunction::Success( |
| 266 scoped_ptr<base::ListValue> network_properties_list) { | 267 scoped_ptr<base::ListValue> network_properties_list) { |
| 267 SetResult(network_properties_list.release()); | 268 SetResult(network_properties_list.release()); |
| 268 SendResponse(true); | 269 SendResponse(true); |
| 269 } | 270 } |
| 270 | 271 |
| 271 void NetworkingPrivateGetVisibleNetworksFunction::Failure( | 272 void NetworkingPrivateGetVisibleNetworksFunction::Failure( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 288 error_ = networking_private::kErrorNotSupported; | 289 error_ = networking_private::kErrorNotSupported; |
| 289 return false; | 290 return false; |
| 290 } | 291 } |
| 291 scoped_ptr<base::ListValue> enabled_networks_list(new base::ListValue); | 292 scoped_ptr<base::ListValue> enabled_networks_list(new base::ListValue); |
| 292 for (base::ListValue::iterator iter = enabled_networks_onc_types->begin(); | 293 for (base::ListValue::iterator iter = enabled_networks_onc_types->begin(); |
| 293 iter != enabled_networks_onc_types->end(); ++iter) { | 294 iter != enabled_networks_onc_types->end(); ++iter) { |
| 294 std::string type; | 295 std::string type; |
| 295 if (!(*iter)->GetAsString(&type)) | 296 if (!(*iter)->GetAsString(&type)) |
| 296 NOTREACHED(); | 297 NOTREACHED(); |
| 297 if (type == ::onc::network_type::kEthernet) { | 298 if (type == ::onc::network_type::kEthernet) { |
| 298 enabled_networks_list->AppendString(api::networking_private::ToString( | 299 enabled_networks_list->AppendString( |
| 299 api::networking_private::NETWORK_TYPE_ETHERNET)); | 300 private_api::ToString(private_api::NETWORK_TYPE_ETHERNET)); |
| 300 } else if (type == ::onc::network_type::kWiFi) { | 301 } else if (type == ::onc::network_type::kWiFi) { |
| 301 enabled_networks_list->AppendString(api::networking_private::ToString( | 302 enabled_networks_list->AppendString( |
| 302 api::networking_private::NETWORK_TYPE_WIFI)); | 303 private_api::ToString(private_api::NETWORK_TYPE_WIFI)); |
| 303 } else if (type == ::onc::network_type::kWimax) { | 304 } else if (type == ::onc::network_type::kWimax) { |
| 304 enabled_networks_list->AppendString(api::networking_private::ToString( | 305 enabled_networks_list->AppendString( |
| 305 api::networking_private::NETWORK_TYPE_WIMAX)); | 306 private_api::ToString(private_api::NETWORK_TYPE_WIMAX)); |
| 306 } else if (type == ::onc::network_type::kCellular) { | 307 } else if (type == ::onc::network_type::kCellular) { |
| 307 enabled_networks_list->AppendString(api::networking_private::ToString( | 308 enabled_networks_list->AppendString( |
| 308 api::networking_private::NETWORK_TYPE_CELLULAR)); | 309 private_api::ToString(private_api::NETWORK_TYPE_CELLULAR)); |
| 309 } else { | 310 } else { |
| 310 LOG(ERROR) << "networkingPrivate: Unexpected type: " << type; | 311 LOG(ERROR) << "networkingPrivate: Unexpected type: " << type; |
| 311 } | 312 } |
| 312 } | 313 } |
| 313 SetResult(enabled_networks_list.release()); | 314 SetResult(enabled_networks_list.release()); |
| 314 return true; | 315 return true; |
| 315 } | 316 } |
| 316 | 317 |
| 317 //////////////////////////////////////////////////////////////////////////////// | 318 //////////////////////////////////////////////////////////////////////////////// |
| 318 // NetworkingPrivateEnableNetworkTypeFunction | 319 // NetworkingPrivateEnableNetworkTypeFunction |
| 319 | 320 |
| 320 NetworkingPrivateEnableNetworkTypeFunction:: | 321 NetworkingPrivateEnableNetworkTypeFunction:: |
| 321 ~NetworkingPrivateEnableNetworkTypeFunction() { | 322 ~NetworkingPrivateEnableNetworkTypeFunction() { |
| 322 } | 323 } |
| 323 | 324 |
| 324 bool NetworkingPrivateEnableNetworkTypeFunction::RunSync() { | 325 bool NetworkingPrivateEnableNetworkTypeFunction::RunSync() { |
| 325 scoped_ptr<private_api::EnableNetworkType::Params> params = | 326 scoped_ptr<private_api::EnableNetworkType::Params> params = |
| 326 private_api::EnableNetworkType::Params::Create(*args_); | 327 private_api::EnableNetworkType::Params::Create(*args_); |
| 327 EXTENSION_FUNCTION_VALIDATE(params); | 328 EXTENSION_FUNCTION_VALIDATE(params); |
| 328 | 329 |
| 329 return GetDelegate(browser_context())->EnableNetworkType( | 330 return GetDelegate(browser_context()) |
| 330 private_api::ToString(params->network_type)); | 331 ->EnableNetworkType(private_api::ToString(params->network_type)); |
| 331 } | 332 } |
| 332 | 333 |
| 333 //////////////////////////////////////////////////////////////////////////////// | 334 //////////////////////////////////////////////////////////////////////////////// |
| 334 // NetworkingPrivateDisableNetworkTypeFunction | 335 // NetworkingPrivateDisableNetworkTypeFunction |
| 335 | 336 |
| 336 NetworkingPrivateDisableNetworkTypeFunction:: | 337 NetworkingPrivateDisableNetworkTypeFunction:: |
| 337 ~NetworkingPrivateDisableNetworkTypeFunction() { | 338 ~NetworkingPrivateDisableNetworkTypeFunction() { |
| 338 } | 339 } |
| 339 | 340 |
| 340 bool NetworkingPrivateDisableNetworkTypeFunction::RunSync() { | 341 bool NetworkingPrivateDisableNetworkTypeFunction::RunSync() { |
| 341 scoped_ptr<private_api::DisableNetworkType::Params> params = | 342 scoped_ptr<private_api::DisableNetworkType::Params> params = |
| 342 private_api::DisableNetworkType::Params::Create(*args_); | 343 private_api::DisableNetworkType::Params::Create(*args_); |
| 343 | 344 |
| 344 return GetDelegate(browser_context())->DisableNetworkType( | 345 return GetDelegate(browser_context()) |
| 345 private_api::ToString(params->network_type)); | 346 ->DisableNetworkType(private_api::ToString(params->network_type)); |
| 346 } | 347 } |
| 347 | 348 |
| 348 //////////////////////////////////////////////////////////////////////////////// | 349 //////////////////////////////////////////////////////////////////////////////// |
| 349 // NetworkingPrivateRequestNetworkScanFunction | 350 // NetworkingPrivateRequestNetworkScanFunction |
| 350 | 351 |
| 351 NetworkingPrivateRequestNetworkScanFunction:: | 352 NetworkingPrivateRequestNetworkScanFunction:: |
| 352 ~NetworkingPrivateRequestNetworkScanFunction() { | 353 ~NetworkingPrivateRequestNetworkScanFunction() { |
| 353 } | 354 } |
| 354 | 355 |
| 355 bool NetworkingPrivateRequestNetworkScanFunction::RunSync() { | 356 bool NetworkingPrivateRequestNetworkScanFunction::RunSync() { |
| 356 return GetDelegate(browser_context())->RequestScan(); | 357 return GetDelegate(browser_context())->RequestScan(); |
| 357 } | 358 } |
| 358 | 359 |
| 359 //////////////////////////////////////////////////////////////////////////////// | 360 //////////////////////////////////////////////////////////////////////////////// |
| 360 // NetworkingPrivateStartConnectFunction | 361 // NetworkingPrivateStartConnectFunction |
| 361 | 362 |
| 362 NetworkingPrivateStartConnectFunction:: | 363 NetworkingPrivateStartConnectFunction:: |
| 363 ~NetworkingPrivateStartConnectFunction() { | 364 ~NetworkingPrivateStartConnectFunction() { |
| 364 } | 365 } |
| 365 | 366 |
| 366 bool NetworkingPrivateStartConnectFunction::RunAsync() { | 367 bool NetworkingPrivateStartConnectFunction::RunAsync() { |
| 367 scoped_ptr<private_api::StartConnect::Params> params = | 368 scoped_ptr<private_api::StartConnect::Params> params = |
| 368 private_api::StartConnect::Params::Create(*args_); | 369 private_api::StartConnect::Params::Create(*args_); |
| 369 EXTENSION_FUNCTION_VALIDATE(params); | 370 EXTENSION_FUNCTION_VALIDATE(params); |
| 370 | 371 |
| 371 GetDelegate(browser_context())->StartConnect( | 372 GetDelegate(browser_context()) |
| 372 params->network_guid, | 373 ->StartConnect( |
| 373 base::Bind(&NetworkingPrivateStartConnectFunction::Success, this), | 374 params->network_guid, |
| 374 base::Bind(&NetworkingPrivateStartConnectFunction::Failure, this)); | 375 base::Bind(&NetworkingPrivateStartConnectFunction::Success, this), |
| 376 base::Bind(&NetworkingPrivateStartConnectFunction::Failure, this)); |
| 375 return true; | 377 return true; |
| 376 } | 378 } |
| 377 | 379 |
| 378 void NetworkingPrivateStartConnectFunction::Success() { | 380 void NetworkingPrivateStartConnectFunction::Success() { |
| 379 SendResponse(true); | 381 SendResponse(true); |
| 380 } | 382 } |
| 381 | 383 |
| 382 void NetworkingPrivateStartConnectFunction::Failure(const std::string& error) { | 384 void NetworkingPrivateStartConnectFunction::Failure(const std::string& error) { |
| 383 error_ = error; | 385 error_ = error; |
| 384 SendResponse(false); | 386 SendResponse(false); |
| 385 } | 387 } |
| 386 | 388 |
| 387 //////////////////////////////////////////////////////////////////////////////// | 389 //////////////////////////////////////////////////////////////////////////////// |
| 388 // NetworkingPrivateStartDisconnectFunction | 390 // NetworkingPrivateStartDisconnectFunction |
| 389 | 391 |
| 390 NetworkingPrivateStartDisconnectFunction:: | 392 NetworkingPrivateStartDisconnectFunction:: |
| 391 ~NetworkingPrivateStartDisconnectFunction() { | 393 ~NetworkingPrivateStartDisconnectFunction() { |
| 392 } | 394 } |
| 393 | 395 |
| 394 bool NetworkingPrivateStartDisconnectFunction::RunAsync() { | 396 bool NetworkingPrivateStartDisconnectFunction::RunAsync() { |
| 395 scoped_ptr<private_api::StartDisconnect::Params> params = | 397 scoped_ptr<private_api::StartDisconnect::Params> params = |
| 396 private_api::StartDisconnect::Params::Create(*args_); | 398 private_api::StartDisconnect::Params::Create(*args_); |
| 397 EXTENSION_FUNCTION_VALIDATE(params); | 399 EXTENSION_FUNCTION_VALIDATE(params); |
| 398 | 400 |
| 399 GetDelegate(browser_context())->StartDisconnect( | 401 GetDelegate(browser_context()) |
| 400 params->network_guid, | 402 ->StartDisconnect( |
| 401 base::Bind(&NetworkingPrivateStartDisconnectFunction::Success, this), | 403 params->network_guid, |
| 402 base::Bind(&NetworkingPrivateStartDisconnectFunction::Failure, this)); | 404 base::Bind(&NetworkingPrivateStartDisconnectFunction::Success, this), |
| 405 base::Bind(&NetworkingPrivateStartDisconnectFunction::Failure, this)); |
| 403 return true; | 406 return true; |
| 404 } | 407 } |
| 405 | 408 |
| 406 void NetworkingPrivateStartDisconnectFunction::Success() { | 409 void NetworkingPrivateStartDisconnectFunction::Success() { |
| 407 SendResponse(true); | 410 SendResponse(true); |
| 408 } | 411 } |
| 409 | 412 |
| 410 void NetworkingPrivateStartDisconnectFunction::Failure( | 413 void NetworkingPrivateStartDisconnectFunction::Failure( |
| 411 const std::string& error) { | 414 const std::string& error) { |
| 412 error_ = error; | 415 error_ = error; |
| 413 SendResponse(false); | 416 SendResponse(false); |
| 414 } | 417 } |
| 415 | 418 |
| 416 //////////////////////////////////////////////////////////////////////////////// | 419 //////////////////////////////////////////////////////////////////////////////// |
| 417 // NetworkingPrivateVerifyDestinationFunction | 420 // NetworkingPrivateVerifyDestinationFunction |
| 418 | 421 |
| 419 NetworkingPrivateVerifyDestinationFunction:: | 422 NetworkingPrivateVerifyDestinationFunction:: |
| 420 ~NetworkingPrivateVerifyDestinationFunction() { | 423 ~NetworkingPrivateVerifyDestinationFunction() { |
| 421 } | 424 } |
| 422 | 425 |
| 423 bool NetworkingPrivateVerifyDestinationFunction::RunAsync() { | 426 bool NetworkingPrivateVerifyDestinationFunction::RunAsync() { |
| 424 scoped_ptr<private_api::VerifyDestination::Params> params = | 427 scoped_ptr<private_api::VerifyDestination::Params> params = |
| 425 private_api::VerifyDestination::Params::Create(*args_); | 428 private_api::VerifyDestination::Params::Create(*args_); |
| 426 EXTENSION_FUNCTION_VALIDATE(params); | 429 EXTENSION_FUNCTION_VALIDATE(params); |
| 427 | 430 |
| 428 GetDelegate(browser_context())->VerifyDestination( | 431 GetDelegate(browser_context()) |
| 429 params->properties, | 432 ->VerifyDestination( |
| 430 base::Bind(&NetworkingPrivateVerifyDestinationFunction::Success, this), | 433 params->properties, |
| 431 base::Bind(&NetworkingPrivateVerifyDestinationFunction::Failure, this)); | 434 base::Bind(&NetworkingPrivateVerifyDestinationFunction::Success, |
| 435 this), |
| 436 base::Bind(&NetworkingPrivateVerifyDestinationFunction::Failure, |
| 437 this)); |
| 432 return true; | 438 return true; |
| 433 } | 439 } |
| 434 | 440 |
| 435 void NetworkingPrivateVerifyDestinationFunction::Success(bool result) { | 441 void NetworkingPrivateVerifyDestinationFunction::Success(bool result) { |
| 436 results_ = private_api::VerifyDestination::Results::Create(result); | 442 results_ = private_api::VerifyDestination::Results::Create(result); |
| 437 SendResponse(true); | 443 SendResponse(true); |
| 438 } | 444 } |
| 439 | 445 |
| 440 void NetworkingPrivateVerifyDestinationFunction::Failure( | 446 void NetworkingPrivateVerifyDestinationFunction::Failure( |
| 441 const std::string& error) { | 447 const std::string& error) { |
| 442 error_ = error; | 448 error_ = error; |
| 443 SendResponse(false); | 449 SendResponse(false); |
| 444 } | 450 } |
| 445 | 451 |
| 446 //////////////////////////////////////////////////////////////////////////////// | 452 //////////////////////////////////////////////////////////////////////////////// |
| 447 // NetworkingPrivateVerifyAndEncryptCredentialsFunction | 453 // NetworkingPrivateVerifyAndEncryptCredentialsFunction |
| 448 | 454 |
| 449 NetworkingPrivateVerifyAndEncryptCredentialsFunction:: | 455 NetworkingPrivateVerifyAndEncryptCredentialsFunction:: |
| 450 ~NetworkingPrivateVerifyAndEncryptCredentialsFunction() { | 456 ~NetworkingPrivateVerifyAndEncryptCredentialsFunction() { |
| 451 } | 457 } |
| 452 | 458 |
| 453 bool NetworkingPrivateVerifyAndEncryptCredentialsFunction::RunAsync() { | 459 bool NetworkingPrivateVerifyAndEncryptCredentialsFunction::RunAsync() { |
| 454 scoped_ptr<private_api::VerifyAndEncryptCredentials::Params> params = | 460 scoped_ptr<private_api::VerifyAndEncryptCredentials::Params> params = |
| 455 private_api::VerifyAndEncryptCredentials::Params::Create(*args_); | 461 private_api::VerifyAndEncryptCredentials::Params::Create(*args_); |
| 456 EXTENSION_FUNCTION_VALIDATE(params); | 462 EXTENSION_FUNCTION_VALIDATE(params); |
| 457 | 463 |
| 458 GetDelegate(browser_context())->VerifyAndEncryptCredentials( | 464 GetDelegate(browser_context()) |
| 459 params->network_guid, | 465 ->VerifyAndEncryptCredentials( |
| 460 params->properties, | 466 params->network_guid, params->properties, |
| 461 base::Bind(&NetworkingPrivateVerifyAndEncryptCredentialsFunction::Success, | 467 base::Bind( |
| 462 this), | 468 &NetworkingPrivateVerifyAndEncryptCredentialsFunction::Success, |
| 463 base::Bind(&NetworkingPrivateVerifyAndEncryptCredentialsFunction::Failure, | 469 this), |
| 464 this)); | 470 base::Bind( |
| 471 &NetworkingPrivateVerifyAndEncryptCredentialsFunction::Failure, |
| 472 this)); |
| 465 return true; | 473 return true; |
| 466 } | 474 } |
| 467 | 475 |
| 468 void NetworkingPrivateVerifyAndEncryptCredentialsFunction::Success( | 476 void NetworkingPrivateVerifyAndEncryptCredentialsFunction::Success( |
| 469 const std::string& result) { | 477 const std::string& result) { |
| 470 results_ = private_api::VerifyAndEncryptCredentials::Results::Create(result); | 478 results_ = private_api::VerifyAndEncryptCredentials::Results::Create(result); |
| 471 SendResponse(true); | 479 SendResponse(true); |
| 472 } | 480 } |
| 473 | 481 |
| 474 void NetworkingPrivateVerifyAndEncryptCredentialsFunction::Failure( | 482 void NetworkingPrivateVerifyAndEncryptCredentialsFunction::Failure( |
| 475 const std::string& error) { | 483 const std::string& error) { |
| 476 error_ = error; | 484 error_ = error; |
| 477 SendResponse(false); | 485 SendResponse(false); |
| 478 } | 486 } |
| 479 | 487 |
| 480 //////////////////////////////////////////////////////////////////////////////// | 488 //////////////////////////////////////////////////////////////////////////////// |
| 481 // NetworkingPrivateVerifyAndEncryptDataFunction | 489 // NetworkingPrivateVerifyAndEncryptDataFunction |
| 482 | 490 |
| 483 NetworkingPrivateVerifyAndEncryptDataFunction:: | 491 NetworkingPrivateVerifyAndEncryptDataFunction:: |
| 484 ~NetworkingPrivateVerifyAndEncryptDataFunction() { | 492 ~NetworkingPrivateVerifyAndEncryptDataFunction() { |
| 485 } | 493 } |
| 486 | 494 |
| 487 bool NetworkingPrivateVerifyAndEncryptDataFunction::RunAsync() { | 495 bool NetworkingPrivateVerifyAndEncryptDataFunction::RunAsync() { |
| 488 scoped_ptr<private_api::VerifyAndEncryptData::Params> params = | 496 scoped_ptr<private_api::VerifyAndEncryptData::Params> params = |
| 489 private_api::VerifyAndEncryptData::Params::Create(*args_); | 497 private_api::VerifyAndEncryptData::Params::Create(*args_); |
| 490 EXTENSION_FUNCTION_VALIDATE(params); | 498 EXTENSION_FUNCTION_VALIDATE(params); |
| 491 | 499 |
| 492 GetDelegate(browser_context())->VerifyAndEncryptData( | 500 GetDelegate(browser_context()) |
| 493 params->properties, | 501 ->VerifyAndEncryptData( |
| 494 params->data, | 502 params->properties, params->data, |
| 495 base::Bind(&NetworkingPrivateVerifyAndEncryptDataFunction::Success, this), | 503 base::Bind(&NetworkingPrivateVerifyAndEncryptDataFunction::Success, |
| 496 base::Bind(&NetworkingPrivateVerifyAndEncryptDataFunction::Failure, | 504 this), |
| 497 this)); | 505 base::Bind(&NetworkingPrivateVerifyAndEncryptDataFunction::Failure, |
| 506 this)); |
| 498 return true; | 507 return true; |
| 499 } | 508 } |
| 500 | 509 |
| 501 void NetworkingPrivateVerifyAndEncryptDataFunction::Success( | 510 void NetworkingPrivateVerifyAndEncryptDataFunction::Success( |
| 502 const std::string& result) { | 511 const std::string& result) { |
| 503 results_ = private_api::VerifyAndEncryptData::Results::Create(result); | 512 results_ = private_api::VerifyAndEncryptData::Results::Create(result); |
| 504 SendResponse(true); | 513 SendResponse(true); |
| 505 } | 514 } |
| 506 | 515 |
| 507 void NetworkingPrivateVerifyAndEncryptDataFunction::Failure( | 516 void NetworkingPrivateVerifyAndEncryptDataFunction::Failure( |
| 508 const std::string& error) { | 517 const std::string& error) { |
| 509 error_ = error; | 518 error_ = error; |
| 510 SendResponse(false); | 519 SendResponse(false); |
| 511 } | 520 } |
| 512 | 521 |
| 513 //////////////////////////////////////////////////////////////////////////////// | 522 //////////////////////////////////////////////////////////////////////////////// |
| 514 // NetworkingPrivateSetWifiTDLSEnabledStateFunction | 523 // NetworkingPrivateSetWifiTDLSEnabledStateFunction |
| 515 | 524 |
| 516 NetworkingPrivateSetWifiTDLSEnabledStateFunction:: | 525 NetworkingPrivateSetWifiTDLSEnabledStateFunction:: |
| 517 ~NetworkingPrivateSetWifiTDLSEnabledStateFunction() { | 526 ~NetworkingPrivateSetWifiTDLSEnabledStateFunction() { |
| 518 } | 527 } |
| 519 | 528 |
| 520 bool NetworkingPrivateSetWifiTDLSEnabledStateFunction::RunAsync() { | 529 bool NetworkingPrivateSetWifiTDLSEnabledStateFunction::RunAsync() { |
| 521 scoped_ptr<private_api::SetWifiTDLSEnabledState::Params> params = | 530 scoped_ptr<private_api::SetWifiTDLSEnabledState::Params> params = |
| 522 private_api::SetWifiTDLSEnabledState::Params::Create(*args_); | 531 private_api::SetWifiTDLSEnabledState::Params::Create(*args_); |
| 523 EXTENSION_FUNCTION_VALIDATE(params); | 532 EXTENSION_FUNCTION_VALIDATE(params); |
| 524 | 533 |
| 525 GetDelegate(browser_context())->SetWifiTDLSEnabledState( | 534 GetDelegate(browser_context()) |
| 526 params->ip_or_mac_address, | 535 ->SetWifiTDLSEnabledState( |
| 527 params->enabled, | 536 params->ip_or_mac_address, params->enabled, |
| 528 base::Bind(&NetworkingPrivateSetWifiTDLSEnabledStateFunction::Success, | 537 base::Bind(&NetworkingPrivateSetWifiTDLSEnabledStateFunction::Success, |
| 529 this), | 538 this), |
| 530 base::Bind(&NetworkingPrivateSetWifiTDLSEnabledStateFunction::Failure, | 539 base::Bind(&NetworkingPrivateSetWifiTDLSEnabledStateFunction::Failure, |
| 531 this)); | 540 this)); |
| 532 | 541 |
| 533 return true; | 542 return true; |
| 534 } | 543 } |
| 535 | 544 |
| 536 void NetworkingPrivateSetWifiTDLSEnabledStateFunction::Success( | 545 void NetworkingPrivateSetWifiTDLSEnabledStateFunction::Success( |
| 537 const std::string& result) { | 546 const std::string& result) { |
| 538 results_ = private_api::SetWifiTDLSEnabledState::Results::Create(result); | 547 results_ = private_api::SetWifiTDLSEnabledState::Results::Create(result); |
| 539 SendResponse(true); | 548 SendResponse(true); |
| 540 } | 549 } |
| 541 | 550 |
| 542 void NetworkingPrivateSetWifiTDLSEnabledStateFunction::Failure( | 551 void NetworkingPrivateSetWifiTDLSEnabledStateFunction::Failure( |
| 543 const std::string& error) { | 552 const std::string& error) { |
| 544 error_ = error; | 553 error_ = error; |
| 545 SendResponse(false); | 554 SendResponse(false); |
| 546 } | 555 } |
| 547 | 556 |
| 548 //////////////////////////////////////////////////////////////////////////////// | 557 //////////////////////////////////////////////////////////////////////////////// |
| 549 // NetworkingPrivateGetWifiTDLSStatusFunction | 558 // NetworkingPrivateGetWifiTDLSStatusFunction |
| 550 | 559 |
| 551 NetworkingPrivateGetWifiTDLSStatusFunction:: | 560 NetworkingPrivateGetWifiTDLSStatusFunction:: |
| 552 ~NetworkingPrivateGetWifiTDLSStatusFunction() { | 561 ~NetworkingPrivateGetWifiTDLSStatusFunction() { |
| 553 } | 562 } |
| 554 | 563 |
| 555 bool NetworkingPrivateGetWifiTDLSStatusFunction::RunAsync() { | 564 bool NetworkingPrivateGetWifiTDLSStatusFunction::RunAsync() { |
| 556 scoped_ptr<private_api::GetWifiTDLSStatus::Params> params = | 565 scoped_ptr<private_api::GetWifiTDLSStatus::Params> params = |
| 557 private_api::GetWifiTDLSStatus::Params::Create(*args_); | 566 private_api::GetWifiTDLSStatus::Params::Create(*args_); |
| 558 EXTENSION_FUNCTION_VALIDATE(params); | 567 EXTENSION_FUNCTION_VALIDATE(params); |
| 559 | 568 |
| 560 GetDelegate(browser_context())->GetWifiTDLSStatus( | 569 GetDelegate(browser_context()) |
| 561 params->ip_or_mac_address, | 570 ->GetWifiTDLSStatus( |
| 562 base::Bind(&NetworkingPrivateGetWifiTDLSStatusFunction::Success, this), | 571 params->ip_or_mac_address, |
| 563 base::Bind(&NetworkingPrivateGetWifiTDLSStatusFunction::Failure, this)); | 572 base::Bind(&NetworkingPrivateGetWifiTDLSStatusFunction::Success, |
| 573 this), |
| 574 base::Bind(&NetworkingPrivateGetWifiTDLSStatusFunction::Failure, |
| 575 this)); |
| 564 | 576 |
| 565 return true; | 577 return true; |
| 566 } | 578 } |
| 567 | 579 |
| 568 void NetworkingPrivateGetWifiTDLSStatusFunction::Success( | 580 void NetworkingPrivateGetWifiTDLSStatusFunction::Success( |
| 569 const std::string& result) { | 581 const std::string& result) { |
| 570 results_ = private_api::GetWifiTDLSStatus::Results::Create(result); | 582 results_ = private_api::GetWifiTDLSStatus::Results::Create(result); |
| 571 SendResponse(true); | 583 SendResponse(true); |
| 572 } | 584 } |
| 573 | 585 |
| 574 void NetworkingPrivateGetWifiTDLSStatusFunction::Failure( | 586 void NetworkingPrivateGetWifiTDLSStatusFunction::Failure( |
| 575 const std::string& error) { | 587 const std::string& error) { |
| 576 error_ = error; | 588 error_ = error; |
| 577 SendResponse(false); | 589 SendResponse(false); |
| 578 } | 590 } |
| 579 | 591 |
| 580 //////////////////////////////////////////////////////////////////////////////// | 592 //////////////////////////////////////////////////////////////////////////////// |
| 581 // NetworkingPrivateGetCaptivePortalStatusFunction | 593 // NetworkingPrivateGetCaptivePortalStatusFunction |
| 582 | 594 |
| 583 NetworkingPrivateGetCaptivePortalStatusFunction:: | 595 NetworkingPrivateGetCaptivePortalStatusFunction:: |
| 584 ~NetworkingPrivateGetCaptivePortalStatusFunction() { | 596 ~NetworkingPrivateGetCaptivePortalStatusFunction() { |
| 585 } | 597 } |
| 586 | 598 |
| 587 bool NetworkingPrivateGetCaptivePortalStatusFunction::RunAsync() { | 599 bool NetworkingPrivateGetCaptivePortalStatusFunction::RunAsync() { |
| 588 scoped_ptr<private_api::GetCaptivePortalStatus::Params> params = | 600 scoped_ptr<private_api::GetCaptivePortalStatus::Params> params = |
| 589 private_api::GetCaptivePortalStatus::Params::Create(*args_); | 601 private_api::GetCaptivePortalStatus::Params::Create(*args_); |
| 590 EXTENSION_FUNCTION_VALIDATE(params); | 602 EXTENSION_FUNCTION_VALIDATE(params); |
| 591 | 603 |
| 592 GetDelegate(browser_context())->GetCaptivePortalStatus( | 604 GetDelegate(browser_context()) |
| 593 params->network_guid, | 605 ->GetCaptivePortalStatus( |
| 594 base::Bind(&NetworkingPrivateGetCaptivePortalStatusFunction::Success, | 606 params->network_guid, |
| 595 this), | 607 base::Bind(&NetworkingPrivateGetCaptivePortalStatusFunction::Success, |
| 596 base::Bind(&NetworkingPrivateGetCaptivePortalStatusFunction::Failure, | 608 this), |
| 597 this)); | 609 base::Bind(&NetworkingPrivateGetCaptivePortalStatusFunction::Failure, |
| 610 this)); |
| 598 return true; | 611 return true; |
| 599 } | 612 } |
| 600 | 613 |
| 601 void NetworkingPrivateGetCaptivePortalStatusFunction::Success( | 614 void NetworkingPrivateGetCaptivePortalStatusFunction::Success( |
| 602 const std::string& result) { | 615 const std::string& result) { |
| 603 results_ = private_api::GetCaptivePortalStatus::Results::Create( | 616 results_ = private_api::GetCaptivePortalStatus::Results::Create( |
| 604 private_api::ParseCaptivePortalStatus(result)); | 617 private_api::ParseCaptivePortalStatus(result)); |
| 605 SendResponse(true); | 618 SendResponse(true); |
| 606 } | 619 } |
| 607 | 620 |
| 608 void NetworkingPrivateGetCaptivePortalStatusFunction::Failure( | 621 void NetworkingPrivateGetCaptivePortalStatusFunction::Failure( |
| 609 const std::string& error) { | 622 const std::string& error) { |
| 610 error_ = error; | 623 error_ = error; |
| 611 SendResponse(false); | 624 SendResponse(false); |
| 612 } | 625 } |
| 613 | 626 |
| 614 } // namespace extensions | 627 } // namespace extensions |
| OLD | NEW |