Upload upstream chromium 73.0.3683.0
[platform/framework/web/chromium-efl.git] / printing / printing_context_mac.h
1 // Copyright (c) 2011 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.
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/macros.h"
13 #include "printing/print_job_constants.h"
14 #include "printing/printing_context.h"
15
16 @class NSPrintInfo;
17
18 namespace printing {
19
20 class PRINTING_EXPORT PrintingContextMac : public PrintingContext {
21  public:
22   explicit PrintingContextMac(Delegate* delegate);
23   ~PrintingContextMac() override;
24
25   // PrintingContext implementation.
26   void AskUserForSettings(int max_pages,
27                           bool has_selection,
28                           bool is_scripted,
29                           PrintSettingsCallback callback) override;
30   Result UseDefaultSettings() override;
31   gfx::Size GetPdfPaperSizeDeviceUnits() override;
32   Result UpdatePrinterSettings(bool external_preview,
33                                bool show_system_dialog,
34                                int page_count) override;
35   Result NewDocument(const base::string16& document_name) override;
36   Result NewPage() override;
37   Result PageDone() override;
38   Result DocumentDone() override;
39   void Cancel() override;
40   void ReleaseContext() override;
41   printing::NativeDrawingContext context() const override;
42
43  private:
44   // Initializes PrintSettings from |print_info_|. This must be called
45   // after changes to |print_info_| in order for the changes to take effect in
46   // printing.
47   // This function ignores the page range information specified in the print
48   // info object and use |settings_.ranges| instead.
49   void InitPrintSettingsFromPrintInfo();
50
51   // Returns the set of page ranges constructed from |print_info_|.
52   PageRanges GetPageRangesFromPrintInfo();
53
54   // Updates |print_info_| to use the given printer.
55   // Returns true if the printer was set.
56   bool SetPrinter(const std::string& device_name);
57
58   // Updates |print_info_| page format with paper selected by user. If paper was
59   // not selected, default system paper is used.
60   // Returns true if the paper was set.
61   bool UpdatePageFormatWithPaperInfo();
62
63   // Updates |print_info_| page format with |paper|.
64   // Returns true if the paper was set.
65   bool UpdatePageFormatWithPaper(PMPaper paper, PMPageFormat page_format);
66
67   // Sets the print job destination type as preview job.
68   // Returns true if the print job destination type is set.
69   bool SetPrintPreviewJob();
70
71   // Sets |copies| in PMPrintSettings.
72   // Returns true if the number of copies is set.
73   bool SetCopiesInPrintSettings(int copies);
74
75   // Sets |collate| in PMPrintSettings.
76   // Returns true if |collate| is set.
77   bool SetCollateInPrintSettings(bool collate);
78
79   // Sets orientation in native print info object.
80   // Returns true if the orientation was set.
81   bool SetOrientationIsLandscape(bool landscape);
82
83   // Sets duplex mode in PMPrintSettings.
84   // Returns true if duplex mode is set.
85   bool SetDuplexModeInPrintSettings(DuplexMode mode);
86
87   // Sets output color mode in PMPrintSettings.
88   // Returns true if color mode is set.
89   bool SetOutputColor(int color_mode);
90
91   // The native print info object.
92   base::scoped_nsobject<NSPrintInfo> print_info_;
93
94   // The current page's context; only valid between NewPage and PageDone call
95   // pairs.
96   CGContext* context_;
97
98   DISALLOW_COPY_AND_ASSIGN(PrintingContextMac);
99 };
100
101 }  // namespace printing
102
103 #endif  // PRINTING_PRINTING_CONTEXT_MAC_H_