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 "device/usb/usb_device_filter.h" | 5 #include "device/usb/usb_device_filter.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "device/usb/usb_descriptors.h" | |
9 #include "device/usb/usb_device.h" | 8 #include "device/usb/usb_device.h" |
10 | 9 |
11 namespace device { | 10 namespace device { |
12 | 11 |
13 namespace { | 12 namespace { |
14 | 13 |
15 const char kProductIdKey[] = "productId"; | 14 const char kProductIdKey[] = "productId"; |
16 const char kVendorIdKey[] = "vendorId"; | 15 const char kVendorIdKey[] = "vendorId"; |
17 const char kInterfaceClassKey[] = "interfaceClass"; | 16 const char kInterfaceClassKey[] = "interfaceClass"; |
18 const char kInterfaceSubclassKey[] = "interfaceSubclass"; | 17 const char kInterfaceSubclassKey[] = "interfaceSubclass"; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 if (device->vendor_id() != vendor_id_) { | 60 if (device->vendor_id() != vendor_id_) { |
62 return false; | 61 return false; |
63 } | 62 } |
64 | 63 |
65 if (product_id_set_ && device->product_id() != product_id_) { | 64 if (product_id_set_ && device->product_id() != product_id_) { |
66 return false; | 65 return false; |
67 } | 66 } |
68 } | 67 } |
69 | 68 |
70 if (interface_class_set_) { | 69 if (interface_class_set_) { |
71 const UsbConfigDescriptor* config = device->GetConfiguration(); | 70 const UsbConfigDescriptor* config = device->GetActiveConfiguration(); |
72 if (!config) { | 71 if (!config) { |
73 return false; | 72 return false; |
74 } | 73 } |
75 | 74 |
76 // TODO(reillyg): Check device configuration if the class is not defined at | 75 // TODO(reillyg): Check device configuration if the class is not defined at |
77 // a per-interface level. This is not really important because most devices | 76 // a per-interface level. This is not really important because most devices |
78 // have per-interface classes. The only counter-examples I know of are hubs. | 77 // have per-interface classes. The only counter-examples I know of are hubs. |
79 | 78 |
80 bool foundMatch = false; | 79 bool foundMatch = false; |
81 for (const UsbInterfaceDescriptor& iface : config->interfaces) { | 80 for (const UsbInterfaceDescriptor& iface : config->interfaces) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 i != filters.end(); | 125 i != filters.end(); |
127 ++i) { | 126 ++i) { |
128 if (i->Matches(device)) { | 127 if (i->Matches(device)) { |
129 return true; | 128 return true; |
130 } | 129 } |
131 } | 130 } |
132 return false; | 131 return false; |
133 } | 132 } |
134 | 133 |
135 } // namespace device | 134 } // namespace device |
OLD | NEW |