OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_CHROMEOS_PRINTING_USB_PRINTER_DETECTOR_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_PRINTING_USB_PRINTER_DETECTOR_H_ |
6 #define CHROME_BROWSER_CHROMEOS_PRINTING_USB_PRINTER_DETECTOR_H_ | 6 #define CHROME_BROWSER_CHROMEOS_PRINTING_USB_PRINTER_DETECTOR_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "chrome/browser/chromeos/printing/printer_detector.h" |
13 #include "chromeos/printing/printer_configuration.h" | 14 #include "chromeos/printing/printer_configuration.h" |
14 #include "components/keyed_service/core/keyed_service.h" | 15 #include "components/keyed_service/core/keyed_service.h" |
15 | 16 |
16 class Profile; | 17 class Profile; |
17 | 18 |
18 namespace chromeos { | 19 namespace chromeos { |
19 | 20 |
20 // Observes device::UsbService for addition of USB printers (devices with | 21 // Observes device::UsbService for addition of USB printers. When a new USB |
21 // interface class 7). When a device is detected, it is forwarded to the | 22 // printer that is not already configured for this user is found, if it can be |
22 // printing subsystem for either autoconfiguration or user guidance. | 23 // automatically configured for printing, that is done. USB printers that |
23 class UsbPrinterDetector : public KeyedService { | 24 // cannot be automatically configured are exposed via the PrinterDetector |
| 25 // interface so that higher level processing can handle them. |
| 26 class UsbPrinterDetector : public PrinterDetector, public KeyedService { |
24 public: | 27 public: |
25 class Observer { | |
26 public: | |
27 virtual ~Observer() = default; | |
28 | |
29 // The set of available printers has changed. | |
30 virtual void OnAvailableUsbPrintersChanged( | |
31 const std::vector<Printer>& printers) = 0; | |
32 }; | |
33 | |
34 // Factory function for the CUPS implementation. | 28 // Factory function for the CUPS implementation. |
35 static std::unique_ptr<UsbPrinterDetector> Create(Profile* profile); | 29 static std::unique_ptr<UsbPrinterDetector> Create(Profile* profile); |
36 ~UsbPrinterDetector() override = default; | 30 ~UsbPrinterDetector() override = default; |
37 | 31 |
38 virtual void AddObserver(Observer* observer) = 0; | |
39 virtual void RemoveObserver(Observer* observer) = 0; | |
40 | |
41 // Get the current set of detected printers. | |
42 virtual std::vector<Printer> GetPrinters() = 0; | |
43 | |
44 protected: | 32 protected: |
45 UsbPrinterDetector() = default; | 33 UsbPrinterDetector() = default; |
46 | 34 |
47 private: | 35 private: |
48 DISALLOW_COPY_AND_ASSIGN(UsbPrinterDetector); | 36 DISALLOW_COPY_AND_ASSIGN(UsbPrinterDetector); |
49 }; | 37 }; |
50 | 38 |
51 } // namespace chromeos | 39 } // namespace chromeos |
52 | 40 |
53 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_USB_PRINTER_DETECTOR_H_ | 41 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_USB_PRINTER_DETECTOR_H_ |
OLD | NEW |