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
3 // found in the LICENSE file.
5 #ifndef PRINTING_BACKEND_PRINT_BACKEND_H_
6 #define PRINTING_BACKEND_PRINT_BACKEND_H_
12 #include "base/memory/ref_counted.h"
13 #include "printing/print_job_constants.h"
14 #include "printing/printing_export.h"
17 class DictionaryValue
;
20 // This is the interface for platform-specific code for a print backend
23 struct PRINTING_EXPORT PrinterBasicInfo
{
27 std::string printer_name
;
28 std::string printer_description
;
31 std::map
<std::string
, std::string
> options
;
34 typedef std::vector
<PrinterBasicInfo
> PrinterList
;
36 struct PRINTING_EXPORT PrinterSemanticCapsAndDefaults
{
37 PrinterSemanticCapsAndDefaults();
38 ~PrinterSemanticCapsAndDefaults();
41 bool color_changeable
;
45 ColorModel color_model
;
51 DuplexMode duplex_default
;
54 struct PRINTING_EXPORT PrinterCapsAndDefaults
{
55 PrinterCapsAndDefaults();
56 ~PrinterCapsAndDefaults();
58 std::string printer_capabilities
;
59 std::string caps_mime_type
;
60 std::string printer_defaults
;
61 std::string defaults_mime_type
;
64 // PrintBackend class will provide interface for different print backends
65 // (Windows, CUPS) to implement. User will call CreateInstance() to
66 // obtain available print backend.
67 // Please note, that PrintBackend is not platform specific, but rather
68 // print system specific. For example, CUPS is available on both Linux and Mac,
69 // but not available on ChromeOS, etc. This design allows us to add more
70 // functionality on some platforms, while reusing core (CUPS) functions.
71 class PRINTING_EXPORT PrintBackend
72 : public base::RefCountedThreadSafe
<PrintBackend
> {
74 // Enumerates the list of installed local and network printers.
75 virtual bool EnumeratePrinters(PrinterList
* printer_list
) = 0;
77 // Get the default printer name. Empty string if no default printer.
78 virtual std::string
GetDefaultPrinterName() = 0;
80 // Gets the semantic capabilities and defaults for a specific printer.
81 // This is usually a lighter implementation than GetPrinterCapsAndDefaults().
82 // NOTE: on some old platforms (WinXP without XPS pack)
83 // GetPrinterCapsAndDefaults() will fail, while this function will succeed.
84 virtual bool GetPrinterSemanticCapsAndDefaults(
85 const std::string
& printer_name
,
86 PrinterSemanticCapsAndDefaults
* printer_info
) = 0;
88 // Gets the capabilities and defaults for a specific printer.
89 virtual bool GetPrinterCapsAndDefaults(
90 const std::string
& printer_name
,
91 PrinterCapsAndDefaults
* printer_info
) = 0;
93 // Gets the information about driver for a specific printer.
94 virtual std::string
GetPrinterDriverInfo(
95 const std::string
& printer_name
) = 0;
97 // Returns true if printer_name points to a valid printer.
98 virtual bool IsValidPrinter(const std::string
& printer_name
) = 0;
100 // Allocate a print backend. If |print_backend_settings| is NULL, default
101 // settings will be used.
102 // Return NULL if no print backend available.
103 static scoped_refptr
<PrintBackend
> CreateInstance(
104 const base::DictionaryValue
* print_backend_settings
);
107 friend class base::RefCountedThreadSafe
<PrintBackend
>;
108 virtual ~PrintBackend();
111 } // namespace printing
113 #endif // PRINTING_BACKEND_PRINT_BACKEND_H_