Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / extensions / common / permissions / usb_device_permission_data.h
blob001b12c27b3445077ef6d426703eb03e237600ce
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
3 // found in the LICENSE file.
4 #ifndef EXTENSIONS_COMMON_PERMISSIONS_USB_DEVICE_PERMISSION_DATA_H_
5 #define EXTENSIONS_COMMON_PERMISSIONS_USB_DEVICE_PERMISSION_DATA_H_
7 #include <string>
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "extensions/common/permissions/api_permission.h"
13 namespace base {
15 class Value;
17 } // namespace base
19 namespace extensions {
21 // A pattern that can be used to match a USB device permission.
22 // Should be of the format: vendorId:productId, where both vendorId and
23 // productId are decimal strings representing uint16 values.
24 class UsbDevicePermissionData {
25 public:
26 enum SpecialInterfaces {
27 // A special interface id for stating permissions for an entire USB device,
28 // no specific interface. This value must match value of Rule::ANY_INTERFACE
29 // from ChromeOS permission_broker project.
30 ANY_INTERFACE = -1,
32 // A special interface id for |Check| to indicate that interface field is
33 // not to be checked. Not used in manifest file.
34 UNSPECIFIED_INTERFACE = -2
37 UsbDevicePermissionData();
38 UsbDevicePermissionData(uint16 vendor_id,
39 uint16 product_id,
40 int interface_id);
42 // Check if |param| (which must be a UsbDevicePermissionData::CheckParam)
43 // matches the vendor and product IDs associated with |this|.
44 bool Check(const APIPermission::CheckParam* param) const;
46 // Convert |this| into a base::Value.
47 scoped_ptr<base::Value> ToValue() const;
49 // Populate |this| from a base::Value.
50 bool FromValue(const base::Value* value);
52 bool operator<(const UsbDevicePermissionData& rhs) const;
53 bool operator==(const UsbDevicePermissionData& rhs) const;
55 const uint16& vendor_id() const { return vendor_id_; }
56 const uint16& product_id() const { return product_id_; }
58 // These accessors are provided for IPC_STRUCT_TRAITS_MEMBER. Please
59 // think twice before using them for anything else.
60 uint16& vendor_id() { return vendor_id_; }
61 uint16& product_id() { return product_id_; }
63 private:
64 uint16 vendor_id_;
65 uint16 product_id_;
66 int interface_id_;
69 } // namespace extensions
71 #endif // EXTENSIONS_COMMON_PERMISSIONS_USB_DEVICE_PERMISSION_DATA_H_