| 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/usb/usb_api.h" | 5 #include "extensions/browser/api/usb/usb_api.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <numeric> | 9 #include <numeric> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 service->GetDevices( | 588 service->GetDevices( |
| 589 base::Bind(&UsbGetDevicesFunction::OnGetDevicesComplete, this)); | 589 base::Bind(&UsbGetDevicesFunction::OnGetDevicesComplete, this)); |
| 590 return RespondLater(); | 590 return RespondLater(); |
| 591 } | 591 } |
| 592 | 592 |
| 593 void UsbGetDevicesFunction::OnGetDevicesComplete( | 593 void UsbGetDevicesFunction::OnGetDevicesComplete( |
| 594 const std::vector<scoped_refptr<UsbDevice>>& devices) { | 594 const std::vector<scoped_refptr<UsbDevice>>& devices) { |
| 595 std::unique_ptr<base::ListValue> result(new base::ListValue()); | 595 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
| 596 UsbGuidMap* guid_map = UsbGuidMap::Get(browser_context()); | 596 UsbGuidMap* guid_map = UsbGuidMap::Get(browser_context()); |
| 597 for (const scoped_refptr<UsbDevice>& device : devices) { | 597 for (const scoped_refptr<UsbDevice>& device : devices) { |
| 598 if ((filters_.empty() || UsbDeviceFilter::MatchesAny(device, filters_)) && | 598 if (UsbDeviceFilter::MatchesAny(device, filters_) && |
| 599 HasDevicePermission(device)) { | 599 HasDevicePermission(device)) { |
| 600 Device api_device; | 600 Device api_device; |
| 601 guid_map->GetApiDevice(device, &api_device); | 601 guid_map->GetApiDevice(device, &api_device); |
| 602 result->Append(api_device.ToValue()); | 602 result->Append(api_device.ToValue()); |
| 603 } | 603 } |
| 604 } | 604 } |
| 605 | 605 |
| 606 Respond(OneArgument(std::move(result))); | 606 Respond(OneArgument(std::move(result))); |
| 607 } | 607 } |
| 608 | 608 |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 | 1271 |
| 1272 std::unique_ptr<base::ListValue> error_args(new base::ListValue()); | 1272 std::unique_ptr<base::ListValue> error_args(new base::ListValue()); |
| 1273 error_args->AppendBoolean(false); | 1273 error_args->AppendBoolean(false); |
| 1274 // Using ErrorWithArguments is discouraged but required to maintain | 1274 // Using ErrorWithArguments is discouraged but required to maintain |
| 1275 // compatibility with existing applications. | 1275 // compatibility with existing applications. |
| 1276 Respond(ErrorWithArguments(std::move(error_args), kErrorResetDevice)); | 1276 Respond(ErrorWithArguments(std::move(error_args), kErrorResetDevice)); |
| 1277 } | 1277 } |
| 1278 } | 1278 } |
| 1279 | 1279 |
| 1280 } // namespace extensions | 1280 } // namespace extensions |
| OLD | NEW |