blob: 06cdc0e1a4a50e29a148c97c964c30a939e800da [file] [log] [blame]
[email protected]7868ecab2011-03-05 00:12:531// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]51e8d9352010-10-06 22:21:172// 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
tapted05d4a5b2015-05-04 07:20:128#include <ApplicationServices/ApplicationServices.h>
[email protected]ee5f36e42010-12-03 22:40:379#include <string>
10
[email protected]a8522032013-06-24 22:51:4611#include "base/mac/scoped_nsobject.h"
avi126e93c2015-12-21 21:48:1612#include "base/macros.h"
Julie Jeongeun Kime454f2602020-04-30 05:20:0713#include "printing/mojom/print.mojom.h"
[email protected]a44b0c142011-04-26 15:46:1014#include "printing/print_job_constants.h"
[email protected]a8522032013-06-24 22:51:4615#include "printing/printing_context.h"
[email protected]51e8d9352010-10-06 22:21:1716
[email protected]51e8d9352010-10-06 22:21:1717@class NSPrintInfo;
[email protected]51e8d9352010-10-06 22:21:1718
19namespace printing {
20
[email protected]69f5b1e62011-09-01 06:34:0421class PRINTING_EXPORT PrintingContextMac : public PrintingContext {
[email protected]51e8d9352010-10-06 22:21:1722 public:
Vitaly Bukabd7c9812014-08-26 08:57:5423 explicit PrintingContextMac(Delegate* delegate);
dchengd5a0f182014-10-22 00:04:3424 ~PrintingContextMac() override;
[email protected]51e8d9352010-10-06 22:21:1725
26 // PrintingContext implementation.
dchengd5a0f182014-10-22 00:04:3427 void AskUserForSettings(int max_pages,
28 bool has_selection,
dgn4c172eea2014-12-15 21:11:2329 bool is_scripted,
Vladislav Kuzkokov48ceab22018-02-14 16:29:2830 PrintSettingsCallback callback) override;
dchengd5a0f182014-10-22 00:04:3431 Result UseDefaultSettings() override;
32 gfx::Size GetPdfPaperSizeDeviceUnits() override;
33 Result UpdatePrinterSettings(bool external_preview,
vitalybuka95fa3c92015-05-05 03:03:3234 bool show_system_dialog,
35 int page_count) override;
dchengd5a0f182014-10-22 00:04:3436 Result NewDocument(const base::string16& document_name) override;
37 Result NewPage() override;
38 Result PageDone() override;
39 Result DocumentDone() override;
40 void Cancel() override;
41 void ReleaseContext() override;
Nico Weber8e559562017-10-03 01:25:2642 printing::NativeDrawingContext context() const override;
[email protected]51e8d9352010-10-06 22:21:1743
44 private:
[email protected]4274861a2011-06-03 19:27:0045 // Initializes PrintSettings from |print_info_|. This must be called
46 // after changes to |print_info_| in order for the changes to take effect in
47 // printing.
48 // This function ignores the page range information specified in the print
[email protected]e5324b52013-10-29 03:16:3749 // info object and use |settings_.ranges| instead.
50 void InitPrintSettingsFromPrintInfo();
[email protected]89f5aa8c2011-03-21 20:58:4451
[email protected]4274861a2011-06-03 19:27:0052 // Returns the set of page ranges constructed from |print_info_|.
53 PageRanges GetPageRangesFromPrintInfo();
54
[email protected]36fbeee22011-03-23 16:35:1255 // Updates |print_info_| to use the given printer.
[email protected]f106a212014-06-20 05:02:3756 // Returns true if the printer was set.
[email protected]987e51f92011-05-04 21:10:1557 bool SetPrinter(const std::string& device_name);
[email protected]36fbeee22011-03-23 16:35:1258
[email protected]f106a212014-06-20 05:02:3759 // Updates |print_info_| page format with paper selected by user. If paper was
60 // not selected, default system paper is used.
61 // Returns true if the paper was set.
[email protected]4ed1df62011-11-02 02:32:5762 bool UpdatePageFormatWithPaperInfo();
63
[email protected]f106a212014-06-20 05:02:3764 // Updates |print_info_| page format with |paper|.
65 // Returns true if the paper was set.
66 bool UpdatePageFormatWithPaper(PMPaper paper, PMPageFormat page_format);
67
[email protected]97c295752011-11-17 00:44:3768 // Sets the print job destination type as preview job.
69 // Returns true if the print job destination type is set.
70 bool SetPrintPreviewJob();
71
[email protected]c97e5e82011-04-05 18:50:2372 // Sets |copies| in PMPrintSettings.
73 // Returns true if the number of copies is set.
74 bool SetCopiesInPrintSettings(int copies);
75
76 // Sets |collate| in PMPrintSettings.
77 // Returns true if |collate| is set.
78 bool SetCollateInPrintSettings(bool collate);
79
[email protected]d2034862011-04-05 20:03:3180 // Sets orientation in native print info object.
81 // Returns true if the orientation was set.
82 bool SetOrientationIsLandscape(bool landscape);
83
[email protected]770f9062011-04-07 16:22:1384 // Sets duplex mode in PMPrintSettings.
85 // Returns true if duplex mode is set.
Julie Jeongeun Kime454f2602020-04-30 05:20:0786 bool SetDuplexModeInPrintSettings(mojom::DuplexMode mode);
[email protected]770f9062011-04-07 16:22:1387
[email protected]c7b3c632011-04-12 19:36:1988 // Sets output color mode in PMPrintSettings.
89 // Returns true if color mode is set.
[email protected]f3256b0d82011-09-04 23:36:2990 bool SetOutputColor(int color_mode);
[email protected]c7b3c632011-04-12 19:36:1991
[email protected]51e8d9352010-10-06 22:21:1792 // The native print info object.
[email protected]a8522032013-06-24 22:51:4693 base::scoped_nsobject<NSPrintInfo> print_info_;
[email protected]51e8d9352010-10-06 22:21:1794
95 // The current page's context; only valid between NewPage and PageDone call
96 // pairs.
97 CGContext* context_;
98
99 DISALLOW_COPY_AND_ASSIGN(PrintingContextMac);
100};
101
102} // namespace printing
103
104#endif // PRINTING_PRINTING_CONTEXT_MAC_H_