OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 PRINTING_BACKEND_PRINT_BACKEND_H_ | 5 #ifndef PRINTING_BACKEND_PRINT_BACKEND_H_ |
6 #define PRINTING_BACKEND_PRINT_BACKEND_H_ | 6 #define PRINTING_BACKEND_PRINT_BACKEND_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "printing/print_job_constants.h" | |
13 #include "printing/printing_export.h" | 14 #include "printing/printing_export.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 class DictionaryValue; | 17 class DictionaryValue; |
17 } | 18 } |
18 | 19 |
19 // This is the interface for platform-specific code for a print backend | 20 // This is the interface for platform-specific code for a print backend |
20 namespace printing { | 21 namespace printing { |
21 | 22 |
22 struct PRINTING_EXPORT PrinterBasicInfo { | 23 struct PRINTING_EXPORT PrinterBasicInfo { |
23 PrinterBasicInfo(); | 24 PrinterBasicInfo(); |
24 ~PrinterBasicInfo(); | 25 ~PrinterBasicInfo(); |
25 | 26 |
26 std::string printer_name; | 27 std::string printer_name; |
27 std::string printer_description; | 28 std::string printer_description; |
28 int printer_status; | 29 int printer_status; |
29 int is_default; | 30 int is_default; |
30 std::map<std::string, std::string> options; | 31 std::map<std::string, std::string> options; |
31 }; | 32 }; |
32 | 33 |
33 typedef std::vector<PrinterBasicInfo> PrinterList; | 34 typedef std::vector<PrinterBasicInfo> PrinterList; |
34 | 35 |
36 struct PRINTING_EXPORT PrinterSemanticCapsAndDefaults { | |
37 PrinterSemanticCapsAndDefaults(); | |
38 ~PrinterSemanticCapsAndDefaults(); | |
39 | |
40 std::string GetAsJson() const; | |
41 | |
42 // Capabilities. | |
43 bool color_capable; | |
44 bool duplex_capable; | |
45 | |
46 // Current defaults. | |
47 bool color_default; | |
48 DuplexMode duplex_default; | |
49 }; | |
50 | |
35 struct PRINTING_EXPORT PrinterCapsAndDefaults { | 51 struct PRINTING_EXPORT PrinterCapsAndDefaults { |
36 PrinterCapsAndDefaults(); | 52 PrinterCapsAndDefaults(); |
37 ~PrinterCapsAndDefaults(); | 53 ~PrinterCapsAndDefaults(); |
38 | 54 |
39 std::string printer_capabilities; | 55 std::string printer_capabilities; |
40 std::string caps_mime_type; | 56 std::string caps_mime_type; |
41 std::string printer_defaults; | 57 std::string printer_defaults; |
42 std::string defaults_mime_type; | 58 std::string defaults_mime_type; |
43 }; | 59 }; |
44 | 60 |
45 // PrintBackend class will provide interface for different print backends | 61 // PrintBackend class will provide interface for different print backends |
46 // (Windows, CUPS) to implement. User will call CreateInstance() to | 62 // (Windows, CUPS) to implement. User will call CreateInstance() to |
47 // obtain available print backend. | 63 // obtain available print backend. |
48 // Please note, that PrintBackend is not platform specific, but rather | 64 // Please note, that PrintBackend is not platform specific, but rather |
49 // print system specific. For example, CUPS is available on both Linux and Mac, | 65 // print system specific. For example, CUPS is available on both Linux and Mac, |
50 // but not available on ChromeOS, etc. This design allows us to add more | 66 // but not available on ChromeOS, etc. This design allows us to add more |
51 // functionality on some platforms, while reusing core (CUPS) functions. | 67 // functionality on some platforms, while reusing core (CUPS) functions. |
52 class PRINTING_EXPORT PrintBackend | 68 class PRINTING_EXPORT PrintBackend |
53 : public base::RefCountedThreadSafe<PrintBackend> { | 69 : public base::RefCountedThreadSafe<PrintBackend> { |
54 public: | 70 public: |
55 // Enumerates the list of installed local and network printers. | 71 // Enumerates the list of installed local and network printers. |
56 virtual bool EnumeratePrinters(PrinterList* printer_list) = 0; | 72 virtual bool EnumeratePrinters(PrinterList* printer_list) = 0; |
57 | 73 |
58 // Get the default printer name. Empty string if no default printer. | 74 // Get the default printer name. Empty string if no default printer. |
59 virtual std::string GetDefaultPrinterName() = 0; | 75 virtual std::string GetDefaultPrinterName() = 0; |
60 | 76 |
77 // Gets the semantic capabilities and defaults for a specific printer. | |
78 // This is usually a lighter implementation than GetPrinterCapsAndDefaults(). | |
79 // NOTE: on some old platforms (WinXP without XPS pack) | |
80 // GetPrinterCapsAndDefaults() will fail, while this function will succeed. | |
81 virtual bool GetPrinterSemanticCapsAndDefaults( | |
82 const std::string& printer_name, | |
83 PrinterSemanticCapsAndDefaults* printer_info) = 0; | |
84 | |
61 // Gets the capabilities and defaults for a specific printer. | 85 // Gets the capabilities and defaults for a specific printer. |
62 virtual bool GetPrinterCapsAndDefaults( | 86 virtual bool GetPrinterCapsAndDefaults( |
Albert Bodenhamer
2012/08/29 23:54:26
Do we need to keep both?
gene
2012/08/30 03:19:03
Definitely yes. This function is used by CloudPrin
| |
63 const std::string& printer_name, | 87 const std::string& printer_name, |
64 PrinterCapsAndDefaults* printer_info) = 0; | 88 PrinterCapsAndDefaults* printer_info) = 0; |
65 | 89 |
66 // Gets the information about driver for a specific printer. | 90 // Gets the information about driver for a specific printer. |
67 virtual std::string GetPrinterDriverInfo( | 91 virtual std::string GetPrinterDriverInfo( |
68 const std::string& printer_name) = 0; | 92 const std::string& printer_name) = 0; |
69 | 93 |
70 // Returns true if printer_name points to a valid printer. | 94 // Returns true if printer_name points to a valid printer. |
71 virtual bool IsValidPrinter(const std::string& printer_name) = 0; | 95 virtual bool IsValidPrinter(const std::string& printer_name) = 0; |
72 | 96 |
73 // Allocate a print backend. If |print_backend_settings| is NULL, default | 97 // Allocate a print backend. If |print_backend_settings| is NULL, default |
74 // settings will be used. | 98 // settings will be used. |
75 // Return NULL if no print backend available. | 99 // Return NULL if no print backend available. |
76 static scoped_refptr<PrintBackend> CreateInstance( | 100 static scoped_refptr<PrintBackend> CreateInstance( |
77 const base::DictionaryValue* print_backend_settings); | 101 const base::DictionaryValue* print_backend_settings); |
78 | 102 |
79 protected: | 103 protected: |
80 friend class base::RefCountedThreadSafe<PrintBackend>; | 104 friend class base::RefCountedThreadSafe<PrintBackend>; |
81 virtual ~PrintBackend(); | 105 virtual ~PrintBackend(); |
82 }; | 106 }; |
83 | 107 |
84 } // namespace printing | 108 } // namespace printing |
85 | 109 |
86 #endif // PRINTING_BACKEND_PRINT_BACKEND_H_ | 110 #endif // PRINTING_BACKEND_PRINT_BACKEND_H_ |
OLD | NEW |