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.h" | 5 #include "extensions/common/permissions/usb_device_permission.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "device/usb/usb_ids.h" |
13 #include "extensions/common/permissions/permissions_info.h" | 14 #include "extensions/common/permissions/permissions_info.h" |
14 #include "grit/extensions_strings.h" | 15 #include "grit/extensions_strings.h" |
15 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
16 | 17 |
17 #if defined(ENABLE_EXTENSIONS) | |
18 #include "device/usb/usb_ids.h" | |
19 #endif | |
20 | |
21 namespace extensions { | 18 namespace extensions { |
22 | 19 |
23 UsbDevicePermission::UsbDevicePermission( | 20 UsbDevicePermission::UsbDevicePermission( |
24 const APIPermissionInfo* info) | 21 const APIPermissionInfo* info) |
25 : SetDisjunctionPermission<UsbDevicePermissionData, | 22 : SetDisjunctionPermission<UsbDevicePermissionData, |
26 UsbDevicePermission>(info) { | 23 UsbDevicePermission>(info) { |
27 } | 24 } |
28 | 25 |
29 UsbDevicePermission::~UsbDevicePermission() { | 26 UsbDevicePermission::~UsbDevicePermission() { |
30 } | 27 } |
31 | 28 |
32 PermissionMessages UsbDevicePermission::GetMessages() const { | 29 PermissionMessages UsbDevicePermission::GetMessages() const { |
33 DCHECK(HasMessages()); | 30 DCHECK(HasMessages()); |
34 PermissionMessages result; | 31 PermissionMessages result; |
35 | 32 |
36 #if defined(ENABLE_EXTENSIONS) | |
37 // //device/usb/usb.gyp:device_usb is not available when extensions are | 33 // //device/usb/usb.gyp:device_usb is not available when extensions are |
38 // disabled. | 34 // disabled. |
39 for (std::set<UsbDevicePermissionData>::const_iterator i = | 35 for (std::set<UsbDevicePermissionData>::const_iterator i = |
40 data_set_.begin(); i != data_set_.end(); ++i) { | 36 data_set_.begin(); i != data_set_.end(); ++i) { |
41 const char* vendor = device::UsbIds::GetVendorName(i->vendor_id()); | 37 const char* vendor = device::UsbIds::GetVendorName(i->vendor_id()); |
42 | 38 |
43 if (vendor) { | 39 if (vendor) { |
44 const char* product = | 40 const char* product = |
45 device::UsbIds::GetProductName(i->vendor_id(), i->product_id()); | 41 device::UsbIds::GetProductName(i->vendor_id(), i->product_id()); |
46 if (product) { | 42 if (product) { |
(...skipping 10 matching lines...) Expand all Loading... |
57 IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE_MISSING_PRODUCT, | 53 IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE_MISSING_PRODUCT, |
58 base::ASCIIToUTF16(vendor)))); | 54 base::ASCIIToUTF16(vendor)))); |
59 } | 55 } |
60 } else { | 56 } else { |
61 result.push_back(PermissionMessage( | 57 result.push_back(PermissionMessage( |
62 PermissionMessage::kUsbDevice, | 58 PermissionMessage::kUsbDevice, |
63 l10n_util::GetStringUTF16( | 59 l10n_util::GetStringUTF16( |
64 IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE_MISSING_VENDOR))); | 60 IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE_MISSING_VENDOR))); |
65 } | 61 } |
66 } | 62 } |
67 #else | |
68 NOTREACHED(); | |
69 #endif // defined(ENABLE_EXTENSIONS) | |
70 | 63 |
71 return result; | 64 return result; |
72 } | 65 } |
73 | 66 |
74 } // namespace extensions | 67 } // namespace extensions |
OLD | NEW |