Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: device/usb/webusb_descriptors.cc

Issue 2746313002: Remove RenderFrameHost pointer from ChooserController. (Closed)
Patch Set: Fix Android build and juncai@ comment. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/usb/webusb_descriptors.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « device/usb/webusb_descriptors.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698