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 // Utility routines for working with UsbDevices that are printers. | 5 // Utility routines for working with UsbDevices that are printers. |
6 | 6 |
7 #ifndef CHROME_BROWSER_CHROMEOS_PRINTING_USB_PRINTER_UTIL_H__ | 7 #ifndef CHROME_BROWSER_CHROMEOS_PRINTING_USB_PRINTER_UTIL_H__ |
8 #define CHROME_BROWSER_CHROMEOS_PRINTING_USB_PRINTER_UTIL_H__ | 8 #define CHROME_BROWSER_CHROMEOS_PRINTING_USB_PRINTER_UTIL_H__ |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 | 14 |
15 namespace device { | 15 namespace device { |
16 class UsbDevice; | 16 class UsbDevice; |
17 } | 17 } |
18 | 18 |
19 namespace chromeos { | 19 namespace chromeos { |
20 | 20 |
21 class Printer; | 21 class Printer; |
22 | 22 |
23 bool UsbDeviceIsPrinter(scoped_refptr<device::UsbDevice> usb_device); | 23 bool UsbDeviceIsPrinter(const device::UsbDevice& usb_device); |
24 | 24 |
25 // Convert the interesting details of a device to a string, for | 25 // Convert the interesting details of a device to a string, for |
26 // logging/debugging. | 26 // logging/debugging. |
27 std::string UsbPrinterDeviceDetailsAsString(const device::UsbDevice& device); | 27 std::string UsbPrinterDeviceDetailsAsString(const device::UsbDevice& device); |
28 | 28 |
29 // Attempt to gather all the information we need to work with this printer by | 29 // Attempt to gather all the information we need to work with this printer by |
30 // querying the USB device. This should only be called using devices we believe | 30 // querying the USB device. This should only be called using devices we believe |
31 // are printers, not arbitrary USB devices, as we may get weird partial results | 31 // are printers, not arbitrary USB devices, as we may get weird partial results |
32 // from arbitrary devices. | 32 // from arbitrary devices. |
33 // | 33 // |
34 // Returns nullptr and logs an error on failure. | 34 // Returns nullptr and logs an error on failure. |
35 std::unique_ptr<Printer> UsbDeviceToPrinter(const device::UsbDevice& device); | 35 std::unique_ptr<Printer> UsbDeviceToPrinter(const device::UsbDevice& device); |
36 | 36 |
37 // Gets the URI CUPS would use to refer to this USB device. Assumes device | 37 // Gets the URI CUPS would use to refer to this USB device. Assumes device |
38 // is a printer. | 38 // is a printer. |
39 std::string UsbPrinterUri(const device::UsbDevice& device); | 39 std::string UsbPrinterUri(const device::UsbDevice& device); |
40 | 40 |
41 } // namespace chromeos | 41 } // namespace chromeos |
42 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_USB_PRINTER_UTIL_H__ | 42 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_USB_PRINTER_UTIL_H__ |
OLD | NEW |