Fix the MediaDrmBridgeTest on android builds without Widevine support
[chromium-blink-merge.git] / printing / printing_context_mac.h
blob51a1a1cf5d80d78af46c67bf4b95ed67080127c0
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 bool is_scripted,
31 const PrintSettingsCallback& callback) override;
32 Result UseDefaultSettings() override;
33 gfx::Size GetPdfPaperSizeDeviceUnits() override;
34 Result UpdatePrinterSettings(bool external_preview,
35 bool show_system_dialog) override;
36 Result InitWithSettings(const PrintSettings& settings) override;
37 Result NewDocument(const base::string16& document_name) override;
38 Result NewPage() override;
39 Result PageDone() override;
40 Result DocumentDone() override;
41 void Cancel() override;
42 void ReleaseContext() override;
43 gfx::NativeDrawingContext context() const override;
45 private:
46 // Initializes PrintSettings from |print_info_|. This must be called
47 // after changes to |print_info_| in order for the changes to take effect in
48 // printing.
49 // This function ignores the page range information specified in the print
50 // info object and use |settings_.ranges| instead.
51 void InitPrintSettingsFromPrintInfo();
53 // Returns the set of page ranges constructed from |print_info_|.
54 PageRanges GetPageRangesFromPrintInfo();
56 // Updates |print_info_| to use the given printer.
57 // Returns true if the printer was set.
58 bool SetPrinter(const std::string& device_name);
60 // Updates |print_info_| page format with paper selected by user. If paper was
61 // not selected, default system paper is used.
62 // Returns true if the paper was set.
63 bool UpdatePageFormatWithPaperInfo();
65 // Updates |print_info_| page format with |paper|.
66 // Returns true if the paper was set.
67 bool UpdatePageFormatWithPaper(PMPaper paper, PMPageFormat page_format);
69 // Sets the print job destination type as preview job.
70 // Returns true if the print job destination type is set.
71 bool SetPrintPreviewJob();
73 // Sets |copies| in PMPrintSettings.
74 // Returns true if the number of copies is set.
75 bool SetCopiesInPrintSettings(int copies);
77 // Sets |collate| in PMPrintSettings.
78 // Returns true if |collate| is set.
79 bool SetCollateInPrintSettings(bool collate);
81 // Sets orientation in native print info object.
82 // Returns true if the orientation was set.
83 bool SetOrientationIsLandscape(bool landscape);
85 // Sets duplex mode in PMPrintSettings.
86 // Returns true if duplex mode is set.
87 bool SetDuplexModeInPrintSettings(DuplexMode mode);
89 // Sets output color mode in PMPrintSettings.
90 // Returns true if color mode is set.
91 bool SetOutputColor(int color_mode);
93 // The native print info object.
94 base::scoped_nsobject<NSPrintInfo> print_info_;
96 // The current page's context; only valid between NewPage and PageDone call
97 // pairs.
98 CGContext* context_;
100 DISALLOW_COPY_AND_ASSIGN(PrintingContextMac);
103 } // namespace printing
105 #endif // PRINTING_PRINTING_CONTEXT_MAC_H_