[email protected] | 7868ecab | 2011-03-05 00:12:53 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 2 | // 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 | |||||
[email protected] | ee5f36e4 | 2010-12-03 22:40:37 | [diff] [blame] | 8 | #include <string> |
9 | |||||
[email protected] | a7d7b63 | 2011-03-15 21:55:02 | [diff] [blame] | 10 | #include "base/scoped_nsobject.h" |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 11 | #include "printing/printing_context.h" |
12 | |||||
13 | #ifdef __OBJC__ | ||||
14 | @class NSPrintInfo; | ||||
15 | #else | ||||
16 | class NSPrintInfo; | ||||
17 | #endif // __OBJC__ | ||||
18 | |||||
19 | namespace printing { | ||||
20 | |||||
21 | class PrintingContextMac : public PrintingContext { | ||||
22 | public: | ||||
[email protected] | ee5f36e4 | 2010-12-03 22:40:37 | [diff] [blame] | 23 | explicit PrintingContextMac(const std::string& app_locale); |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 24 | ~PrintingContextMac(); |
25 | |||||
26 | // PrintingContext implementation. | ||||
27 | virtual void AskUserForSettings(gfx::NativeView parent_view, | ||||
28 | int max_pages, | ||||
29 | bool has_selection, | ||||
30 | PrintSettingsCallback* callback); | ||||
31 | virtual Result UseDefaultSettings(); | ||||
[email protected] | c82d3f21 | 2011-03-22 01:18:30 | [diff] [blame^] | 32 | virtual Result UpdatePrintSettings(const DictionaryValue& job_settings, |
[email protected] | 89f5aa8c | 2011-03-21 20:58:44 | [diff] [blame] | 33 | const PageRanges& ranges); |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 34 | virtual Result InitWithSettings(const PrintSettings& settings); |
35 | virtual Result NewDocument(const string16& document_name); | ||||
36 | virtual Result NewPage(); | ||||
37 | virtual Result PageDone(); | ||||
38 | virtual Result DocumentDone(); | ||||
39 | virtual void Cancel(); | ||||
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 40 | virtual void ReleaseContext(); |
41 | virtual gfx::NativeDrawingContext context() const; | ||||
42 | |||||
43 | private: | ||||
44 | // Read the settings from the given NSPrintInfo (and cache it for later use). | ||||
45 | void ParsePrintInfo(NSPrintInfo* print_info); | ||||
46 | |||||
[email protected] | 89f5aa8c | 2011-03-21 20:58:44 | [diff] [blame] | 47 | // Initializes PrintSettings from native print info object. |
48 | void InitPrintSettingsFromPrintInfo(const PageRanges& ranges); | ||||
49 | |||||
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 50 | // The native print info object. |
[email protected] | a7d7b63 | 2011-03-15 21:55:02 | [diff] [blame] | 51 | scoped_nsobject<NSPrintInfo> print_info_; |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 52 | |
53 | // The current page's context; only valid between NewPage and PageDone call | ||||
54 | // pairs. | ||||
55 | CGContext* context_; | ||||
56 | |||||
57 | DISALLOW_COPY_AND_ASSIGN(PrintingContextMac); | ||||
58 | }; | ||||
59 | |||||
60 | } // namespace printing | ||||
61 | |||||
62 | #endif // PRINTING_PRINTING_CONTEXT_MAC_H_ |