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 <set> | 10 #include <set> |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 service->GetDevices( | 606 service->GetDevices( |
607 base::Bind(&UsbGetDevicesFunction::OnGetDevicesComplete, this)); | 607 base::Bind(&UsbGetDevicesFunction::OnGetDevicesComplete, this)); |
608 return RespondLater(); | 608 return RespondLater(); |
609 } | 609 } |
610 | 610 |
611 void UsbGetDevicesFunction::OnGetDevicesComplete( | 611 void UsbGetDevicesFunction::OnGetDevicesComplete( |
612 const std::vector<scoped_refptr<UsbDevice>>& devices) { | 612 const std::vector<scoped_refptr<UsbDevice>>& devices) { |
613 std::unique_ptr<base::ListValue> result(new base::ListValue()); | 613 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
614 UsbGuidMap* guid_map = UsbGuidMap::Get(browser_context()); | 614 UsbGuidMap* guid_map = UsbGuidMap::Get(browser_context()); |
615 for (const scoped_refptr<UsbDevice>& device : devices) { | 615 for (const scoped_refptr<UsbDevice>& device : devices) { |
616 if (UsbDeviceFilter::MatchesAny(device, filters_) && | 616 if (UsbDeviceFilter::MatchesAny(*device, filters_) && |
617 HasDevicePermission(device)) { | 617 HasDevicePermission(device)) { |
618 Device api_device; | 618 Device api_device; |
619 guid_map->GetApiDevice(device, &api_device); | 619 guid_map->GetApiDevice(device, &api_device); |
620 result->Append(api_device.ToValue()); | 620 result->Append(api_device.ToValue()); |
621 } | 621 } |
622 } | 622 } |
623 | 623 |
624 Respond(OneArgument(std::move(result))); | 624 Respond(OneArgument(std::move(result))); |
625 } | 625 } |
626 | 626 |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1288 | 1288 |
1289 std::unique_ptr<base::ListValue> error_args(new base::ListValue()); | 1289 std::unique_ptr<base::ListValue> error_args(new base::ListValue()); |
1290 error_args->AppendBoolean(false); | 1290 error_args->AppendBoolean(false); |
1291 // Using ErrorWithArguments is discouraged but required to maintain | 1291 // Using ErrorWithArguments is discouraged but required to maintain |
1292 // compatibility with existing applications. | 1292 // compatibility with existing applications. |
1293 Respond(ErrorWithArguments(std::move(error_args), kErrorResetDevice)); | 1293 Respond(ErrorWithArguments(std::move(error_args), kErrorResetDevice)); |
1294 } | 1294 } |
1295 } | 1295 } |
1296 | 1296 |
1297 } // namespace extensions | 1297 } // namespace extensions |
OLD | NEW |