OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "printing/printing_context_cairo.h" | 5 #include "printing/printing_context_cairo.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "printing/print_job_constants.h" | 9 #include "printing/print_job_constants.h" |
10 #include "printing/print_settings_initializer_gtk.h" | 10 #include "printing/print_settings_initializer_gtk.h" |
11 #include "printing/units.h" | 11 #include "printing/units.h" |
12 | 12 |
13 #if defined(OS_CHROMEOS) | 13 #if defined(OS_CHROMEOS) |
14 #include <unicode/ulocdata.h> | 14 #include <unicode/ulocdata.h> |
15 #else | 15 #else |
16 #include <gtk/gtk.h> | 16 #include <gtk/gtk.h> |
17 #include <gtk/gtkprintunixdialog.h> | 17 #include <gtk/gtkprintunixdialog.h> |
18 #endif // defined(OS_CHROMEOS) | 18 #endif // defined(OS_CHROMEOS) |
19 | 19 |
20 #if !defined(OS_CHROMEOS) | 20 #if !defined(OS_CHROMEOS) |
21 namespace { | 21 namespace { |
22 // Function pointer for creating print dialogs. | 22 // Function pointer for creating print dialogs. |
23 static void* (*create_dialog_func_)( | 23 static void* (*create_dialog_func_)( |
24 printing::PrintingContext::PrintSettingsCallback* callback, | 24 printing::PrintingContext::PrintSettingsCallback* callback, |
25 printing::PrintingContextCairo* context) = NULL; | 25 printing::PrintingContextCairo* context) = NULL; |
26 // Function pointer for printing documents. | 26 // Function pointer for printing documents. |
27 static void (*print_document_func_)( | 27 static void (*print_document_func_)( |
28 void* print_dialog, | 28 void* print_dialog, |
29 const printing::NativeMetafile* metafile, | 29 const printing::Metafile* metafile, |
30 const string16& document_name) = NULL; | 30 const string16& document_name) = NULL; |
31 } // namespace | 31 } // namespace |
32 #endif // !defined(OS_CHROMEOS) | 32 #endif // !defined(OS_CHROMEOS) |
33 | 33 |
34 namespace printing { | 34 namespace printing { |
35 | 35 |
36 // static | 36 // static |
37 PrintingContext* PrintingContext::Create(const std::string& app_locale) { | 37 PrintingContext* PrintingContext::Create(const std::string& app_locale) { |
38 return static_cast<PrintingContext*>(new PrintingContextCairo(app_locale)); | 38 return static_cast<PrintingContext*>(new PrintingContextCairo(app_locale)); |
39 } | 39 } |
(...skipping 10 matching lines...) Expand all Loading... |
50 PrintingContextCairo::~PrintingContextCairo() { | 50 PrintingContextCairo::~PrintingContextCairo() { |
51 ReleaseContext(); | 51 ReleaseContext(); |
52 } | 52 } |
53 | 53 |
54 #if !defined(OS_CHROMEOS) | 54 #if !defined(OS_CHROMEOS) |
55 // static | 55 // static |
56 void PrintingContextCairo::SetPrintingFunctions( | 56 void PrintingContextCairo::SetPrintingFunctions( |
57 void* (*create_dialog_func)(PrintSettingsCallback* callback, | 57 void* (*create_dialog_func)(PrintSettingsCallback* callback, |
58 PrintingContextCairo* context), | 58 PrintingContextCairo* context), |
59 void (*print_document_func)(void* print_dialog, | 59 void (*print_document_func)(void* print_dialog, |
60 const NativeMetafile* metafile, | 60 const Metafile* metafile, |
61 const string16& document_name)) { | 61 const string16& document_name)) { |
62 DCHECK(create_dialog_func); | 62 DCHECK(create_dialog_func); |
63 DCHECK(print_document_func); | 63 DCHECK(print_document_func); |
64 DCHECK(!create_dialog_func_); | 64 DCHECK(!create_dialog_func_); |
65 DCHECK(!print_document_func_); | 65 DCHECK(!print_document_func_); |
66 create_dialog_func_ = create_dialog_func; | 66 create_dialog_func_ = create_dialog_func; |
67 print_document_func_ = print_document_func; | 67 print_document_func_ = print_document_func; |
68 } | 68 } |
69 | 69 |
70 void PrintingContextCairo::PrintDocument(const NativeMetafile* metafile) { | 70 void PrintingContextCairo::PrintDocument(const Metafile* metafile) { |
71 DCHECK(print_dialog_); | 71 DCHECK(print_dialog_); |
72 DCHECK(metafile); | 72 DCHECK(metafile); |
73 print_document_func_(print_dialog_, metafile, document_name_); | 73 print_document_func_(print_dialog_, metafile, document_name_); |
74 } | 74 } |
75 #endif // !defined(OS_CHROMEOS) | 75 #endif // !defined(OS_CHROMEOS) |
76 | 76 |
77 void PrintingContextCairo::AskUserForSettings( | 77 void PrintingContextCairo::AskUserForSettings( |
78 gfx::NativeView parent_view, | 78 gfx::NativeView parent_view, |
79 int max_pages, | 79 int max_pages, |
80 bool has_selection, | 80 bool has_selection, |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 void PrintingContextCairo::ReleaseContext() { | 224 void PrintingContextCairo::ReleaseContext() { |
225 // Intentional No-op. | 225 // Intentional No-op. |
226 } | 226 } |
227 | 227 |
228 gfx::NativeDrawingContext PrintingContextCairo::context() const { | 228 gfx::NativeDrawingContext PrintingContextCairo::context() const { |
229 // Intentional No-op. | 229 // Intentional No-op. |
230 return NULL; | 230 return NULL; |
231 } | 231 } |
232 | 232 |
233 } // namespace printing | 233 } // namespace printing |
OLD | NEW |