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