Chromium Code Reviews| 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 // Add or update a printer in profile preferences. Printers are identified by |
|
Lei Zhang
2017/05/09 01:14:39
BTW, most of the other comments say "Returns" so k
skau
2017/05/09 19:39:27
Done.
| |
| 59 // empty id to add a new printer. | 59 // the id field. Use an 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. This is independent of | |
| 80 // whether a printer is saved in profile preferences. | |
| 81 void PrinterInstalled(const Printer& printer); | |
| 82 | |
| 83 // Returns true if |printer| is currently installed in CUPS. | |
| 84 bool IsConfigurationCurrent(const Printer& printer) const; | |
| 85 | |
| 79 private: | 86 private: |
| 80 // Updates the in-memory recommended printer list. | 87 // Updates the in-memory recommended printer list. |
| 81 void UpdateRecommendedPrinters(); | 88 void UpdateRecommendedPrinters(); |
| 82 | 89 |
| 83 Profile* profile_; | 90 Profile* profile_; |
| 84 PrefChangeRegistrar pref_change_registrar_; | 91 PrefChangeRegistrar pref_change_registrar_; |
| 85 | 92 |
| 86 // The backend for profile printers. | 93 // The backend for profile printers. |
| 87 std::unique_ptr<PrintersSyncBridge> sync_bridge_; | 94 std::unique_ptr<PrintersSyncBridge> sync_bridge_; |
| 88 | 95 |
| 89 // Contains the keys for all recommended printers in order so we can return | 96 // 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. | 97 // the list of recommended printers in the order they were received. |
| 91 std::vector<std::string> recommended_printer_ids_; | 98 std::vector<std::string> recommended_printer_ids_; |
| 92 std::map<std::string, std::unique_ptr<base::DictionaryValue>> | 99 std::map<std::string, std::unique_ptr<Printer>> recommended_printers_; |
| 93 recommended_printers_; | 100 |
| 101 // Map of printer ids to installation timestamps. | |
| 102 std::map<std::string, base::Time> installed_printer_timestamps_; | |
| 94 | 103 |
| 95 base::ObserverList<Observer> observers_; | 104 base::ObserverList<Observer> observers_; |
| 96 | 105 |
| 97 DISALLOW_COPY_AND_ASSIGN(PrintersManager); | 106 DISALLOW_COPY_AND_ASSIGN(PrintersManager); |
| 98 }; | 107 }; |
| 99 | 108 |
| 100 } // namespace chromeos | 109 } // namespace chromeos |
| 101 | 110 |
| 102 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_PRINTERS_MANAGER_H_ | 111 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_PRINTERS_MANAGER_H_ |
| OLD | NEW |