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/usb/webusb_descriptors.h" | 5 #include "device/usb/webusb_descriptors.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <iterator> | 9 #include <iterator> |
10 #include <map> | 10 #include <map> |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 scoped_refptr<IOBufferWithSize> buffer = new IOBufferWithSize(5); | 569 scoped_refptr<IOBufferWithSize> buffer = new IOBufferWithSize(5); |
570 device_handle->ControlTransfer( | 570 device_handle->ControlTransfer( |
571 USB_DIRECTION_INBOUND, UsbDeviceHandle::STANDARD, UsbDeviceHandle::DEVICE, | 571 USB_DIRECTION_INBOUND, UsbDeviceHandle::STANDARD, UsbDeviceHandle::DEVICE, |
572 kGetDescriptorRequest, kBosDescriptorType << 8, 0, buffer, buffer->size(), | 572 kGetDescriptorRequest, kBosDescriptorType << 8, 0, buffer, buffer->size(), |
573 kControlTransferTimeout, | 573 kControlTransferTimeout, |
574 base::Bind(&OnReadBosDescriptorHeader, device_handle, callback)); | 574 base::Bind(&OnReadBosDescriptorHeader, device_handle, callback)); |
575 } | 575 } |
576 | 576 |
577 bool FindInWebUsbAllowedOrigins( | 577 bool FindInWebUsbAllowedOrigins( |
578 const device::WebUsbAllowedOrigins* allowed_origins, | 578 const device::WebUsbAllowedOrigins* allowed_origins, |
579 const GURL& origin) { | 579 const GURL& origin, |
| 580 base::Optional<uint8_t> config_value, |
| 581 base::Optional<uint8_t> first_interface) { |
580 if (!allowed_origins) | 582 if (!allowed_origins) |
581 return false; | 583 return false; |
582 | 584 |
583 if (base::ContainsValue(allowed_origins->origins, origin)) | 585 if (base::ContainsValue(allowed_origins->origins, origin)) |
584 return true; | 586 return true; |
585 | 587 |
586 for (const auto& config : allowed_origins->configurations) { | 588 for (const auto& config : allowed_origins->configurations) { |
| 589 if (config_value && *config_value != config.configuration_value) |
| 590 continue; |
| 591 |
587 if (base::ContainsValue(config.origins, origin)) | 592 if (base::ContainsValue(config.origins, origin)) |
588 return true; | 593 return true; |
589 | 594 |
590 for (const auto& function : config.functions) { | 595 for (const auto& function : config.functions) { |
| 596 if (first_interface && *first_interface != function.first_interface) |
| 597 continue; |
| 598 |
591 if (base::ContainsValue(function.origins, origin)) | 599 if (base::ContainsValue(function.origins, origin)) |
592 return true; | 600 return true; |
593 } | 601 } |
594 } | 602 } |
595 | 603 |
596 return false; | 604 return false; |
597 } | 605 } |
598 | 606 |
599 } // namespace device | 607 } // namespace device |
OLD | NEW |