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_PRINTER_DETECTOR_PRINTER_DETECTOR_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_PRINTER_DETECTOR_PRINTER_DETECTOR_H_ |
6 #define CHROME_BROWSER_CHROMEOS_PRINTER_DETECTOR_PRINTER_DETECTOR_H_ | 6 #define CHROME_BROWSER_CHROMEOS_PRINTER_DETECTOR_PRINTER_DETECTOR_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
| 10 #include <vector> |
10 | 11 |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "chromeos/printing/printer_configuration.h" |
12 #include "components/keyed_service/core/keyed_service.h" | 14 #include "components/keyed_service/core/keyed_service.h" |
13 | 15 |
14 class NotificationUIManager; | 16 class NotificationUIManager; |
15 class Profile; | 17 class Profile; |
16 | 18 |
17 namespace chromeos { | 19 namespace chromeos { |
18 | 20 |
19 // Observes device::UsbService for addition of USB printers (devices with | 21 // Observes device::UsbService for addition of USB printers (devices with |
20 // interface class 7). What it does with this depends on whether or not | 22 // interface class 7). What it does with this depends on whether or not |
21 // CUPS printing support is enabled. | 23 // CUPS printing support is enabled. |
22 // | 24 // |
23 // If CUPS is disabled, the Legacy implementation should be used. The legacy | 25 // If CUPS is disabled, the Legacy implementation should be used. The legacy |
24 // implementation shows a notification depending on whether there are printer | 26 // implementation shows a notification depending on whether there are printer |
25 // provider apps that declared support for the USB device installed. If such | 27 // provider apps that declared support for the USB device installed. If such |
26 // app exists, the notification notifies the user the printer is ready. | 28 // app exists, the notification notifies the user the printer is ready. |
27 // Otherwise the notification offers user to search Chrome Web Store for apps | 29 // Otherwise the notification offers user to search Chrome Web Store for apps |
28 // that support the printer. Clicking the notification launches webstore_widget | 30 // that support the printer. Clicking the notification launches webstore_widget |
29 // app for the printer. The notification is shown only for active user's | 31 // app for the printer. The notification is shown only for active user's |
30 // profile. | 32 // profile. |
31 // | 33 // |
32 // If CUPS is enabled, the Cups implementation should be used. This | 34 // If CUPS is enabled, the Cups implementation should be used. This |
33 // implementation to guides the user through setting up a new USB printer in the | 35 // implementation to guides the user through setting up a new USB printer in the |
34 // CUPS backend. | 36 // CUPS backend. |
35 class PrinterDetector : public KeyedService { | 37 class PrinterDetector : public KeyedService { |
36 public: | 38 public: |
| 39 class Observer { |
| 40 public: |
| 41 virtual ~Observer() = default; |
| 42 |
| 43 // The set of available printers has changed. |
| 44 virtual void OnAvailableUsbPrintersChanged( |
| 45 const std::vector<Printer>& printers) = 0; |
| 46 }; |
| 47 |
37 // Factory function for the Legacy implementation. | 48 // Factory function for the Legacy implementation. |
38 static std::unique_ptr<PrinterDetector> CreateLegacy(Profile* profile); | 49 static std::unique_ptr<PrinterDetector> CreateLegacy(Profile* profile); |
39 | 50 |
40 // Factory function for the CUPS implementation. | 51 // Factory function for the CUPS implementation. |
41 static std::unique_ptr<PrinterDetector> CreateCups(Profile* profile); | 52 static std::unique_ptr<PrinterDetector> CreateCups(Profile* profile); |
42 ~PrinterDetector() override {} | 53 ~PrinterDetector() override {} |
43 | 54 |
| 55 // Observer management. Note these are only implemented for the cups backend. |
| 56 // TODO(justincarlson) - Change these all to pure virtual functions when the |
| 57 // legacy backend is retired. |
| 58 |
| 59 virtual void AddObserver(Observer* observer) {} |
| 60 virtual void RemoveObserver(Observer* observer) {} |
| 61 |
| 62 // Get the current set of detected printers. |
| 63 virtual std::vector<Printer> GetPrinters(); |
| 64 |
44 protected: | 65 protected: |
45 PrinterDetector() = default; | 66 PrinterDetector() = default; |
46 | 67 |
47 private: | 68 private: |
48 friend class PrinterDetectorAppSearchEnabledTest; | 69 friend class PrinterDetectorAppSearchEnabledTest; |
49 | 70 |
50 virtual void SetNotificationUIManagerForTesting( | 71 virtual void SetNotificationUIManagerForTesting( |
51 NotificationUIManager* manager) = 0; | 72 NotificationUIManager* manager) = 0; |
52 | 73 |
53 DISALLOW_COPY_AND_ASSIGN(PrinterDetector); | 74 DISALLOW_COPY_AND_ASSIGN(PrinterDetector); |
54 }; | 75 }; |
55 | 76 |
56 } // namespace chromeos | 77 } // namespace chromeos |
57 | 78 |
58 #endif // CHROME_BROWSER_CHROMEOS_PRINTER_DETECTOR_PRINTER_DETECTOR_H_ | 79 #endif // CHROME_BROWSER_CHROMEOS_PRINTER_DETECTOR_PRINTER_DETECTOR_H_ |
OLD | NEW |