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

Side by Side Diff: extensions/common/permissions/usb_device_permission_data.h

Issue 2418353002: Allow interfaceClass USB device permissions (Closed)
Patch Set: Allow interfaceClass USB device permissions Created 4 years, 2 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 #ifndef EXTENSIONS_COMMON_PERMISSIONS_USB_DEVICE_PERMISSION_DATA_H_ 4 #ifndef EXTENSIONS_COMMON_PERMISSIONS_USB_DEVICE_PERMISSION_DATA_H_
5 #define EXTENSIONS_COMMON_PERMISSIONS_USB_DEVICE_PERMISSION_DATA_H_ 5 #define EXTENSIONS_COMMON_PERMISSIONS_USB_DEVICE_PERMISSION_DATA_H_
6 6
7 #include <stdint.h>
8
9 #include <memory> 7 #include <memory>
10 #include <string> 8 #include <string>
11 9
12 #include "extensions/common/permissions/api_permission.h" 10 #include "extensions/common/permissions/api_permission.h"
13 11
14 namespace base { 12 namespace base {
15 13
16 class Value; 14 class Value;
17 15
18 } // namespace base 16 } // namespace base
19 17
18 namespace device {
19 class UsbDevice;
20 }
21
20 namespace extensions { 22 namespace extensions {
21 23
22 // A pattern that can be used to match a USB device permission. 24 // A pattern that can be used to match a USB device permission.
23 // Should be of the format: vendorId:productId, where both vendorId and 25 // Should be of the format: vendorId:productId, where both vendorId and
24 // productId are decimal strings representing uint16_t values. 26 // productId are decimal strings representing uint16_t values.
25 class UsbDevicePermissionData { 27 class UsbDevicePermissionData {
26 public: 28 public:
27 enum SpecialInterfaces { 29 enum SpecialValues {
28 // A special interface id for stating permissions for an entire USB device, 30 // A special interface id for stating permissions for an entire USB device,
29 // no specific interface. This value must match value of Rule::ANY_INTERFACE 31 // no specific interface. This value must match value of Rule::ANY_INTERFACE
30 // from ChromeOS permission_broker project. 32 // from ChromeOS permission_broker project.
31 ANY_INTERFACE = -1, 33 SPECIAL_VALUE_ANY = -1,
32 34
33 // A special interface id for |Check| to indicate that interface field is 35 // A special interface id for |Check| to indicate that interface field is
34 // not to be checked. Not used in manifest file. 36 // not to be checked. Not used in manifest file.
35 UNSPECIFIED_INTERFACE = -2 37 SPECIAL_VALUE_UNSPECIFIED = -2
36 }; 38 };
37 39
38 UsbDevicePermissionData(); 40 UsbDevicePermissionData();
39 UsbDevicePermissionData(uint16_t vendor_id, 41 UsbDevicePermissionData(int vendor_id,
40 uint16_t product_id, 42 int product_id,
41 int interface_id); 43 int interface_id,
Reilly Grant (use Gerrit) 2016/10/20 23:16:52 Since |interface_id| is ignored please make it inv
tbarzic 2016/10/21 00:05:05 Done.
44 int interface_class);
42 45
43 // Check if |param| (which must be a UsbDevicePermissionData::CheckParam) 46 // Check if |param| (which must be a UsbDevicePermissionData::CheckParam)
44 // matches the vendor and product IDs associated with |this|. 47 // matches the vendor and product IDs associated with |this|.
45 bool Check(const APIPermission::CheckParam* param) const; 48 bool Check(const APIPermission::CheckParam* param) const;
46 49
47 // Convert |this| into a base::Value. 50 // Convert |this| into a base::Value.
48 std::unique_ptr<base::Value> ToValue() const; 51 std::unique_ptr<base::Value> ToValue() const;
49 52
50 // Populate |this| from a base::Value. 53 // Populate |this| from a base::Value.
51 bool FromValue(const base::Value* value); 54 bool FromValue(const base::Value* value);
52 55
53 bool operator<(const UsbDevicePermissionData& rhs) const; 56 bool operator<(const UsbDevicePermissionData& rhs) const;
54 bool operator==(const UsbDevicePermissionData& rhs) const; 57 bool operator==(const UsbDevicePermissionData& rhs) const;
55 58
56 const uint16_t& vendor_id() const { return vendor_id_; } 59 const int& vendor_id() const { return vendor_id_; }
57 const uint16_t& product_id() const { return product_id_; } 60 const int& product_id() const { return product_id_; }
61 const int& interface_id() const { return interface_id_; }
62 const int& interface_class() const { return interface_class_; }
58 63
59 // These accessors are provided for IPC_STRUCT_TRAITS_MEMBER. Please 64 // These accessors are provided for IPC_STRUCT_TRAITS_MEMBER. Please
60 // think twice before using them for anything else. 65 // think twice before using them for anything else.
61 uint16_t& vendor_id() { return vendor_id_; } 66 int& vendor_id() { return vendor_id_; }
62 uint16_t& product_id() { return product_id_; } 67 int& product_id() { return product_id_; }
68 int& interface_id() { return interface_id_; }
Reilly Grant (use Gerrit) 2016/10/20 23:16:52 This field is unused and I've only not gotten rid
tbarzic 2016/10/21 00:05:05 OK, I'll also add a comment about that. Note that
69 int& interface_class() { return interface_class_; }
63 70
64 private: 71 private:
65 uint16_t vendor_id_; 72 int vendor_id_{SPECIAL_VALUE_ANY};
66 uint16_t product_id_; 73 int product_id_{SPECIAL_VALUE_ANY};
67 int interface_id_; 74 int interface_id_{SPECIAL_VALUE_ANY};
75 int interface_class_{SPECIAL_VALUE_ANY};
68 }; 76 };
69 77
70 } // namespace extensions 78 } // namespace extensions
71 79
72 #endif // EXTENSIONS_COMMON_PERMISSIONS_USB_DEVICE_PERMISSION_DATA_H_ 80 #endif // EXTENSIONS_COMMON_PERMISSIONS_USB_DEVICE_PERMISSION_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698