| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "device/devices_app/usb/device_manager_impl.h" | 5 #include "device/devices_app/usb/device_manager_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 void DeviceManagerImpl::OnGetDevices( | 139 void DeviceManagerImpl::OnGetDevices( |
| 140 EnumerationOptionsPtr options, | 140 EnumerationOptionsPtr options, |
| 141 const GetDevicesCallback& callback, | 141 const GetDevicesCallback& callback, |
| 142 const std::vector<scoped_refptr<UsbDevice>>& devices) { | 142 const std::vector<scoped_refptr<UsbDevice>>& devices) { |
| 143 auto filters = options->filters.To<std::vector<UsbDeviceFilter>>(); | 143 auto filters = options->filters.To<std::vector<UsbDeviceFilter>>(); |
| 144 mojo::Array<DeviceInfoPtr> device_infos(0); | 144 mojo::Array<DeviceInfoPtr> device_infos(0); |
| 145 for (size_t i = 0; i < devices.size(); ++i) { | 145 for (size_t i = 0; i < devices.size(); ++i) { |
| 146 DeviceInfoPtr device_info = DeviceInfo::From(*devices[i]); | 146 DeviceInfoPtr device_info = DeviceInfo::From(*devices[i]); |
| 147 if (UsbDeviceFilter::MatchesAny(devices[i], filters) && | 147 if (UsbDeviceFilter::MatchesAny(devices[i], filters) && |
| 148 delegate_->IsDeviceAllowed(*device_info)) { | 148 delegate_->IsDeviceAllowed(*device_info)) { |
| 149 const UsbConfigDescriptor* config = devices[i]->GetConfiguration(); | 149 const UsbConfigDescriptor* config = devices[i]->GetActiveConfiguration(); |
| 150 device_info->configurations = mojo::Array<ConfigurationInfoPtr>::New(0); | 150 device_info->configurations = mojo::Array<ConfigurationInfoPtr>::New(0); |
| 151 if (config) | 151 if (config) |
| 152 device_info->configurations.push_back(ConfigurationInfo::From(*config)); | 152 device_info->configurations.push_back(ConfigurationInfo::From(*config)); |
| 153 device_infos.push_back(device_info.Pass()); | 153 device_infos.push_back(device_info.Pass()); |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 callback.Run(device_infos.Pass()); | 156 callback.Run(device_infos.Pass()); |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace usb | 159 } // namespace usb |
| 160 } // namespace device | 160 } // namespace device |
| OLD | NEW |