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

Side by Side Diff: device/usb/usb_device.h

Issue 1369643002: Add configuration and interface permission checks to DeviceImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add new method ot Android USB mocks. Created 5 years, 3 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
OLDNEW
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 #ifndef DEVICE_USB_USB_DEVICE_H_ 5 #ifndef DEVICE_USB_USB_DEVICE_H_
6 #define DEVICE_USB_USB_DEVICE_H_ 6 #define DEVICE_USB_USB_DEVICE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 26 matching lines...) Expand all
37 uint16_t product_id() const { return product_id_; } 37 uint16_t product_id() const { return product_id_; }
38 const base::string16& manufacturer_string() const { 38 const base::string16& manufacturer_string() const {
39 return manufacturer_string_; 39 return manufacturer_string_;
40 } 40 }
41 const base::string16& product_string() const { return product_string_; } 41 const base::string16& product_string() const { return product_string_; }
42 const base::string16& serial_number() const { return serial_number_; } 42 const base::string16& serial_number() const { return serial_number_; }
43 const WebUsbDescriptorSet* webusb_allowed_origins() const { 43 const WebUsbDescriptorSet* webusb_allowed_origins() const {
44 return webusb_allowed_origins_.get(); 44 return webusb_allowed_origins_.get();
45 } 45 }
46 const GURL& webusb_landing_page() const { return webusb_landing_page_; } 46 const GURL& webusb_landing_page() const { return webusb_landing_page_; }
47 const std::vector<UsbConfigDescriptor>& configurations() const {
48 return configurations_;
49 }
47 50
48 // On ChromeOS the permission_broker service is used to change the ownership 51 // On ChromeOS the permission_broker service is used to change the ownership
49 // of USB device nodes so that Chrome can open them. On other platforms these 52 // of USB device nodes so that Chrome can open them. On other platforms these
50 // functions are no-ops and always return true. 53 // functions are no-ops and always return true.
51 virtual void CheckUsbAccess(const ResultCallback& callback); 54 virtual void CheckUsbAccess(const ResultCallback& callback);
52 55
53 // Creates a UsbDeviceHandle for further manipulation. 56 // Creates a UsbDeviceHandle for further manipulation.
54 virtual void Open(const OpenCallback& callback) = 0; 57 virtual void Open(const OpenCallback& callback) = 0;
55 58
56 // Explicitly closes a device handle. This method will be automatically called 59 // Explicitly closes a device handle. This method will be automatically called
57 // by the destructor of a UsbDeviceHandle as well. 60 // by the destructor of a UsbDeviceHandle as well.
58 virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) = 0; 61 virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) = 0;
59 62
60 // Gets the UsbConfigDescriptor for the active device configuration or nullptr 63 // Gets the UsbConfigDescriptor for the active device configuration or nullptr
61 // if the device is unconfigured. 64 // if the device is unconfigured.
62 virtual const UsbConfigDescriptor* GetActiveConfiguration() = 0; 65 virtual const UsbConfigDescriptor* GetActiveConfiguration() = 0;
63 66
64 // Gets all of the device's UsbConfigDescriptors.
65 const std::vector<UsbConfigDescriptor>& configurations() const {
66 return configurations_;
67 }
68
69 protected: 67 protected:
70 UsbDevice(uint16_t vendor_id, 68 UsbDevice(uint16_t vendor_id,
71 uint16_t product_id, 69 uint16_t product_id,
72 const base::string16& manufacturer_string, 70 const base::string16& manufacturer_string,
73 const base::string16& product_string, 71 const base::string16& product_string,
74 const base::string16& serial_number); 72 const base::string16& serial_number);
75 virtual ~UsbDevice(); 73 virtual ~UsbDevice();
76 74
77 // These members must be mutable by subclasses as necessary during device 75 // These members must be mutable by subclasses as necessary during device
78 // enumeration. To preserve the thread safety of this object they must remain 76 // enumeration. To preserve the thread safety of this object they must remain
(...skipping 13 matching lines...) Expand all
92 const std::string guid_; 90 const std::string guid_;
93 const uint16_t vendor_id_; 91 const uint16_t vendor_id_;
94 const uint16_t product_id_; 92 const uint16_t product_id_;
95 93
96 DISALLOW_COPY_AND_ASSIGN(UsbDevice); 94 DISALLOW_COPY_AND_ASSIGN(UsbDevice);
97 }; 95 };
98 96
99 } // namespace device 97 } // namespace device
100 98
101 #endif // DEVICE_USB_USB_DEVICE_H_ 99 #endif // DEVICE_USB_USB_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698