Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: chrome/browser/chromeos/printer_detector/printer_detector.h

Issue 2790603003: Make CUPS USB printing play better with the settings page. This change does several things: (Closed)
Patch Set: Address xdai@ comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/memory/ref_counted.h"
stevenjb 2017/04/10 19:49:55 needed?
Carlson 2017/04/10 22:16:41 Removed
14 #include "chromeos/printing/printer_configuration.h"
12 #include "components/keyed_service/core/keyed_service.h" 15 #include "components/keyed_service/core/keyed_service.h"
13 16
14 class NotificationUIManager; 17 class NotificationUIManager;
15 class Profile; 18 class Profile;
16 19
17 namespace chromeos { 20 namespace chromeos {
18 21
19 // Observes device::UsbService for addition of USB printers (devices with 22 // Observes device::UsbService for addition of USB printers (devices with
20 // interface class 7). What it does with this depends on whether or not 23 // interface class 7). What it does with this depends on whether or not
21 // CUPS printing support is enabled. 24 // CUPS printing support is enabled.
22 // 25 //
23 // If CUPS is disabled, the Legacy implementation should be used. The legacy 26 // If CUPS is disabled, the Legacy implementation should be used. The legacy
24 // implementation shows a notification depending on whether there are printer 27 // implementation shows a notification depending on whether there are printer
25 // provider apps that declared support for the USB device installed. If such 28 // provider apps that declared support for the USB device installed. If such
26 // app exists, the notification notifies the user the printer is ready. 29 // app exists, the notification notifies the user the printer is ready.
27 // Otherwise the notification offers user to search Chrome Web Store for apps 30 // Otherwise the notification offers user to search Chrome Web Store for apps
28 // that support the printer. Clicking the notification launches webstore_widget 31 // that support the printer. Clicking the notification launches webstore_widget
29 // app for the printer. The notification is shown only for active user's 32 // app for the printer. The notification is shown only for active user's
30 // profile. 33 // profile.
31 // 34 //
32 // If CUPS is enabled, the Cups implementation should be used. This 35 // 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 36 // implementation to guides the user through setting up a new USB printer in the
34 // CUPS backend. 37 // CUPS backend.
35 class PrinterDetector : public KeyedService { 38 class PrinterDetector : public KeyedService {
36 public: 39 public:
40 class Observer {
41 public:
42 virtual ~Observer() = default;
43
44 // The set of available printers has changed
stevenjb 2017/04/10 19:49:55 nit: .
Carlson 2017/04/10 22:16:41 Done.
45 virtual void OnAvailableUsbPrintersChanged(
46 const std::vector<Printer>& printers) = 0;
47 };
48
37 // Factory function for the Legacy implementation. 49 // Factory function for the Legacy implementation.
38 static std::unique_ptr<PrinterDetector> CreateLegacy(Profile* profile); 50 static std::unique_ptr<PrinterDetector> CreateLegacy(Profile* profile);
39 51
40 // Factory function for the CUPS implementation. 52 // Factory function for the CUPS implementation.
41 static std::unique_ptr<PrinterDetector> CreateCups(Profile* profile); 53 static std::unique_ptr<PrinterDetector> CreateCups(Profile* profile);
42 ~PrinterDetector() override {} 54 ~PrinterDetector() override {}
43 55
56 // Observer management. Note these are only implemented for the cups backend.
57 virtual void AddObserver(Observer* observer) {}
58 virtual void RemoveObserver(Observer* observer) {}
59
60 // Get the current set of detected printers.
61 virtual std::vector<Printer> GetPrinters() { return {}; }
62
44 protected: 63 protected:
45 PrinterDetector() = default; 64 PrinterDetector() = default;
46 65
47 private: 66 private:
48 friend class PrinterDetectorAppSearchEnabledTest; 67 friend class PrinterDetectorAppSearchEnabledTest;
49 68
50 virtual void SetNotificationUIManagerForTesting( 69 virtual void SetNotificationUIManagerForTesting(
51 NotificationUIManager* manager) = 0; 70 NotificationUIManager* manager) = 0;
52 71
53 DISALLOW_COPY_AND_ASSIGN(PrinterDetector); 72 DISALLOW_COPY_AND_ASSIGN(PrinterDetector);
54 }; 73 };
55 74
56 } // namespace chromeos 75 } // namespace chromeos
57 76
58 #endif // CHROME_BROWSER_CHROMEOS_PRINTER_DETECTOR_PRINTER_DETECTOR_H_ 77 #endif // CHROME_BROWSER_CHROMEOS_PRINTER_DETECTOR_PRINTER_DETECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698