Chromium Code Reviews| 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" |
| 11 #include "extensions/browser/api/networking_private/networking_private_delegate. h" | 11 #include "extensions/browser/api/networking_private/networking_private_delegate. h" |
| 12 #include "extensions/browser/api/networking_private/networking_private_delegate_ factory.h" | 12 #include "extensions/browser/api/networking_private/networking_private_delegate_ factory.h" |
| 13 #include "extensions/browser/extension_function_registry.h" | 13 #include "extensions/browser/extension_function_registry.h" |
| 14 #include "extensions/common/api/networking_private.h" | 14 #include "extensions/common/api/networking_private.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 const int kDefaultNetworkListLimit = 1000; | |
| 19 | |
| 20 extensions::NetworkingPrivateDelegate* GetDelegate( | 18 extensions::NetworkingPrivateDelegate* GetDelegate( |
| 21 content::BrowserContext* browser_context) { | 19 content::BrowserContext* browser_context) { |
| 22 return extensions::NetworkingPrivateDelegateFactory::GetForBrowserContext( | 20 return extensions::NetworkingPrivateDelegateFactory::GetForBrowserContext( |
| 23 browser_context); | 21 browser_context); |
| 24 } | 22 } |
| 25 | 23 |
| 26 } // namespace | 24 } // namespace |
| 27 | 25 |
| 28 namespace extensions { | 26 namespace extensions { |
| 29 | 27 |
| 30 namespace private_api = api::networking_private; | 28 namespace private_api = api::networking_private; |
| 31 | 29 |
| 32 namespace networking_private { | 30 namespace networking_private { |
| 33 | 31 |
| 34 // static | 32 const int kDefaultNetworkListLimit = 1000; |
| 35 const char kErrorInvalidNetworkGuid[] = "Error.InvalidNetworkGuid"; | 33 const char kErrorInvalidNetworkGuid[] = "Error.InvalidNetworkGuid"; |
| 36 const char kErrorInvalidNetworkOperation[] = "Error.InvalidNetworkOperation"; | 34 const char kErrorInvalidNetworkOperation[] = "Error.InvalidNetworkOperation"; |
| 37 const char kErrorNetworkUnavailable[] = "Error.NetworkUnavailable"; | 35 const char kErrorNetworkUnavailable[] = "Error.NetworkUnavailable"; |
| 38 const char kErrorEncryptionError[] = "Error.EncryptionError"; | 36 const char kErrorEncryptionError[] = "Error.EncryptionError"; |
| 39 const char kErrorNotReady[] = "Error.NotReady"; | 37 const char kErrorNotReady[] = "Error.NotReady"; |
| 40 const char kErrorNotSupported[] = "Error.NotSupported"; | 38 const char kErrorNotSupported[] = "Error.NotSupported"; |
| 41 const char kErrorSimLocked[] = "Error.SimLocked"; | 39 const char kErrorSimLocked[] = "Error.SimLocked"; |
| 42 | 40 |
| 43 } // namespace networking_private | 41 } // namespace networking_private |
| 44 | 42 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 bool NetworkingPrivateGetNetworksFunction::RunAsync() { | 237 bool NetworkingPrivateGetNetworksFunction::RunAsync() { |
| 240 scoped_ptr<private_api::GetNetworks::Params> params = | 238 scoped_ptr<private_api::GetNetworks::Params> params = |
| 241 private_api::GetNetworks::Params::Create(*args_); | 239 private_api::GetNetworks::Params::Create(*args_); |
| 242 EXTENSION_FUNCTION_VALIDATE(params); | 240 EXTENSION_FUNCTION_VALIDATE(params); |
| 243 | 241 |
| 244 std::string network_type = private_api::ToString(params->filter.network_type); | 242 std::string network_type = private_api::ToString(params->filter.network_type); |
| 245 const bool configured_only = | 243 const bool configured_only = |
| 246 params->filter.configured ? *params->filter.configured : false; | 244 params->filter.configured ? *params->filter.configured : false; |
| 247 const bool visible_only = | 245 const bool visible_only = |
| 248 params->filter.visible ? *params->filter.visible : false; | 246 params->filter.visible ? *params->filter.visible : false; |
| 249 const int limit = | 247 const int limit = params->filter.limit |
|
pneubeck (no reviews)
2015/08/13 12:58:37
orthogonal change?
| |
| 250 params->filter.limit ? *params->filter.limit : kDefaultNetworkListLimit; | 248 ? *params->filter.limit |
| 249 : networking_private::kDefaultNetworkListLimit; | |
| 251 | 250 |
| 252 GetDelegate(browser_context()) | 251 GetDelegate(browser_context()) |
| 253 ->GetNetworks( | 252 ->GetNetworks( |
| 254 network_type, configured_only, visible_only, limit, | 253 network_type, configured_only, visible_only, limit, |
| 255 base::Bind(&NetworkingPrivateGetNetworksFunction::Success, this), | 254 base::Bind(&NetworkingPrivateGetNetworksFunction::Success, this), |
| 256 base::Bind(&NetworkingPrivateGetNetworksFunction::Failure, this)); | 255 base::Bind(&NetworkingPrivateGetNetworksFunction::Failure, this)); |
| 257 return true; | 256 return true; |
| 258 } | 257 } |
| 259 | 258 |
| 260 void NetworkingPrivateGetNetworksFunction::Success( | 259 void NetworkingPrivateGetNetworksFunction::Success( |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 279 scoped_ptr<private_api::GetVisibleNetworks::Params> params = | 278 scoped_ptr<private_api::GetVisibleNetworks::Params> params = |
| 280 private_api::GetVisibleNetworks::Params::Create(*args_); | 279 private_api::GetVisibleNetworks::Params::Create(*args_); |
| 281 EXTENSION_FUNCTION_VALIDATE(params); | 280 EXTENSION_FUNCTION_VALIDATE(params); |
| 282 | 281 |
| 283 std::string network_type = private_api::ToString(params->network_type); | 282 std::string network_type = private_api::ToString(params->network_type); |
| 284 const bool configured_only = false; | 283 const bool configured_only = false; |
| 285 const bool visible_only = true; | 284 const bool visible_only = true; |
| 286 | 285 |
| 287 GetDelegate(browser_context()) | 286 GetDelegate(browser_context()) |
| 288 ->GetNetworks( | 287 ->GetNetworks( |
| 289 network_type, configured_only, visible_only, kDefaultNetworkListLimit, | 288 network_type, configured_only, visible_only, |
| 289 networking_private::kDefaultNetworkListLimit, | |
| 290 base::Bind(&NetworkingPrivateGetVisibleNetworksFunction::Success, | 290 base::Bind(&NetworkingPrivateGetVisibleNetworksFunction::Success, |
| 291 this), | 291 this), |
| 292 base::Bind(&NetworkingPrivateGetVisibleNetworksFunction::Failure, | 292 base::Bind(&NetworkingPrivateGetVisibleNetworksFunction::Failure, |
| 293 this)); | 293 this)); |
| 294 return true; | 294 return true; |
| 295 } | 295 } |
| 296 | 296 |
| 297 void NetworkingPrivateGetVisibleNetworksFunction::Success( | 297 void NetworkingPrivateGetVisibleNetworksFunction::Success( |
| 298 scoped_ptr<base::ListValue> network_properties_list) { | 298 scoped_ptr<base::ListValue> network_properties_list) { |
| 299 SetResult(network_properties_list.release()); | 299 SetResult(network_properties_list.release()); |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 763 void NetworkingPrivateSetCellularSimStateFunction::Success() { | 763 void NetworkingPrivateSetCellularSimStateFunction::Success() { |
| 764 SendResponse(true); | 764 SendResponse(true); |
| 765 } | 765 } |
| 766 | 766 |
| 767 void NetworkingPrivateSetCellularSimStateFunction::Failure( | 767 void NetworkingPrivateSetCellularSimStateFunction::Failure( |
| 768 const std::string& error) { | 768 const std::string& error) { |
| 769 error_ = error; | 769 error_ = error; |
| 770 SendResponse(false); | 770 SendResponse(false); |
| 771 } | 771 } |
| 772 | 772 |
| 773 //////////////////////////////////////////////////////////////////////////////// | |
| 774 // NetworkingPrivateGetThirdPartyVPNProvidersFunction | |
| 775 | |
| 776 NetworkingPrivateGetThirdPartyVPNProvidersFunction:: | |
| 777 ~NetworkingPrivateGetThirdPartyVPNProvidersFunction() {} | |
| 778 | |
| 779 bool NetworkingPrivateGetThirdPartyVPNProvidersFunction::RunAsync() { | |
| 780 scoped_ptr<base::ListValue> vpn_provider_list = | |
| 781 GetDelegate(browser_context())->GetThirdPartyVpnProviderList(); | |
| 782 SetResult(vpn_provider_list.release()); | |
| 783 SendResponse(true); | |
| 784 return true; | |
| 785 } | |
| 786 | |
| 773 } // namespace extensions | 787 } // namespace extensions |
| OLD | NEW |