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"
15 #include "ui/gfx/geometry/size.h"
18 class DictionaryValue
;
21 // This is the interface for platform-specific code for a print backend
24 struct PRINTING_EXPORT PrinterBasicInfo
{
28 std::string printer_name
;
29 std::string printer_description
;
32 std::map
<std::string
, std::string
> options
;
35 typedef std::vector
<PrinterBasicInfo
> PrinterList
;
37 struct PRINTING_EXPORT PrinterSemanticCapsAndDefaults
{
38 PrinterSemanticCapsAndDefaults();
39 ~PrinterSemanticCapsAndDefaults();
41 bool color_changeable
;
45 ColorModel color_model
;
60 std::vector
<Paper
> papers
;
63 std::vector
<gfx::Size
> dpis
;
64 gfx::Size default_dpi
;
68 DuplexMode duplex_default
;
71 struct PRINTING_EXPORT PrinterCapsAndDefaults
{
72 PrinterCapsAndDefaults();
73 ~PrinterCapsAndDefaults();
75 std::string printer_capabilities
;
76 std::string caps_mime_type
;
77 std::string printer_defaults
;
78 std::string defaults_mime_type
;
81 // PrintBackend class will provide interface for different print backends
82 // (Windows, CUPS) to implement. User will call CreateInstance() to
83 // obtain available print backend.
84 // Please note, that PrintBackend is not platform specific, but rather
85 // print system specific. For example, CUPS is available on both Linux and Mac,
86 // but not available on ChromeOS, etc. This design allows us to add more
87 // functionality on some platforms, while reusing core (CUPS) functions.
88 class PRINTING_EXPORT PrintBackend
89 : public base::RefCountedThreadSafe
<PrintBackend
> {
91 // Enumerates the list of installed local and network printers.
92 virtual bool EnumeratePrinters(PrinterList
* printer_list
) = 0;
94 // Get the default printer name. Empty string if no default printer.
95 virtual std::string
GetDefaultPrinterName() = 0;
97 // Gets the semantic capabilities and defaults for a specific printer.
98 // This is usually a lighter implementation than GetPrinterCapsAndDefaults().
99 // NOTE: on some old platforms (WinXP without XPS pack)
100 // GetPrinterCapsAndDefaults() will fail, while this function will succeed.
101 virtual bool GetPrinterSemanticCapsAndDefaults(
102 const std::string
& printer_name
,
103 PrinterSemanticCapsAndDefaults
* printer_info
) = 0;
105 // Gets the capabilities and defaults for a specific printer.
106 virtual bool GetPrinterCapsAndDefaults(
107 const std::string
& printer_name
,
108 PrinterCapsAndDefaults
* printer_info
) = 0;
110 // Gets the information about driver for a specific printer.
111 virtual std::string
GetPrinterDriverInfo(
112 const std::string
& printer_name
) = 0;
114 // Returns true if printer_name points to a valid printer.
115 virtual bool IsValidPrinter(const std::string
& printer_name
) = 0;
117 // Allocate a print backend. If |print_backend_settings| is NULL, default
118 // settings will be used.
119 // Return NULL if no print backend available.
120 static scoped_refptr
<PrintBackend
> CreateInstance(
121 const base::DictionaryValue
* print_backend_settings
);
124 friend class base::RefCountedThreadSafe
<PrintBackend
>;
125 virtual ~PrintBackend();
128 } // namespace printing
130 #endif // PRINTING_BACKEND_PRINT_BACKEND_H_