Enable chrome with aura for tizen
[platform/framework/web/chromium-efl.git] / printing / printing_context_mac.h
1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef PRINTING_PRINTING_CONTEXT_MAC_H_
6 #define PRINTING_PRINTING_CONTEXT_MAC_H_
7
8 #include <ApplicationServices/ApplicationServices.h>
9 #include <string>
10
11 #include "base/mac/scoped_nsobject.h"
12 #include "base/strings/string_piece.h"
13 #include "printing/mojom/print.mojom.h"
14 #include "printing/print_job_constants.h"
15 #include "printing/printing_context.h"
16
17 @class NSPrintInfo;
18
19 namespace printing {
20
21 class COMPONENT_EXPORT(PRINTING) PrintingContextMac : public PrintingContext {
22  public:
23   explicit PrintingContextMac(Delegate* delegate);
24   PrintingContextMac(const PrintingContextMac&) = delete;
25   PrintingContextMac& operator=(const PrintingContextMac&) = delete;
26   ~PrintingContextMac() override;
27
28   // PrintingContext implementation.
29   void AskUserForSettings(int max_pages,
30                           bool has_selection,
31                           bool is_scripted,
32                           PrintSettingsCallback callback) override;
33   mojom::ResultCode UseDefaultSettings() override;
34   gfx::Size GetPdfPaperSizeDeviceUnits() override;
35   mojom::ResultCode UpdatePrinterSettings(
36       const PrinterSettings& printer_settings) override;
37   mojom::ResultCode NewDocument(const std::u16string& document_name) override;
38   mojom::ResultCode PrintDocument(const MetafilePlayer& metafile,
39                                   const PrintSettings& settings,
40                                   uint32_t num_pages) override;
41   mojom::ResultCode DocumentDone() override;
42   void Cancel() override;
43   void ReleaseContext() override;
44   printing::NativeDrawingContext context() const override;
45
46  private:
47   // Initializes PrintSettings from `print_info_`. This must be called
48   // after changes to `print_info_` in order for the changes to take effect in
49   // printing.
50   // This function ignores the page range information specified in the print
51   // info object and use `settings_.ranges` instead.
52   void InitPrintSettingsFromPrintInfo();
53
54   // Returns the set of page ranges constructed from `print_info_`.
55   PageRanges GetPageRangesFromPrintInfo();
56
57   // Updates `print_info_` to use the given printer.
58   // Returns true if the printer was set.
59   bool SetPrinter(const std::string& device_name);
60
61   // Updates `print_info_` page format with paper selected by user. If paper was
62   // not selected, default system paper is used.
63   // Returns true if the paper was set.
64   bool UpdatePageFormatWithPaperInfo();
65
66   // Updates `print_info_` page format with `paper`.
67   // Returns true if the paper was set.
68   bool UpdatePageFormatWithPaper(PMPaper paper, PMPageFormat page_format);
69
70   // Sets the print job destination type as preview job.
71   // Returns true if the print job destination type is set.
72   bool SetPrintPreviewJob();
73
74   // Sets `copies` in PMPrintSettings.
75   // Returns true if the number of copies is set.
76   bool SetCopiesInPrintSettings(int copies);
77
78   // Sets `collate` in PMPrintSettings.
79   // Returns true if `collate` is set.
80   bool SetCollateInPrintSettings(bool collate);
81
82   // Sets orientation in native print info object.
83   // Returns true if the orientation was set.
84   bool SetOrientationIsLandscape(bool landscape);
85
86   // Sets duplex mode in PMPrintSettings.
87   // Returns true if duplex mode is set.
88   bool SetDuplexModeInPrintSettings(mojom::DuplexMode mode);
89
90   // Sets output color mode in PMPrintSettings.
91   // Returns true if color mode is set.
92   bool SetOutputColor(int color_mode);
93
94   // Sets resolution in PMPrintSettings.
95   // Returns true if resolution is set.
96   bool SetResolution(const gfx::Size& dpi_size);
97
98   // Sets key-value pair in PMPrintSettings.
99   // Returns true is the pair is set.
100   bool SetKeyValue(base::StringPiece key, base::StringPiece value);
101
102   // Starts a new page.
103   mojom::ResultCode NewPage();
104
105   // Closes the printed page.
106   mojom::ResultCode PageDone();
107
108   // The native print info object.
109   base::scoped_nsobject<NSPrintInfo> print_info_;
110
111   // The current page's context; only valid between NewPage and PageDone call
112   // pairs.
113   CGContext* context_;
114 };
115
116 }  // namespace printing
117
118 #endif  // PRINTING_PRINTING_CONTEXT_MAC_H_