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" | 8 #include "device/usb/usb_descriptors.h" |
9 #include "device/usb/usb_device.h" | 9 #include "device/usb/usb_device.h" |
10 | 10 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 | 90 |
91 if (!foundMatch) { | 91 if (!foundMatch) { |
92 return false; | 92 return false; |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 return true; | 96 return true; |
97 } | 97 } |
98 | 98 |
99 base::Value* UsbDeviceFilter::ToValue() const { | 99 scoped_ptr<base::Value> UsbDeviceFilter::ToValue() const { |
100 scoped_ptr<base::DictionaryValue> obj(new base::DictionaryValue()); | 100 scoped_ptr<base::DictionaryValue> obj(new base::DictionaryValue()); |
101 | 101 |
102 if (vendor_id_set_) { | 102 if (vendor_id_set_) { |
103 obj->SetInteger(kVendorIdKey, vendor_id_); | 103 obj->SetInteger(kVendorIdKey, vendor_id_); |
104 if (product_id_set_) { | 104 if (product_id_set_) { |
105 obj->SetInteger(kProductIdKey, product_id_); | 105 obj->SetInteger(kProductIdKey, product_id_); |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 if (interface_class_set_) { | 109 if (interface_class_set_) { |
110 obj->SetInteger(kInterfaceClassKey, interface_class_); | 110 obj->SetInteger(kInterfaceClassKey, interface_class_); |
111 if (interface_subclass_set_) { | 111 if (interface_subclass_set_) { |
112 obj->SetInteger(kInterfaceSubclassKey, interface_subclass_); | 112 obj->SetInteger(kInterfaceSubclassKey, interface_subclass_); |
113 if (interface_protocol_set_) { | 113 if (interface_protocol_set_) { |
114 obj->SetInteger(kInterfaceProtocolKey, interface_protocol_); | 114 obj->SetInteger(kInterfaceProtocolKey, interface_protocol_); |
115 } | 115 } |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 return obj.release(); | 119 return obj.Pass(); |
120 } | 120 } |
121 | 121 |
122 // static | 122 // static |
123 bool UsbDeviceFilter::MatchesAny(scoped_refptr<UsbDevice> device, | 123 bool UsbDeviceFilter::MatchesAny(scoped_refptr<UsbDevice> device, |
124 const std::vector<UsbDeviceFilter>& filters) { | 124 const std::vector<UsbDeviceFilter>& filters) { |
125 for (std::vector<UsbDeviceFilter>::const_iterator i = filters.begin(); | 125 for (std::vector<UsbDeviceFilter>::const_iterator i = filters.begin(); |
126 i != filters.end(); | 126 i != filters.end(); |
127 ++i) { | 127 ++i) { |
128 if (i->Matches(device)) { | 128 if (i->Matches(device)) { |
129 return true; | 129 return true; |
130 } | 130 } |
131 } | 131 } |
132 return false; | 132 return false; |
133 } | 133 } |
134 | 134 |
135 } // namespace device | 135 } // namespace device |
OLD | NEW |