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
3 // found in the LICENSE file.
5 #include "extensions/browser/api/networking_private/networking_private_api.h"
8 #include "base/bind_helpers.h"
9 #include "base/callback.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"
13 #include "extensions/browser/extension_function_registry.h"
14 #include "extensions/common/api/networking_private.h"
18 const int kDefaultNetworkListLimit
= 1000;
20 extensions::NetworkingPrivateDelegate
* GetDelegate(
21 content::BrowserContext
* browser_context
) {
22 return extensions::NetworkingPrivateDelegateFactory::GetForBrowserContext(
28 namespace extensions
{
30 namespace private_api
= api::networking_private
;
32 namespace networking_private
{
35 const char kErrorInvalidNetworkGuid
[] = "Error.InvalidNetworkGuid";
36 const char kErrorInvalidNetworkOperation
[] = "Error.InvalidNetworkOperation";
37 const char kErrorNetworkUnavailable
[] = "Error.NetworkUnavailable";
38 const char kErrorEncryptionError
[] = "Error.EncryptionError";
39 const char kErrorNotReady
[] = "Error.NotReady";
40 const char kErrorNotSupported
[] = "Error.NotSupported";
41 const char kErrorSimLocked
[] = "Error.SimLocked";
43 } // namespace networking_private
45 ////////////////////////////////////////////////////////////////////////////////
46 // NetworkingPrivateGetPropertiesFunction
48 NetworkingPrivateGetPropertiesFunction::
49 ~NetworkingPrivateGetPropertiesFunction() {
52 bool NetworkingPrivateGetPropertiesFunction::RunAsync() {
53 scoped_ptr
<private_api::GetProperties::Params
> params
=
54 private_api::GetProperties::Params::Create(*args_
);
55 EXTENSION_FUNCTION_VALIDATE(params
);
57 GetDelegate(browser_context())
60 base::Bind(&NetworkingPrivateGetPropertiesFunction::Success
, this),
61 base::Bind(&NetworkingPrivateGetPropertiesFunction::Failure
, this));
65 void NetworkingPrivateGetPropertiesFunction::Success(
66 scoped_ptr
<base::DictionaryValue
> result
) {
67 SetResult(result
.release());
71 void NetworkingPrivateGetPropertiesFunction::Failure(const std::string
& error
) {
76 ////////////////////////////////////////////////////////////////////////////////
77 // NetworkingPrivateGetManagedPropertiesFunction
79 NetworkingPrivateGetManagedPropertiesFunction::
80 ~NetworkingPrivateGetManagedPropertiesFunction() {
83 bool NetworkingPrivateGetManagedPropertiesFunction::RunAsync() {
84 scoped_ptr
<private_api::GetManagedProperties::Params
> params
=
85 private_api::GetManagedProperties::Params::Create(*args_
);
86 EXTENSION_FUNCTION_VALIDATE(params
);
88 GetDelegate(browser_context())
89 ->GetManagedProperties(
91 base::Bind(&NetworkingPrivateGetManagedPropertiesFunction::Success
,
93 base::Bind(&NetworkingPrivateGetManagedPropertiesFunction::Failure
,
98 void NetworkingPrivateGetManagedPropertiesFunction::Success(
99 scoped_ptr
<base::DictionaryValue
> result
) {
100 SetResult(result
.release());
104 void NetworkingPrivateGetManagedPropertiesFunction::Failure(
105 const std::string
& error
) {
110 ////////////////////////////////////////////////////////////////////////////////
111 // NetworkingPrivateGetStateFunction
113 NetworkingPrivateGetStateFunction::~NetworkingPrivateGetStateFunction() {
116 bool NetworkingPrivateGetStateFunction::RunAsync() {
117 scoped_ptr
<private_api::GetState::Params
> params
=
118 private_api::GetState::Params::Create(*args_
);
119 EXTENSION_FUNCTION_VALIDATE(params
);
121 GetDelegate(browser_context())
122 ->GetState(params
->network_guid
,
123 base::Bind(&NetworkingPrivateGetStateFunction::Success
, this),
124 base::Bind(&NetworkingPrivateGetStateFunction::Failure
, this));
128 void NetworkingPrivateGetStateFunction::Success(
129 scoped_ptr
<base::DictionaryValue
> result
) {
130 SetResult(result
.release());
134 void NetworkingPrivateGetStateFunction::Failure(const std::string
& error
) {
139 ////////////////////////////////////////////////////////////////////////////////
140 // NetworkingPrivateSetPropertiesFunction
142 NetworkingPrivateSetPropertiesFunction::
143 ~NetworkingPrivateSetPropertiesFunction() {
146 bool NetworkingPrivateSetPropertiesFunction::RunAsync() {
147 scoped_ptr
<private_api::SetProperties::Params
> params
=
148 private_api::SetProperties::Params::Create(*args_
);
149 EXTENSION_FUNCTION_VALIDATE(params
);
151 scoped_ptr
<base::DictionaryValue
> properties_dict(
152 params
->properties
.ToValue());
154 GetDelegate(browser_context())
156 params
->network_guid
, properties_dict
.Pass(),
157 base::Bind(&NetworkingPrivateSetPropertiesFunction::Success
, this),
158 base::Bind(&NetworkingPrivateSetPropertiesFunction::Failure
, this));
162 void NetworkingPrivateSetPropertiesFunction::Success() {
166 void NetworkingPrivateSetPropertiesFunction::Failure(const std::string
& error
) {
171 ////////////////////////////////////////////////////////////////////////////////
172 // NetworkingPrivateCreateNetworkFunction
174 NetworkingPrivateCreateNetworkFunction::
175 ~NetworkingPrivateCreateNetworkFunction() {
178 bool NetworkingPrivateCreateNetworkFunction::RunAsync() {
179 scoped_ptr
<private_api::CreateNetwork::Params
> params
=
180 private_api::CreateNetwork::Params::Create(*args_
);
181 EXTENSION_FUNCTION_VALIDATE(params
);
183 scoped_ptr
<base::DictionaryValue
> properties_dict(
184 params
->properties
.ToValue());
186 GetDelegate(browser_context())
188 params
->shared
, properties_dict
.Pass(),
189 base::Bind(&NetworkingPrivateCreateNetworkFunction::Success
, this),
190 base::Bind(&NetworkingPrivateCreateNetworkFunction::Failure
, this));
194 void NetworkingPrivateCreateNetworkFunction::Success(const std::string
& guid
) {
195 results_
= private_api::CreateNetwork::Results::Create(guid
);
199 void NetworkingPrivateCreateNetworkFunction::Failure(const std::string
& error
) {
204 ////////////////////////////////////////////////////////////////////////////////
205 // NetworkingPrivateForgetNetworkFunction
207 NetworkingPrivateForgetNetworkFunction::
208 ~NetworkingPrivateForgetNetworkFunction() {
211 bool NetworkingPrivateForgetNetworkFunction::RunAsync() {
212 scoped_ptr
<private_api::ForgetNetwork::Params
> params
=
213 private_api::ForgetNetwork::Params::Create(*args_
);
214 EXTENSION_FUNCTION_VALIDATE(params
);
216 GetDelegate(browser_context())
218 params
->network_guid
,
219 base::Bind(&NetworkingPrivateForgetNetworkFunction::Success
, this),
220 base::Bind(&NetworkingPrivateForgetNetworkFunction::Failure
, this));
224 void NetworkingPrivateForgetNetworkFunction::Success() {
228 void NetworkingPrivateForgetNetworkFunction::Failure(const std::string
& error
) {
233 ////////////////////////////////////////////////////////////////////////////////
234 // NetworkingPrivateGetNetworksFunction
236 NetworkingPrivateGetNetworksFunction::~NetworkingPrivateGetNetworksFunction() {
239 bool NetworkingPrivateGetNetworksFunction::RunAsync() {
240 scoped_ptr
<private_api::GetNetworks::Params
> params
=
241 private_api::GetNetworks::Params::Create(*args_
);
242 EXTENSION_FUNCTION_VALIDATE(params
);
244 std::string network_type
= private_api::ToString(params
->filter
.network_type
);
245 const bool configured_only
=
246 params
->filter
.configured
? *params
->filter
.configured
: false;
247 const bool visible_only
=
248 params
->filter
.visible
? *params
->filter
.visible
: false;
250 params
->filter
.limit
? *params
->filter
.limit
: kDefaultNetworkListLimit
;
252 GetDelegate(browser_context())
254 network_type
, configured_only
, visible_only
, limit
,
255 base::Bind(&NetworkingPrivateGetNetworksFunction::Success
, this),
256 base::Bind(&NetworkingPrivateGetNetworksFunction::Failure
, this));
260 void NetworkingPrivateGetNetworksFunction::Success(
261 scoped_ptr
<base::ListValue
> network_list
) {
262 SetResult(network_list
.release());
266 void NetworkingPrivateGetNetworksFunction::Failure(const std::string
& error
) {
271 ////////////////////////////////////////////////////////////////////////////////
272 // NetworkingPrivateGetVisibleNetworksFunction
274 NetworkingPrivateGetVisibleNetworksFunction::
275 ~NetworkingPrivateGetVisibleNetworksFunction() {
278 bool NetworkingPrivateGetVisibleNetworksFunction::RunAsync() {
279 scoped_ptr
<private_api::GetVisibleNetworks::Params
> params
=
280 private_api::GetVisibleNetworks::Params::Create(*args_
);
281 EXTENSION_FUNCTION_VALIDATE(params
);
283 std::string network_type
= private_api::ToString(params
->network_type
);
284 const bool configured_only
= false;
285 const bool visible_only
= true;
287 GetDelegate(browser_context())
289 network_type
, configured_only
, visible_only
, kDefaultNetworkListLimit
,
290 base::Bind(&NetworkingPrivateGetVisibleNetworksFunction::Success
,
292 base::Bind(&NetworkingPrivateGetVisibleNetworksFunction::Failure
,
297 void NetworkingPrivateGetVisibleNetworksFunction::Success(
298 scoped_ptr
<base::ListValue
> network_properties_list
) {
299 SetResult(network_properties_list
.release());
303 void NetworkingPrivateGetVisibleNetworksFunction::Failure(
304 const std::string
& error
) {
309 ////////////////////////////////////////////////////////////////////////////////
310 // NetworkingPrivateGetEnabledNetworkTypesFunction
312 NetworkingPrivateGetEnabledNetworkTypesFunction::
313 ~NetworkingPrivateGetEnabledNetworkTypesFunction() {
316 bool NetworkingPrivateGetEnabledNetworkTypesFunction::RunSync() {
317 scoped_ptr
<base::ListValue
> enabled_networks_onc_types(
318 GetDelegate(browser_context())->GetEnabledNetworkTypes());
319 if (!enabled_networks_onc_types
) {
320 error_
= networking_private::kErrorNotSupported
;
323 scoped_ptr
<base::ListValue
> enabled_networks_list(new base::ListValue
);
324 for (base::ListValue::iterator iter
= enabled_networks_onc_types
->begin();
325 iter
!= enabled_networks_onc_types
->end(); ++iter
) {
327 if (!(*iter
)->GetAsString(&type
))
329 if (type
== ::onc::network_type::kEthernet
) {
330 enabled_networks_list
->AppendString(
331 private_api::ToString(private_api::NETWORK_TYPE_ETHERNET
));
332 } else if (type
== ::onc::network_type::kWiFi
) {
333 enabled_networks_list
->AppendString(
334 private_api::ToString(private_api::NETWORK_TYPE_WIFI
));
335 } else if (type
== ::onc::network_type::kWimax
) {
336 enabled_networks_list
->AppendString(
337 private_api::ToString(private_api::NETWORK_TYPE_WIMAX
));
338 } else if (type
== ::onc::network_type::kCellular
) {
339 enabled_networks_list
->AppendString(
340 private_api::ToString(private_api::NETWORK_TYPE_CELLULAR
));
342 LOG(ERROR
) << "networkingPrivate: Unexpected type: " << type
;
345 SetResult(enabled_networks_list
.release());
349 ////////////////////////////////////////////////////////////////////////////////
350 // NetworkingPrivateGetDeviceStatesFunction
352 NetworkingPrivateGetDeviceStatesFunction::
353 ~NetworkingPrivateGetDeviceStatesFunction() {
356 bool NetworkingPrivateGetDeviceStatesFunction::RunSync() {
357 scoped_ptr
<NetworkingPrivateDelegate::DeviceStateList
> device_states(
358 GetDelegate(browser_context())->GetDeviceStateList());
359 if (!device_states
) {
360 error_
= networking_private::kErrorNotSupported
;
364 scoped_ptr
<base::ListValue
> device_state_list(new base::ListValue
);
365 for (const private_api::DeviceStateProperties
* properties
: *device_states
)
366 device_state_list
->Append(properties
->ToValue().release());
367 SetResult(device_state_list
.release());
371 ////////////////////////////////////////////////////////////////////////////////
372 // NetworkingPrivateEnableNetworkTypeFunction
374 NetworkingPrivateEnableNetworkTypeFunction::
375 ~NetworkingPrivateEnableNetworkTypeFunction() {
378 bool NetworkingPrivateEnableNetworkTypeFunction::RunSync() {
379 scoped_ptr
<private_api::EnableNetworkType::Params
> params
=
380 private_api::EnableNetworkType::Params::Create(*args_
);
381 EXTENSION_FUNCTION_VALIDATE(params
);
383 return GetDelegate(browser_context())
384 ->EnableNetworkType(private_api::ToString(params
->network_type
));
387 ////////////////////////////////////////////////////////////////////////////////
388 // NetworkingPrivateDisableNetworkTypeFunction
390 NetworkingPrivateDisableNetworkTypeFunction::
391 ~NetworkingPrivateDisableNetworkTypeFunction() {
394 bool NetworkingPrivateDisableNetworkTypeFunction::RunSync() {
395 scoped_ptr
<private_api::DisableNetworkType::Params
> params
=
396 private_api::DisableNetworkType::Params::Create(*args_
);
398 return GetDelegate(browser_context())
399 ->DisableNetworkType(private_api::ToString(params
->network_type
));
402 ////////////////////////////////////////////////////////////////////////////////
403 // NetworkingPrivateRequestNetworkScanFunction
405 NetworkingPrivateRequestNetworkScanFunction::
406 ~NetworkingPrivateRequestNetworkScanFunction() {
409 bool NetworkingPrivateRequestNetworkScanFunction::RunSync() {
410 return GetDelegate(browser_context())->RequestScan();
413 ////////////////////////////////////////////////////////////////////////////////
414 // NetworkingPrivateStartConnectFunction
416 NetworkingPrivateStartConnectFunction::
417 ~NetworkingPrivateStartConnectFunction() {
420 bool NetworkingPrivateStartConnectFunction::RunAsync() {
421 scoped_ptr
<private_api::StartConnect::Params
> params
=
422 private_api::StartConnect::Params::Create(*args_
);
423 EXTENSION_FUNCTION_VALIDATE(params
);
425 GetDelegate(browser_context())
427 params
->network_guid
,
428 base::Bind(&NetworkingPrivateStartConnectFunction::Success
, this),
429 base::Bind(&NetworkingPrivateStartConnectFunction::Failure
, this));
433 void NetworkingPrivateStartConnectFunction::Success() {
437 void NetworkingPrivateStartConnectFunction::Failure(const std::string
& error
) {
442 ////////////////////////////////////////////////////////////////////////////////
443 // NetworkingPrivateStartDisconnectFunction
445 NetworkingPrivateStartDisconnectFunction::
446 ~NetworkingPrivateStartDisconnectFunction() {
449 bool NetworkingPrivateStartDisconnectFunction::RunAsync() {
450 scoped_ptr
<private_api::StartDisconnect::Params
> params
=
451 private_api::StartDisconnect::Params::Create(*args_
);
452 EXTENSION_FUNCTION_VALIDATE(params
);
454 GetDelegate(browser_context())
456 params
->network_guid
,
457 base::Bind(&NetworkingPrivateStartDisconnectFunction::Success
, this),
458 base::Bind(&NetworkingPrivateStartDisconnectFunction::Failure
, this));
462 void NetworkingPrivateStartDisconnectFunction::Success() {
466 void NetworkingPrivateStartDisconnectFunction::Failure(
467 const std::string
& error
) {
472 ////////////////////////////////////////////////////////////////////////////////
473 // NetworkingPrivateStartActivateFunction
475 NetworkingPrivateStartActivateFunction::
476 ~NetworkingPrivateStartActivateFunction() {
479 bool NetworkingPrivateStartActivateFunction::RunAsync() {
480 scoped_ptr
<private_api::StartActivate::Params
> params
=
481 private_api::StartActivate::Params::Create(*args_
);
482 EXTENSION_FUNCTION_VALIDATE(params
);
484 GetDelegate(browser_context())
486 params
->network_guid
, params
->carrier
? *params
->carrier
: "",
487 base::Bind(&NetworkingPrivateStartActivateFunction::Success
, this),
488 base::Bind(&NetworkingPrivateStartActivateFunction::Failure
, this));
492 void NetworkingPrivateStartActivateFunction::Success() {
496 void NetworkingPrivateStartActivateFunction::Failure(const std::string
& error
) {
501 ////////////////////////////////////////////////////////////////////////////////
502 // NetworkingPrivateVerifyDestinationFunction
504 NetworkingPrivateVerifyDestinationFunction::
505 ~NetworkingPrivateVerifyDestinationFunction() {
508 bool NetworkingPrivateVerifyDestinationFunction::RunAsync() {
509 scoped_ptr
<private_api::VerifyDestination::Params
> params
=
510 private_api::VerifyDestination::Params::Create(*args_
);
511 EXTENSION_FUNCTION_VALIDATE(params
);
513 GetDelegate(browser_context())
516 base::Bind(&NetworkingPrivateVerifyDestinationFunction::Success
,
518 base::Bind(&NetworkingPrivateVerifyDestinationFunction::Failure
,
523 void NetworkingPrivateVerifyDestinationFunction::Success(bool result
) {
524 results_
= private_api::VerifyDestination::Results::Create(result
);
528 void NetworkingPrivateVerifyDestinationFunction::Failure(
529 const std::string
& error
) {
534 ////////////////////////////////////////////////////////////////////////////////
535 // NetworkingPrivateVerifyAndEncryptCredentialsFunction
537 NetworkingPrivateVerifyAndEncryptCredentialsFunction::
538 ~NetworkingPrivateVerifyAndEncryptCredentialsFunction() {
541 bool NetworkingPrivateVerifyAndEncryptCredentialsFunction::RunAsync() {
542 scoped_ptr
<private_api::VerifyAndEncryptCredentials::Params
> params
=
543 private_api::VerifyAndEncryptCredentials::Params::Create(*args_
);
544 EXTENSION_FUNCTION_VALIDATE(params
);
546 GetDelegate(browser_context())
547 ->VerifyAndEncryptCredentials(
548 params
->network_guid
, params
->properties
,
550 &NetworkingPrivateVerifyAndEncryptCredentialsFunction::Success
,
553 &NetworkingPrivateVerifyAndEncryptCredentialsFunction::Failure
,
558 void NetworkingPrivateVerifyAndEncryptCredentialsFunction::Success(
559 const std::string
& result
) {
560 results_
= private_api::VerifyAndEncryptCredentials::Results::Create(result
);
564 void NetworkingPrivateVerifyAndEncryptCredentialsFunction::Failure(
565 const std::string
& error
) {
570 ////////////////////////////////////////////////////////////////////////////////
571 // NetworkingPrivateVerifyAndEncryptDataFunction
573 NetworkingPrivateVerifyAndEncryptDataFunction::
574 ~NetworkingPrivateVerifyAndEncryptDataFunction() {
577 bool NetworkingPrivateVerifyAndEncryptDataFunction::RunAsync() {
578 scoped_ptr
<private_api::VerifyAndEncryptData::Params
> params
=
579 private_api::VerifyAndEncryptData::Params::Create(*args_
);
580 EXTENSION_FUNCTION_VALIDATE(params
);
582 GetDelegate(browser_context())
583 ->VerifyAndEncryptData(
584 params
->properties
, params
->data
,
585 base::Bind(&NetworkingPrivateVerifyAndEncryptDataFunction::Success
,
587 base::Bind(&NetworkingPrivateVerifyAndEncryptDataFunction::Failure
,
592 void NetworkingPrivateVerifyAndEncryptDataFunction::Success(
593 const std::string
& result
) {
594 results_
= private_api::VerifyAndEncryptData::Results::Create(result
);
598 void NetworkingPrivateVerifyAndEncryptDataFunction::Failure(
599 const std::string
& error
) {
604 ////////////////////////////////////////////////////////////////////////////////
605 // NetworkingPrivateSetWifiTDLSEnabledStateFunction
607 NetworkingPrivateSetWifiTDLSEnabledStateFunction::
608 ~NetworkingPrivateSetWifiTDLSEnabledStateFunction() {
611 bool NetworkingPrivateSetWifiTDLSEnabledStateFunction::RunAsync() {
612 scoped_ptr
<private_api::SetWifiTDLSEnabledState::Params
> params
=
613 private_api::SetWifiTDLSEnabledState::Params::Create(*args_
);
614 EXTENSION_FUNCTION_VALIDATE(params
);
616 GetDelegate(browser_context())
617 ->SetWifiTDLSEnabledState(
618 params
->ip_or_mac_address
, params
->enabled
,
619 base::Bind(&NetworkingPrivateSetWifiTDLSEnabledStateFunction::Success
,
621 base::Bind(&NetworkingPrivateSetWifiTDLSEnabledStateFunction::Failure
,
627 void NetworkingPrivateSetWifiTDLSEnabledStateFunction::Success(
628 const std::string
& result
) {
629 results_
= private_api::SetWifiTDLSEnabledState::Results::Create(result
);
633 void NetworkingPrivateSetWifiTDLSEnabledStateFunction::Failure(
634 const std::string
& error
) {
639 ////////////////////////////////////////////////////////////////////////////////
640 // NetworkingPrivateGetWifiTDLSStatusFunction
642 NetworkingPrivateGetWifiTDLSStatusFunction::
643 ~NetworkingPrivateGetWifiTDLSStatusFunction() {
646 bool NetworkingPrivateGetWifiTDLSStatusFunction::RunAsync() {
647 scoped_ptr
<private_api::GetWifiTDLSStatus::Params
> params
=
648 private_api::GetWifiTDLSStatus::Params::Create(*args_
);
649 EXTENSION_FUNCTION_VALIDATE(params
);
651 GetDelegate(browser_context())
653 params
->ip_or_mac_address
,
654 base::Bind(&NetworkingPrivateGetWifiTDLSStatusFunction::Success
,
656 base::Bind(&NetworkingPrivateGetWifiTDLSStatusFunction::Failure
,
662 void NetworkingPrivateGetWifiTDLSStatusFunction::Success(
663 const std::string
& result
) {
664 results_
= private_api::GetWifiTDLSStatus::Results::Create(result
);
668 void NetworkingPrivateGetWifiTDLSStatusFunction::Failure(
669 const std::string
& error
) {
674 ////////////////////////////////////////////////////////////////////////////////
675 // NetworkingPrivateGetCaptivePortalStatusFunction
677 NetworkingPrivateGetCaptivePortalStatusFunction::
678 ~NetworkingPrivateGetCaptivePortalStatusFunction() {
681 bool NetworkingPrivateGetCaptivePortalStatusFunction::RunAsync() {
682 scoped_ptr
<private_api::GetCaptivePortalStatus::Params
> params
=
683 private_api::GetCaptivePortalStatus::Params::Create(*args_
);
684 EXTENSION_FUNCTION_VALIDATE(params
);
686 GetDelegate(browser_context())
687 ->GetCaptivePortalStatus(
688 params
->network_guid
,
689 base::Bind(&NetworkingPrivateGetCaptivePortalStatusFunction::Success
,
691 base::Bind(&NetworkingPrivateGetCaptivePortalStatusFunction::Failure
,
696 void NetworkingPrivateGetCaptivePortalStatusFunction::Success(
697 const std::string
& result
) {
698 results_
= private_api::GetCaptivePortalStatus::Results::Create(
699 private_api::ParseCaptivePortalStatus(result
));
703 void NetworkingPrivateGetCaptivePortalStatusFunction::Failure(
704 const std::string
& error
) {
709 ////////////////////////////////////////////////////////////////////////////////
710 // NetworkingPrivateUnlockCellularSimFunction
712 NetworkingPrivateUnlockCellularSimFunction::
713 ~NetworkingPrivateUnlockCellularSimFunction() {}
715 bool NetworkingPrivateUnlockCellularSimFunction::RunAsync() {
716 scoped_ptr
<private_api::UnlockCellularSim::Params
> params
=
717 private_api::UnlockCellularSim::Params::Create(*args_
);
718 EXTENSION_FUNCTION_VALIDATE(params
);
720 GetDelegate(browser_context())
722 params
->network_guid
, params
->pin
, params
->puk
? *params
->puk
: "",
723 base::Bind(&NetworkingPrivateUnlockCellularSimFunction::Success
,
725 base::Bind(&NetworkingPrivateUnlockCellularSimFunction::Failure
,
730 void NetworkingPrivateUnlockCellularSimFunction::Success() {
734 void NetworkingPrivateUnlockCellularSimFunction::Failure(
735 const std::string
& error
) {
740 ////////////////////////////////////////////////////////////////////////////////
741 // NetworkingPrivateSetCellularSimStateFunction
743 NetworkingPrivateSetCellularSimStateFunction::
744 ~NetworkingPrivateSetCellularSimStateFunction() {}
746 bool NetworkingPrivateSetCellularSimStateFunction::RunAsync() {
747 scoped_ptr
<private_api::SetCellularSimState::Params
> params
=
748 private_api::SetCellularSimState::Params::Create(*args_
);
749 EXTENSION_FUNCTION_VALIDATE(params
);
751 GetDelegate(browser_context())
752 ->SetCellularSimState(
753 params
->network_guid
, params
->sim_state
.require_pin
,
754 params
->sim_state
.current_pin
,
755 params
->sim_state
.new_pin
? *params
->sim_state
.new_pin
: "",
756 base::Bind(&NetworkingPrivateSetCellularSimStateFunction::Success
,
758 base::Bind(&NetworkingPrivateSetCellularSimStateFunction::Failure
,
763 void NetworkingPrivateSetCellularSimStateFunction::Success() {
767 void NetworkingPrivateSetCellularSimStateFunction::Failure(
768 const std::string
& error
) {
773 } // namespace extensions