Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_PRINTER_CONFIGURER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_CONFIGURER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_CONFIGURER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_CONFIGURER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "chromeos/printing/printer_configuration.h" | 11 #include "chromeos/printing/printer_configuration.h" |
| 12 | 12 |
| 13 class Profile; | 13 class Profile; |
| 14 | 14 |
| 15 namespace chromeos { | 15 namespace chromeos { |
| 16 | 16 |
| 17 enum SetupResult { | 17 enum PrinterSetupResult { |
|
stevenjb
2017/03/17 17:34:11
Thank you for the less generic name :) It would be
Carlson
2017/03/17 18:47:34
I think this will take some thought about what mak
| |
| 18 UNKNOWN, | 18 UNKNOWN, |
| 19 FATAL_ERROR, | 19 FATAL_ERROR, |
| 20 SUCCESS, // Printer set up successfully | 20 SUCCESS, // Printer set up successfully |
| 21 PRINTER_UNREACHABLE, // Could not reach printer | 21 PRINTER_UNREACHABLE, // Could not reach printer |
| 22 DBUS_ERROR, // Could not contact debugd | 22 DBUS_ERROR, // Could not contact debugd |
| 23 | 23 |
| 24 // PPD errors | 24 // PPD errors |
| 25 PPD_TOO_LARGE, // PPD exceeds size limit | 25 PPD_TOO_LARGE, // PPD exceeds size limit |
| 26 INVALID_PPD, // PPD rejected by cupstestppd | 26 INVALID_PPD, // PPD rejected by cupstestppd |
| 27 PPD_NOT_FOUND, // Could not find PPD | 27 PPD_NOT_FOUND, // Could not find PPD |
| 28 PPD_UNRETRIEVABLE // Could not download PPD | 28 PPD_UNRETRIEVABLE // Could not download PPD |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 using PrinterSetupCallback = base::Callback<void(SetupResult)>; | 31 using PrinterSetupCallback = base::Callback<void(PrinterSetupResult)>; |
| 32 | 32 |
| 33 // Configures printers by retrieving PPDs and registering the printer with CUPS. | 33 // Configures printers by retrieving PPDs and registering the printer with CUPS. |
| 34 // Class must be constructed and used on the UI thread. | 34 // Class must be constructed and used on the UI thread. |
| 35 class PrinterConfigurer { | 35 class PrinterConfigurer { |
| 36 public: | 36 public: |
| 37 static std::unique_ptr<PrinterConfigurer> Create(Profile* profile); | 37 static std::unique_ptr<PrinterConfigurer> Create(Profile* profile); |
| 38 | 38 |
| 39 PrinterConfigurer(const PrinterConfigurer&) = delete; | 39 PrinterConfigurer(const PrinterConfigurer&) = delete; |
| 40 PrinterConfigurer& operator=(const PrinterConfigurer&) = delete; | 40 PrinterConfigurer& operator=(const PrinterConfigurer&) = delete; |
| 41 | 41 |
| 42 virtual ~PrinterConfigurer() = default; | 42 virtual ~PrinterConfigurer() = default; |
| 43 | 43 |
| 44 // Set up |printer| retrieving the appropriate PPD and registering the printer | 44 // Set up |printer| retrieving the appropriate PPD and registering the printer |
| 45 // with CUPS. |callback| is called with the result of the operation. This | 45 // with CUPS. |callback| is called with the result of the operation. This |
| 46 // method must be called on the UI thread and will run |callback| on the | 46 // method must be called on the UI thread and will run |callback| on the |
| 47 // UI thread. | 47 // UI thread. |
| 48 virtual void SetUpPrinter(const Printer& printer, | 48 virtual void SetUpPrinter(const Printer& printer, |
| 49 const PrinterSetupCallback& callback) = 0; | 49 const PrinterSetupCallback& callback) = 0; |
| 50 | 50 |
| 51 protected: | 51 protected: |
| 52 PrinterConfigurer() = default; | 52 PrinterConfigurer() = default; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 } // namespace chromeos | 55 } // namespace chromeos |
| 56 | 56 |
| 57 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_CONFIGURER_H_ | 57 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_CONFIGURER_H_ |
| OLD | NEW |