OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/browser/api/networking_private/networking_private_api.h" | 5 #include "extensions/browser/api/networking_private/networking_private_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "components/onc/onc_constants.h" | 10 #include "components/onc/onc_constants.h" |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 private_api::ToString(private_api::NETWORK_TYPE_CELLULAR)); | 338 private_api::ToString(private_api::NETWORK_TYPE_CELLULAR)); |
339 } else { | 339 } else { |
340 LOG(ERROR) << "networkingPrivate: Unexpected type: " << type; | 340 LOG(ERROR) << "networkingPrivate: Unexpected type: " << type; |
341 } | 341 } |
342 } | 342 } |
343 SetResult(enabled_networks_list.release()); | 343 SetResult(enabled_networks_list.release()); |
344 return true; | 344 return true; |
345 } | 345 } |
346 | 346 |
347 //////////////////////////////////////////////////////////////////////////////// | 347 //////////////////////////////////////////////////////////////////////////////// |
| 348 // NetworkingPrivateGetDeviceStatesFunction |
| 349 |
| 350 NetworkingPrivateGetDeviceStatesFunction:: |
| 351 ~NetworkingPrivateGetDeviceStatesFunction() { |
| 352 } |
| 353 |
| 354 bool NetworkingPrivateGetDeviceStatesFunction::RunSync() { |
| 355 scoped_ptr<NetworkingPrivateDelegate::DeviceStateList> device_states( |
| 356 GetDelegate(browser_context())->GetDeviceStateList()); |
| 357 if (!device_states) { |
| 358 error_ = networking_private::kErrorNotSupported; |
| 359 return false; |
| 360 } |
| 361 |
| 362 scoped_ptr<base::ListValue> device_state_list(new base::ListValue); |
| 363 for (const private_api::DeviceStateProperties* properties : *device_states) |
| 364 device_state_list->Append(properties->ToValue().release()); |
| 365 SetResult(device_state_list.release()); |
| 366 return true; |
| 367 } |
| 368 |
| 369 //////////////////////////////////////////////////////////////////////////////// |
348 // NetworkingPrivateEnableNetworkTypeFunction | 370 // NetworkingPrivateEnableNetworkTypeFunction |
349 | 371 |
350 NetworkingPrivateEnableNetworkTypeFunction:: | 372 NetworkingPrivateEnableNetworkTypeFunction:: |
351 ~NetworkingPrivateEnableNetworkTypeFunction() { | 373 ~NetworkingPrivateEnableNetworkTypeFunction() { |
352 } | 374 } |
353 | 375 |
354 bool NetworkingPrivateEnableNetworkTypeFunction::RunSync() { | 376 bool NetworkingPrivateEnableNetworkTypeFunction::RunSync() { |
355 scoped_ptr<private_api::EnableNetworkType::Params> params = | 377 scoped_ptr<private_api::EnableNetworkType::Params> params = |
356 private_api::EnableNetworkType::Params::Create(*args_); | 378 private_api::EnableNetworkType::Params::Create(*args_); |
357 EXTENSION_FUNCTION_VALIDATE(params); | 379 EXTENSION_FUNCTION_VALIDATE(params); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 SendResponse(true); | 698 SendResponse(true); |
677 } | 699 } |
678 | 700 |
679 void NetworkingPrivateGetCaptivePortalStatusFunction::Failure( | 701 void NetworkingPrivateGetCaptivePortalStatusFunction::Failure( |
680 const std::string& error) { | 702 const std::string& error) { |
681 error_ = error; | 703 error_ = error; |
682 SendResponse(false); | 704 SendResponse(false); |
683 } | 705 } |
684 | 706 |
685 } // namespace extensions | 707 } // namespace extensions |
OLD | NEW |