OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_PRINTER_DETECTOR_PRINTER_DETECTOR_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_PRINTER_DETECTOR_PRINTER_DETECTOR_H_ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "base/macros.h" | |
13 #include "chromeos/printing/printer_configuration.h" | |
14 #include "components/keyed_service/core/keyed_service.h" | |
15 | |
16 class NotificationUIManager; | |
17 class Profile; | |
18 | |
19 namespace chromeos { | |
20 | |
21 // Observes device::UsbService for addition of USB printers (devices with | |
22 // interface class 7). What it does with this depends on whether or not | |
23 // CUPS printing support is enabled. | |
24 // | |
25 // If CUPS is disabled, the Legacy implementation should be used. The legacy | |
26 // implementation shows a notification depending on whether there are printer | |
27 // provider apps that declared support for the USB device installed. If such | |
28 // app exists, the notification notifies the user the printer is ready. | |
29 // Otherwise the notification offers user to search Chrome Web Store for apps | |
30 // that support the printer. Clicking the notification launches webstore_widget | |
31 // app for the printer. The notification is shown only for active user's | |
32 // profile. | |
33 // | |
34 // If CUPS is enabled, the Cups implementation should be used. This | |
35 // implementation to guides the user through setting up a new USB printer in the | |
36 // CUPS backend. | |
37 class PrinterDetector : public KeyedService { | |
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 | |
48 // Factory function for the Legacy implementation. | |
49 static std::unique_ptr<PrinterDetector> CreateLegacy(Profile* profile); | |
50 | |
51 // Factory function for the CUPS implementation. | |
52 static std::unique_ptr<PrinterDetector> CreateCups(Profile* profile); | |
53 ~PrinterDetector() override {} | |
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 | |
65 protected: | |
66 PrinterDetector() = default; | |
67 | |
68 private: | |
69 friend class PrinterDetectorAppSearchEnabledTest; | |
70 | |
71 virtual void SetNotificationUIManagerForTesting( | |
72 NotificationUIManager* manager) = 0; | |
73 | |
74 DISALLOW_COPY_AND_ASSIGN(PrinterDetector); | |
75 }; | |
76 | |
77 } // namespace chromeos | |
78 | |
79 #endif // CHROME_BROWSER_CHROMEOS_PRINTER_DETECTOR_PRINTER_DETECTOR_H_ | |
OLD | NEW |