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_
10 #include "base/memory/scoped_nsobject.h"
11 #include "printing/printing_context.h"
12 #include "printing/print_job_constants.h"
22 class PrintingContextMac
: public PrintingContext
{
24 explicit PrintingContextMac(const std::string
& app_locale
);
25 virtual ~PrintingContextMac();
27 // PrintingContext implementation.
28 virtual void AskUserForSettings(gfx::NativeView parent_view
,
31 PrintSettingsCallback
* callback
);
32 virtual Result
UseDefaultSettings();
33 virtual Result
UpdatePrintSettings(const base::DictionaryValue
& job_settings
,
34 const PageRanges
& ranges
);
35 virtual Result
InitWithSettings(const PrintSettings
& settings
);
36 virtual Result
NewDocument(const string16
& document_name
);
37 virtual Result
NewPage();
38 virtual Result
PageDone();
39 virtual Result
DocumentDone();
40 virtual void Cancel();
41 virtual void ReleaseContext();
42 virtual gfx::NativeDrawingContext
context() const;
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
48 // This function ignores the page range information specified in the print
49 // info object and use |ranges| instead.
50 void InitPrintSettingsFromPrintInfo(const PageRanges
& ranges
);
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 else returns false.
57 bool SetPrinter(const std::string
& device_name
);
59 // Sets |copies| in PMPrintSettings.
60 // Returns true if the number of copies is set.
61 bool SetCopiesInPrintSettings(int copies
);
63 // Sets |collate| in PMPrintSettings.
64 // Returns true if |collate| is set.
65 bool SetCollateInPrintSettings(bool collate
);
67 // Sets orientation in native print info object.
68 // Returns true if the orientation was set.
69 bool SetOrientationIsLandscape(bool landscape
);
71 // Sets duplex mode in PMPrintSettings.
72 // Returns true if duplex mode is set.
73 bool SetDuplexModeInPrintSettings(DuplexMode mode
);
75 // Sets output color mode in PMPrintSettings.
76 // Returns true if color mode is set.
77 bool SetOutputIsColor(bool color
);
79 // The native print info object.
80 scoped_nsobject
<NSPrintInfo
> print_info_
;
82 // The current page's context; only valid between NewPage and PageDone call
86 DISALLOW_COPY_AND_ASSIGN(PrintingContextMac
);
89 } // namespace printing
91 #endif // PRINTING_PRINTING_CONTEXT_MAC_H_