OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_PRINTERS_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_PRINTING_PRINTERS_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_PRINTING_PRINTERS_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_PRINTING_PRINTERS_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 // Returns the printers that are saved in preferences. | 48 // Returns the printers that are saved in preferences. |
49 std::vector<std::unique_ptr<Printer>> GetPrinters() const; | 49 std::vector<std::unique_ptr<Printer>> GetPrinters() const; |
50 | 50 |
51 // Returns printers from enterprise policy. | 51 // Returns printers from enterprise policy. |
52 std::vector<std::unique_ptr<Printer>> GetRecommendedPrinters() const; | 52 std::vector<std::unique_ptr<Printer>> GetRecommendedPrinters() const; |
53 | 53 |
54 // Returns the printer with id |printer_id|, or nullptr if no such | 54 // Returns the printer with id |printer_id|, or nullptr if no such |
55 // printer exists. | 55 // printer exists. |
56 std::unique_ptr<Printer> GetPrinter(const std::string& printer_id) const; | 56 std::unique_ptr<Printer> GetPrinter(const std::string& printer_id) const; |
57 | 57 |
58 // Adds or updates a printer. Printers are identified by the id field. Use an | 58 // Adds or updates a printer. Printers are identified by the id field. Use an |
Lei Zhang
2017/05/08 21:42:48
BTW, this comment looks out of date.
skau
2017/05/09 00:52:01
Done.
Lei Zhang
2017/05/09 01:14:39
Err, what I mean was this felt out of date because
skau
2017/05/09 19:39:26
Thanks. That phrasing is clearer.
| |
59 // empty id to add a new printer. | 59 // empty id to add a new printer. |
60 void RegisterPrinter(std::unique_ptr<Printer> printer); | 60 void RegisterPrinter(std::unique_ptr<Printer> printer); |
61 | 61 |
62 // Remove printer from preferences with the id |printer_id|. Returns true if | 62 // Remove printer from preferences with the id |printer_id|. Returns true if |
63 // the printer was successfully removed. | 63 // the printer was successfully removed. |
64 bool RemovePrinter(const std::string& printer_id); | 64 bool RemovePrinter(const std::string& printer_id); |
65 | 65 |
66 // Attach |observer| for notification of events. |observer| is expected to | 66 // Attach |observer| for notification of events. |observer| is expected to |
67 // live on the same thread (UI) as this object. OnPrinter* methods are | 67 // live on the same thread (UI) as this object. OnPrinter* methods are |
68 // invoked inline so calling RegisterPrinter in response to OnPrinterAdded is | 68 // invoked inline so calling RegisterPrinter in response to OnPrinterAdded is |
69 // forbidden. | 69 // forbidden. |
70 void AddObserver(PrintersManager::Observer* observer); | 70 void AddObserver(PrintersManager::Observer* observer); |
71 | 71 |
72 // Remove |observer| so that it no longer receives notifications. After the | 72 // Remove |observer| so that it no longer receives notifications. After the |
73 // completion of this method, the |observer| can be safely destroyed. | 73 // completion of this method, the |observer| can be safely destroyed. |
74 void RemoveObserver(PrintersManager::Observer* observer); | 74 void RemoveObserver(PrintersManager::Observer* observer); |
75 | 75 |
76 // Returns a ModelTypeSyncBridge for the sync client. | 76 // Returns a ModelTypeSyncBridge for the sync client. |
77 PrintersSyncBridge* GetSyncBridge(); | 77 PrintersSyncBridge* GetSyncBridge(); |
78 | 78 |
79 // Registers that the printer was installed in CUPS. | |
Lei Zhang
2017/05/08 21:42:48
One of the PrinterInstalled() callers is as follow
skau
2017/05/09 00:52:01
I've tried to clarify the comment on RegisterPrint
Lei Zhang
2017/05/09 01:14:39
Yes, definitely clearer.
| |
80 void PrinterInstalled(const Printer& printer); | |
81 | |
82 // Returns true if the printer is installed in CUPS. | |
83 bool IsConfigurationCurrent(const Printer& printer); | |
Lei Zhang
2017/05/08 21:42:48
const method?
skau
2017/05/09 00:52:01
Done.
| |
84 | |
79 private: | 85 private: |
80 // Updates the in-memory recommended printer list. | 86 // Updates the in-memory recommended printer list. |
81 void UpdateRecommendedPrinters(); | 87 void UpdateRecommendedPrinters(); |
82 | 88 |
83 Profile* profile_; | 89 Profile* profile_; |
84 PrefChangeRegistrar pref_change_registrar_; | 90 PrefChangeRegistrar pref_change_registrar_; |
85 | 91 |
86 // The backend for profile printers. | 92 // The backend for profile printers. |
87 std::unique_ptr<PrintersSyncBridge> sync_bridge_; | 93 std::unique_ptr<PrintersSyncBridge> sync_bridge_; |
88 | 94 |
89 // Contains the keys for all recommended printers in order so we can return | 95 // Contains the keys for all recommended printers in order so we can return |
90 // the list of recommended printers in the order they were received. | 96 // the list of recommended printers in the order they were received. |
91 std::vector<std::string> recommended_printer_ids_; | 97 std::vector<std::string> recommended_printer_ids_; |
92 std::map<std::string, std::unique_ptr<base::DictionaryValue>> | 98 std::map<std::string, std::unique_ptr<Printer>> recommended_printers_; |
93 recommended_printers_; | 99 |
100 // Map of printer ids to installation timestamps. | |
101 std::map<std::string, base::Time> installed_printer_timestamps_; | |
94 | 102 |
95 base::ObserverList<Observer> observers_; | 103 base::ObserverList<Observer> observers_; |
96 | 104 |
97 DISALLOW_COPY_AND_ASSIGN(PrintersManager); | 105 DISALLOW_COPY_AND_ASSIGN(PrintersManager); |
98 }; | 106 }; |
99 | 107 |
100 } // namespace chromeos | 108 } // namespace chromeos |
101 | 109 |
102 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_PRINTERS_MANAGER_H_ | 110 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_PRINTERS_MANAGER_H_ |
OLD | NEW |