OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/browser/chromeos/printing/usb_printer_util.h" | 5 #include "chrome/browser/chromeos/printing/usb_printer_util.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 buf.push_back(kHexDigits[c & 0xf]); | 43 buf.push_back(kHexDigits[c & 0xf]); |
44 } else { | 44 } else { |
45 buf.push_back(c); | 45 buf.push_back(c); |
46 } | 46 } |
47 } | 47 } |
48 return std::string(buf.data(), buf.size()); | 48 return std::string(buf.data(), buf.size()); |
49 } | 49 } |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 bool UsbDeviceIsPrinter(scoped_refptr<device::UsbDevice> usb_device) { | 53 bool UsbDeviceIsPrinter(const device::UsbDevice& usb_device) { |
54 device::UsbDeviceFilter printer_filter; | 54 device::UsbDeviceFilter printer_filter; |
55 printer_filter.interface_class = kPrinterInterfaceClass; | 55 printer_filter.interface_class = kPrinterInterfaceClass; |
56 return printer_filter.Matches(usb_device); | 56 return printer_filter.Matches(usb_device); |
57 } | 57 } |
58 | 58 |
59 std::string UsbPrinterDeviceDetailsAsString(const device::UsbDevice& device) { | 59 std::string UsbPrinterDeviceDetailsAsString(const device::UsbDevice& device) { |
60 return base::StringPrintf( | 60 return base::StringPrintf( |
61 " guid: %s\n" | 61 " guid: %s\n" |
62 " usb version: %d\n" | 62 " usb version: %d\n" |
63 " device class: %d\n" | 63 " device class: %d\n" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // There doesn't seem to be a robust solution to this problem; if printers | 111 // There doesn't seem to be a robust solution to this problem; if printers |
112 // don't supply a serial number, we don't have any reliable way to do that | 112 // don't supply a serial number, we don't have any reliable way to do that |
113 // differentiation. | 113 // differentiation. |
114 std::string serial = base::UTF16ToUTF8(device.serial_number()); | 114 std::string serial = base::UTF16ToUTF8(device.serial_number()); |
115 return CupsURIEscape(base::StringPrintf("usb://%04x/%04x?serial=%s", | 115 return CupsURIEscape(base::StringPrintf("usb://%04x/%04x?serial=%s", |
116 device.vendor_id(), | 116 device.vendor_id(), |
117 device.product_id(), serial.c_str())); | 117 device.product_id(), serial.c_str())); |
118 } | 118 } |
119 | 119 |
120 } // namespace chromeos | 120 } // namespace chromeos |
OLD | NEW |