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 PrinterSetupResult { | 17 enum PrinterSetupResult { |
| 18 FATAL_ERROR, | 18 kFatalError = 0, // Setup failed in an unrecognized way |
| 19 SUCCESS, // Printer set up successfully | 19 kSuccess = 1, // Printer set up successfully |
| 20 PRINTER_UNREACHABLE, // Could not reach printer | 20 kPrinterUnreachable = 2, // Could not reach printer |
| 21 DBUS_ERROR, // Could not contact debugd | 21 kDbusError = 3, // Could not contact debugd |
| 22 // Space left for additional errors | |
|
Lei Zhang
2017/05/25 22:53:03
Can you explain why this is needed?
skau
2017/05/25 23:11:07
I'm leaving space for non-PPD errors and thought i
Lei Zhang
2017/05/25 23:24:06
OK, the CL description hinted that you are going t
| |
| 22 | 23 |
| 23 // PPD errors | 24 // PPD errors |
| 24 PPD_TOO_LARGE, // PPD exceeds size limit | 25 kPpdTooLarge = 10, // PPD exceeds size limit |
| 25 INVALID_PPD, // PPD rejected by cupstestppd | 26 kInvalidPpd = 11, // PPD rejected by cupstestppd |
| 26 PPD_NOT_FOUND, // Could not find PPD | 27 kPpdNotFound = 12, // Could not find PPD |
| 27 PPD_UNRETRIEVABLE // Could not download PPD | 28 kPpdUnretrievable = 13, // Could not download PPD |
| 29 kMaxValue = kPpdUnretrievable | |
| 28 }; | 30 }; |
| 29 | 31 |
| 30 using PrinterSetupCallback = base::Callback<void(PrinterSetupResult)>; | 32 using PrinterSetupCallback = base::Callback<void(PrinterSetupResult)>; |
| 31 | 33 |
| 32 // Configures printers by retrieving PPDs and registering the printer with CUPS. | 34 // Configures printers by retrieving PPDs and registering the printer with CUPS. |
| 33 // Class must be constructed and used on the UI thread. | 35 // Class must be constructed and used on the UI thread. |
| 34 class PrinterConfigurer { | 36 class PrinterConfigurer { |
| 35 public: | 37 public: |
| 36 static std::unique_ptr<PrinterConfigurer> Create(Profile* profile); | 38 static std::unique_ptr<PrinterConfigurer> Create(Profile* profile); |
| 37 | 39 |
| 38 PrinterConfigurer(const PrinterConfigurer&) = delete; | 40 PrinterConfigurer(const PrinterConfigurer&) = delete; |
| 39 PrinterConfigurer& operator=(const PrinterConfigurer&) = delete; | 41 PrinterConfigurer& operator=(const PrinterConfigurer&) = delete; |
| 40 | 42 |
| 41 virtual ~PrinterConfigurer() = default; | 43 virtual ~PrinterConfigurer() = default; |
| 42 | 44 |
| 43 // Set up |printer| retrieving the appropriate PPD and registering the printer | 45 // Set up |printer| retrieving the appropriate PPD and registering the printer |
| 44 // with CUPS. |callback| is called with the result of the operation. This | 46 // with CUPS. |callback| is called with the result of the operation. This |
| 45 // method must be called on the UI thread and will run |callback| on the | 47 // method must be called on the UI thread and will run |callback| on the |
| 46 // UI thread. | 48 // UI thread. |
| 47 virtual void SetUpPrinter(const Printer& printer, | 49 virtual void SetUpPrinter(const Printer& printer, |
| 48 const PrinterSetupCallback& callback) = 0; | 50 const PrinterSetupCallback& callback) = 0; |
| 49 | 51 |
| 50 protected: | 52 protected: |
| 51 PrinterConfigurer() = default; | 53 PrinterConfigurer() = default; |
| 52 }; | 54 }; |
| 53 | 55 |
| 54 } // namespace chromeos | 56 } // namespace chromeos |
| 55 | 57 |
| 56 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_CONFIGURER_H_ | 58 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_CONFIGURER_H_ |
| OLD | NEW |