Call _set_FMA3_enable(0); to work around VS 2013 CRT AVX bug.
[chromium-blink-merge.git] / printing / printing_context_mac.h
blob561b25d4794032aa71b2612b4f57c6cbab1106e9
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 <string>
10 #include "base/mac/scoped_nsobject.h"
11 #include "printing/print_job_constants.h"
12 #include "printing/printing_context.h"
14 #ifdef __OBJC__
15 @class NSPrintInfo;
16 #else
17 class NSPrintInfo;
18 #endif // __OBJC__
20 namespace printing {
22 class PRINTING_EXPORT PrintingContextMac : public PrintingContext {
23 public:
24 explicit PrintingContextMac(Delegate* delegate);
25 ~PrintingContextMac() override;
27 // PrintingContext implementation.
28 void AskUserForSettings(int max_pages,
29 bool has_selection,
30 const PrintSettingsCallback& callback) override;
31 Result UseDefaultSettings() override;
32 gfx::Size GetPdfPaperSizeDeviceUnits() override;
33 Result UpdatePrinterSettings(bool external_preview,
34 bool show_system_dialog) override;
35 Result InitWithSettings(const PrintSettings& settings) override;
36 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;
42 gfx::NativeDrawingContext context() const override;
44 private:
45 // 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
49 // info object and use |settings_.ranges| instead.
50 void InitPrintSettingsFromPrintInfo();
52 // Returns the set of page ranges constructed from |print_info_|.
53 PageRanges GetPageRangesFromPrintInfo();
55 // Updates |print_info_| to use the given printer.
56 // Returns true if the printer was set.
57 bool SetPrinter(const std::string& device_name);
59 // 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.
62 bool UpdatePageFormatWithPaperInfo();
64 // Updates |print_info_| page format with |paper|.
65 // Returns true if the paper was set.
66 bool UpdatePageFormatWithPaper(PMPaper paper, PMPageFormat page_format);
68 // Sets the print job destination type as preview job.
69 // Returns true if the print job destination type is set.
70 bool SetPrintPreviewJob();
72 // Sets |copies| in PMPrintSettings.
73 // Returns true if the number of copies is set.
74 bool SetCopiesInPrintSettings(int copies);
76 // Sets |collate| in PMPrintSettings.
77 // Returns true if |collate| is set.
78 bool SetCollateInPrintSettings(bool collate);
80 // Sets orientation in native print info object.
81 // Returns true if the orientation was set.
82 bool SetOrientationIsLandscape(bool landscape);
84 // Sets duplex mode in PMPrintSettings.
85 // Returns true if duplex mode is set.
86 bool SetDuplexModeInPrintSettings(DuplexMode mode);
88 // Sets output color mode in PMPrintSettings.
89 // Returns true if color mode is set.
90 bool SetOutputColor(int color_mode);
92 // The native print info object.
93 base::scoped_nsobject<NSPrintInfo> print_info_;
95 // The current page's context; only valid between NewPage and PageDone call
96 // pairs.
97 CGContext* context_;
99 DISALLOW_COPY_AND_ASSIGN(PrintingContextMac);
102 } // namespace printing
104 #endif // PRINTING_PRINTING_CONTEXT_MAC_H_