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 // These values are written to logs. New enum values can be added, but existing | |
18 // enums must never be renumbered or deleted and reused. | |
17 enum PrinterSetupResult { | 19 enum PrinterSetupResult { |
18 kFatalError = 0, // Setup failed in an unrecognized way | 20 kFatalError = 0, // Setup failed in an unrecognized way |
19 kSuccess = 1, // Printer set up successfully | 21 kSuccess = 1, // Printer set up successfully |
20 kPrinterUnreachable = 2, // Could not reach printer | 22 kPrinterUnreachable = 2, // Could not reach printer |
21 kDbusError = 3, // Could not contact debugd | 23 kDbusError = 3, // Could not contact debugd |
22 // Space left for additional errors | 24 // Space left for additional errors |
23 | 25 |
24 // PPD errors | 26 // PPD errors |
25 kPpdTooLarge = 10, // PPD exceeds size limit | 27 kPpdTooLarge = 10, // PPD exceeds size limit |
26 kInvalidPpd = 11, // PPD rejected by cupstestppd | 28 kInvalidPpd = 11, // PPD rejected by cupstestppd |
27 kPpdNotFound = 12, // Could not find PPD | 29 kPpdNotFound = 12, // Could not find PPD |
28 kPpdUnretrievable = 13, // Could not download PPD | 30 kPpdUnretrievable = 13, // Could not download PPD |
29 kMaxValue = kPpdUnretrievable | 31 kMaxValue = kPpdUnretrievable |
Carlson
2017/05/26 16:58:38
I"m suddenly a little suspicious that kMaxValue he
skau
2017/05/26 17:18:02
Well, this is the comment on the histogram method:
| |
30 }; | 32 }; |
31 | 33 |
32 using PrinterSetupCallback = base::Callback<void(PrinterSetupResult)>; | 34 using PrinterSetupCallback = base::Callback<void(PrinterSetupResult)>; |
33 | 35 |
34 // Configures printers by retrieving PPDs and registering the printer with CUPS. | 36 // Configures printers by retrieving PPDs and registering the printer with CUPS. |
35 // Class must be constructed and used on the UI thread. | 37 // Class must be constructed and used on the UI thread. |
36 class PrinterConfigurer { | 38 class PrinterConfigurer { |
37 public: | 39 public: |
38 static std::unique_ptr<PrinterConfigurer> Create(Profile* profile); | 40 static std::unique_ptr<PrinterConfigurer> Create(Profile* profile); |
39 | 41 |
40 PrinterConfigurer(const PrinterConfigurer&) = delete; | 42 PrinterConfigurer(const PrinterConfigurer&) = delete; |
41 PrinterConfigurer& operator=(const PrinterConfigurer&) = delete; | 43 PrinterConfigurer& operator=(const PrinterConfigurer&) = delete; |
42 | 44 |
43 virtual ~PrinterConfigurer() = default; | 45 virtual ~PrinterConfigurer() = default; |
44 | 46 |
45 // Set up |printer| retrieving the appropriate PPD and registering the printer | 47 // Set up |printer| retrieving the appropriate PPD and registering the printer |
46 // with CUPS. |callback| is called with the result of the operation. This | 48 // with CUPS. |callback| is called with the result of the operation. This |
47 // method must be called on the UI thread and will run |callback| on the | 49 // method must be called on the UI thread and will run |callback| on the |
48 // UI thread. | 50 // UI thread. |
49 virtual void SetUpPrinter(const Printer& printer, | 51 virtual void SetUpPrinter(const Printer& printer, |
50 const PrinterSetupCallback& callback) = 0; | 52 const PrinterSetupCallback& callback) = 0; |
51 | 53 |
52 protected: | 54 protected: |
53 PrinterConfigurer() = default; | 55 PrinterConfigurer() = default; |
54 }; | 56 }; |
55 | 57 |
56 } // namespace chromeos | 58 } // namespace chromeos |
57 | 59 |
58 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_CONFIGURER_H_ | 60 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_CONFIGURER_H_ |
OLD | NEW |