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

Side by Side Diff: chrome/common/extensions/permissions/usb_device_permission.cc

Issue 14473014: Fix USB Permission string (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/common/extensions/permissions/usb_device_permission.h" 5 #include "chrome/common/extensions/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"
(...skipping 19 matching lines...) Expand all
30 } 30 }
31 31
32 PermissionMessages UsbDevicePermission::GetMessages() const { 32 PermissionMessages UsbDevicePermission::GetMessages() const {
33 DCHECK(HasMessages()); 33 DCHECK(HasMessages());
34 PermissionMessages result; 34 PermissionMessages result;
35 35
36 #if defined(ENABLE_EXTENSIONS) 36 #if defined(ENABLE_EXTENSIONS)
37 // device.gyp:device_usb is not available when extensions are disabled. 37 // device.gyp:device_usb is not available when extensions are disabled.
38 for (std::set<UsbDevicePermissionData>::const_iterator i = 38 for (std::set<UsbDevicePermissionData>::const_iterator i =
39 data_set_.begin(); i != data_set_.end(); ++i) { 39 data_set_.begin(); i != data_set_.end(); ++i) {
40 const char* vendor = device::UsbIds::GetVendorName(i->vendor_id());
40 41
41 const char* vendor = device::UsbIds::GetVendorName(i->vendor_id());
42 string16 vendor_name;
43 if (vendor) { 42 if (vendor) {
44 vendor_name = ASCIIToUTF16(vendor); 43 const char* product =
44 device::UsbIds::GetProductName(i->vendor_id(), i->product_id());
45 if (product) {
46 result.push_back(PermissionMessage(
47 PermissionMessage::kUsbDevice,
48 l10n_util::GetStringFUTF16(
49 IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE,
50 ASCIIToUTF16(product),
51 ASCIIToUTF16(vendor))));
52 } else {
53 result.push_back(PermissionMessage(
54 PermissionMessage::kUsbDevice,
55 l10n_util::GetStringFUTF16(
56 IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE_MISSING_PRODUCT,
57 ASCIIToUTF16(vendor))));
58 }
45 } else { 59 } else {
46 vendor_name = l10n_util::GetStringUTF16( 60 result.push_back(PermissionMessage(
47 IDS_EXTENSION_PROMPT_WARNING_UNKNOWN_USB_VENDOR); 61 PermissionMessage::kUsbDevice,
62 l10n_util::GetStringUTF16(
63 IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE_MISSING_VENDOR)));
48 } 64 }
49
50 const char* product =
51 device::UsbIds::GetProductName(i->vendor_id(), i->product_id());
52 string16 product_name;
53 if (product) {
54 product_name = ASCIIToUTF16(product);
55 } else {
56 product_name = l10n_util::GetStringUTF16(
57 IDS_EXTENSION_PROMPT_WARNING_UNKNOWN_USB_PRODUCT);
58 }
59
60 result.push_back(PermissionMessage(
61 PermissionMessage::kUsbDevice,
62 l10n_util::GetStringFUTF16(
63 IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE,
64 product_name,
65 vendor_name)));
66 } 65 }
67 #else 66 #else
68 NOTREACHED(); 67 NOTREACHED();
69 #endif // defined(ENABLE_EXTENSIONS) 68 #endif // defined(ENABLE_EXTENSIONS)
70 69
71 return result; 70 return result;
72 } 71 }
73 72
74 } // namespace extensions 73 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698