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