| OLD | NEW |
| 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 #include "extensions/common/permissions/usb_device_permission_data.h" | 5 #include "extensions/common/permissions/usb_device_permission_data.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <tuple> | 10 #include <tuple> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "extensions/common/permissions/api_permission.h" | 16 #include "extensions/common/permissions/api_permission.h" |
| 17 #include "extensions/common/permissions/usb_device_permission.h" | 17 #include "extensions/common/permissions/usb_device_permission.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 const char* kProductIdKey = "productId"; | 21 const char* kProductIdKey = "productId"; |
| 22 const char* kVendorIdKey = "vendorId"; | 22 const char* kVendorIdKey = "vendorId"; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 42 if (!param) | 42 if (!param) |
| 43 return false; | 43 return false; |
| 44 const UsbDevicePermission::CheckParam& specific_param = | 44 const UsbDevicePermission::CheckParam& specific_param = |
| 45 *static_cast<const UsbDevicePermission::CheckParam*>(param); | 45 *static_cast<const UsbDevicePermission::CheckParam*>(param); |
| 46 return vendor_id_ == specific_param.vendor_id && | 46 return vendor_id_ == specific_param.vendor_id && |
| 47 product_id_ == specific_param.product_id && | 47 product_id_ == specific_param.product_id && |
| 48 (specific_param.interface_id == UNSPECIFIED_INTERFACE || | 48 (specific_param.interface_id == UNSPECIFIED_INTERFACE || |
| 49 interface_id_ == specific_param.interface_id); | 49 interface_id_ == specific_param.interface_id); |
| 50 } | 50 } |
| 51 | 51 |
| 52 scoped_ptr<base::Value> UsbDevicePermissionData::ToValue() const { | 52 std::unique_ptr<base::Value> UsbDevicePermissionData::ToValue() const { |
| 53 base::DictionaryValue* result = new base::DictionaryValue(); | 53 base::DictionaryValue* result = new base::DictionaryValue(); |
| 54 result->SetInteger(kVendorIdKey, vendor_id_); | 54 result->SetInteger(kVendorIdKey, vendor_id_); |
| 55 result->SetInteger(kProductIdKey, product_id_); | 55 result->SetInteger(kProductIdKey, product_id_); |
| 56 result->SetInteger(kInterfaceIdKey, interface_id_); | 56 result->SetInteger(kInterfaceIdKey, interface_id_); |
| 57 return scoped_ptr<base::Value>(result); | 57 return std::unique_ptr<base::Value>(result); |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool UsbDevicePermissionData::FromValue(const base::Value* value) { | 60 bool UsbDevicePermissionData::FromValue(const base::Value* value) { |
| 61 if (!value) | 61 if (!value) |
| 62 return false; | 62 return false; |
| 63 | 63 |
| 64 const base::DictionaryValue* dict_value; | 64 const base::DictionaryValue* dict_value; |
| 65 if (!value->GetAsDictionary(&dict_value)) | 65 if (!value->GetAsDictionary(&dict_value)) |
| 66 return false; | 66 return false; |
| 67 | 67 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool UsbDevicePermissionData::operator==( | 97 bool UsbDevicePermissionData::operator==( |
| 98 const UsbDevicePermissionData& rhs) const { | 98 const UsbDevicePermissionData& rhs) const { |
| 99 return vendor_id_ == rhs.vendor_id_ && | 99 return vendor_id_ == rhs.vendor_id_ && |
| 100 product_id_ == rhs.product_id_ && | 100 product_id_ == rhs.product_id_ && |
| 101 interface_id_ == rhs.interface_id_; | 101 interface_id_ == rhs.interface_id_; |
| 102 } | 102 } |
| 103 | 103 |
| 104 } // namespace extensions | 104 } // namespace extensions |
| OLD | NEW |