Introduce 'url::SchemeHostPort'.
[chromium-blink-merge.git] / printing / printing_context_mac.h
blobacccff3f773181566e827317a169ce98e388dac6
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.
5 #ifndef PRINTING_PRINTING_CONTEXT_MAC_H_
6 #define PRINTING_PRINTING_CONTEXT_MAC_H_
8 #include <ApplicationServices/ApplicationServices.h>
9 #include <string>
11 #include "base/mac/scoped_nsobject.h"
12 #include "printing/print_job_constants.h"
13 #include "printing/printing_context.h"
15 @class NSPrintInfo;
17 namespace printing {
19 class PRINTING_EXPORT PrintingContextMac : public PrintingContext {
20 public:
21 explicit PrintingContextMac(Delegate* delegate);
22 ~PrintingContextMac() override;
24 // PrintingContext implementation.
25 void AskUserForSettings(int max_pages,
26 bool has_selection,
27 bool is_scripted,
28 const PrintSettingsCallback& callback) override;
29 Result UseDefaultSettings() override;
30 gfx::Size GetPdfPaperSizeDeviceUnits() override;
31 Result UpdatePrinterSettings(bool external_preview,
32 bool show_system_dialog,
33 int page_count) override;
34 Result InitWithSettings(const PrintSettings& settings) 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 gfx::NativeDrawingContext context() const override;
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();
51 // Returns the set of page ranges constructed from |print_info_|.
52 PageRanges GetPageRangesFromPrintInfo();
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);
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();
63 // Updates |print_info_| page format with |paper|.
64 // Returns true if the paper was set.
65 bool UpdatePageFormatWithPaper(PMPaper paper, PMPageFormat page_format);
67 // Sets the print job destination type as preview job.
68 // Returns true if the print job destination type is set.
69 bool SetPrintPreviewJob();
71 // Sets |copies| in PMPrintSettings.
72 // Returns true if the number of copies is set.
73 bool SetCopiesInPrintSettings(int copies);
75 // Sets |collate| in PMPrintSettings.
76 // Returns true if |collate| is set.
77 bool SetCollateInPrintSettings(bool collate);
79 // Sets orientation in native print info object.
80 // Returns true if the orientation was set.
81 bool SetOrientationIsLandscape(bool landscape);
83 // Sets duplex mode in PMPrintSettings.
84 // Returns true if duplex mode is set.
85 bool SetDuplexModeInPrintSettings(DuplexMode mode);
87 // Sets output color mode in PMPrintSettings.
88 // Returns true if color mode is set.
89 bool SetOutputColor(int color_mode);
91 // The native print info object.
92 base::scoped_nsobject<NSPrintInfo> print_info_;
94 // The current page's context; only valid between NewPage and PageDone call
95 // pairs.
96 CGContext* context_;
98 DISALLOW_COPY_AND_ASSIGN(PrintingContextMac);
101 } // namespace printing
103 #endif // PRINTING_PRINTING_CONTEXT_MAC_H_