Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: printing/backend/print_backend.h

Issue 10905006: Get semantic capabilities from Print Backend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Capabilities.
41 bool color_capable;
42 bool duplex_capable;
43
44 // Current defaults.
45 bool color_default;
46 DuplexMode duplex_default;
47 };
48
35 struct PRINTING_EXPORT PrinterCapsAndDefaults { 49 struct PRINTING_EXPORT PrinterCapsAndDefaults {
36 PrinterCapsAndDefaults(); 50 PrinterCapsAndDefaults();
37 ~PrinterCapsAndDefaults(); 51 ~PrinterCapsAndDefaults();
38 52
39 std::string printer_capabilities; 53 std::string printer_capabilities;
40 std::string caps_mime_type; 54 std::string caps_mime_type;
41 std::string printer_defaults; 55 std::string printer_defaults;
42 std::string defaults_mime_type; 56 std::string defaults_mime_type;
43 }; 57 };
44 58
45 // PrintBackend class will provide interface for different print backends 59 // PrintBackend class will provide interface for different print backends
46 // (Windows, CUPS) to implement. User will call CreateInstance() to 60 // (Windows, CUPS) to implement. User will call CreateInstance() to
47 // obtain available print backend. 61 // obtain available print backend.
48 // Please note, that PrintBackend is not platform specific, but rather 62 // Please note, that PrintBackend is not platform specific, but rather
49 // print system specific. For example, CUPS is available on both Linux and Mac, 63 // 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 64 // but not available on ChromeOS, etc. This design allows us to add more
51 // functionality on some platforms, while reusing core (CUPS) functions. 65 // functionality on some platforms, while reusing core (CUPS) functions.
52 class PRINTING_EXPORT PrintBackend 66 class PRINTING_EXPORT PrintBackend
53 : public base::RefCountedThreadSafe<PrintBackend> { 67 : public base::RefCountedThreadSafe<PrintBackend> {
54 public: 68 public:
55 // Enumerates the list of installed local and network printers. 69 // Enumerates the list of installed local and network printers.
56 virtual bool EnumeratePrinters(PrinterList* printer_list) = 0; 70 virtual bool EnumeratePrinters(PrinterList* printer_list) = 0;
57 71
58 // Get the default printer name. Empty string if no default printer. 72 // Get the default printer name. Empty string if no default printer.
59 virtual std::string GetDefaultPrinterName() = 0; 73 virtual std::string GetDefaultPrinterName() = 0;
60 74
75 // Gets the semantic capabilities and defaults for a specific printer.
76 // This is usually a lighter implementation than GetPrinterCapsAndDefaults().
77 // NOTE: on some old platforms (WinXP without XPS pack)
78 // GetPrinterCapsAndDefaults() will fail, while this function will succeed.
79 virtual bool GetPrinterSemanticCapsAndDefaults(
80 const std::string& printer_name,
81 PrinterSemanticCapsAndDefaults* printer_info) = 0;
82
61 // Gets the capabilities and defaults for a specific printer. 83 // Gets the capabilities and defaults for a specific printer.
62 virtual bool GetPrinterCapsAndDefaults( 84 virtual bool GetPrinterCapsAndDefaults(
63 const std::string& printer_name, 85 const std::string& printer_name,
64 PrinterCapsAndDefaults* printer_info) = 0; 86 PrinterCapsAndDefaults* printer_info) = 0;
65 87
66 // Gets the information about driver for a specific printer. 88 // Gets the information about driver for a specific printer.
67 virtual std::string GetPrinterDriverInfo( 89 virtual std::string GetPrinterDriverInfo(
68 const std::string& printer_name) = 0; 90 const std::string& printer_name) = 0;
69 91
70 // Returns true if printer_name points to a valid printer. 92 // Returns true if printer_name points to a valid printer.
71 virtual bool IsValidPrinter(const std::string& printer_name) = 0; 93 virtual bool IsValidPrinter(const std::string& printer_name) = 0;
72 94
73 // Allocate a print backend. If |print_backend_settings| is NULL, default 95 // Allocate a print backend. If |print_backend_settings| is NULL, default
74 // settings will be used. 96 // settings will be used.
75 // Return NULL if no print backend available. 97 // Return NULL if no print backend available.
76 static scoped_refptr<PrintBackend> CreateInstance( 98 static scoped_refptr<PrintBackend> CreateInstance(
77 const base::DictionaryValue* print_backend_settings); 99 const base::DictionaryValue* print_backend_settings);
78 100
79 protected: 101 protected:
80 friend class base::RefCountedThreadSafe<PrintBackend>; 102 friend class base::RefCountedThreadSafe<PrintBackend>;
81 virtual ~PrintBackend(); 103 virtual ~PrintBackend();
82 }; 104 };
83 105
84 } // namespace printing 106 } // namespace printing
85 107
86 #endif // PRINTING_BACKEND_PRINT_BACKEND_H_ 108 #endif // PRINTING_BACKEND_PRINT_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698