OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_win.h" | 5 #include "printing/printing_context_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/free_deleter.h" | 10 #include "base/memory/free_deleter.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "printing/backend/print_backend.h" | 14 #include "printing/backend/print_backend.h" |
15 #include "printing/backend/win_helper.h" | 15 #include "printing/backend/win_helper.h" |
16 #include "printing/print_settings_initializer_win.h" | 16 #include "printing/print_settings_initializer_win.h" |
17 #include "printing/printed_document.h" | 17 #include "printing/printed_document.h" |
18 #include "printing/printing_context_system_dialog_win.h" | 18 #include "printing/printing_context_system_dialog_win.h" |
19 #include "printing/printing_utils.h" | 19 #include "printing/printing_utils.h" |
20 #include "printing/units.h" | 20 #include "printing/units.h" |
21 #include "skia/ext/skia_utils_win.h" | 21 #include "skia/ext/skia_utils_win.h" |
22 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
23 #include "ui/aura/window_tree_host.h" | 23 #include "ui/aura/window_tree_host.h" |
24 | 24 |
25 namespace printing { | 25 namespace printing { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 void AssingResult(PrintingContext::Result* out, PrintingContext::Result in) { | 29 void AssignResult(PrintingContext::Result* out, PrintingContext::Result in) { |
30 *out = in; | 30 *out = in; |
31 } | 31 } |
32 | 32 |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 // static | 35 // static |
36 std::unique_ptr<PrintingContext> PrintingContext::Create(Delegate* delegate) { | 36 std::unique_ptr<PrintingContext> PrintingContext::Create(Delegate* delegate) { |
37 #if defined(ENABLE_BASIC_PRINTING) | 37 #if defined(ENABLE_BASIC_PRINTING) |
38 return base::WrapUnique(new PrintingContextSytemDialogWin(delegate)); | 38 return base::WrapUnique(new PrintingContextSystemDialogWin(delegate)); |
39 #else // ENABLE_BASIC_PRINTING | 39 #else |
40 return base::WrapUnique(new PrintingContextWin(delegate)); | 40 return base::WrapUnique(new PrintingContextWin(delegate)); |
41 #endif // EENABLE_BASIC_PRINTING | 41 #endif |
42 } | 42 } |
43 | 43 |
44 PrintingContextWin::PrintingContextWin(Delegate* delegate) | 44 PrintingContextWin::PrintingContextWin(Delegate* delegate) |
45 : PrintingContext(delegate), context_(NULL) { | 45 : PrintingContext(delegate), context_(NULL) { |
46 } | 46 } |
47 | 47 |
48 PrintingContextWin::~PrintingContextWin() { | 48 PrintingContextWin::~PrintingContextWin() { |
49 ReleaseContext(); | 49 ReleaseContext(); |
50 } | 50 } |
51 | 51 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 dev_mode->dmPaperWidth = width; | 202 dev_mode->dmPaperWidth = width; |
203 dev_mode->dmFields |= DM_PAPERLENGTH; | 203 dev_mode->dmFields |= DM_PAPERLENGTH; |
204 dev_mode->dmPaperLength = height; | 204 dev_mode->dmPaperLength = height; |
205 } | 205 } |
206 } | 206 } |
207 | 207 |
208 // Update data using DocumentProperties. | 208 // Update data using DocumentProperties. |
209 if (show_system_dialog) { | 209 if (show_system_dialog) { |
210 PrintingContext::Result result = PrintingContext::FAILED; | 210 PrintingContext::Result result = PrintingContext::FAILED; |
211 AskUserForSettings(page_count, false, false, | 211 AskUserForSettings(page_count, false, false, |
212 base::Bind(&AssingResult, &result)); | 212 base::Bind(&AssignResult, &result)); |
213 return result; | 213 return result; |
214 } else { | |
215 scoped_dev_mode = CreateDevMode(printer.Get(), scoped_dev_mode.get()); | |
216 } | 214 } |
217 // Set printer then refresh printer settings. | 215 // Set printer then refresh printer settings. |
| 216 scoped_dev_mode = CreateDevMode(printer.Get(), scoped_dev_mode.get()); |
218 return InitializeSettings(settings_.device_name(), scoped_dev_mode.get()); | 217 return InitializeSettings(settings_.device_name(), scoped_dev_mode.get()); |
219 } | 218 } |
220 | 219 |
221 PrintingContext::Result PrintingContextWin::InitWithSettings( | 220 PrintingContext::Result PrintingContextWin::InitWithSettings( |
222 const PrintSettings& settings) { | 221 const PrintSettings& settings) { |
223 DCHECK(!in_print_job_); | 222 DCHECK(!in_print_job_); |
224 | 223 |
225 settings_ = settings; | 224 settings_ = settings; |
226 | 225 |
227 // TODO(maruel): settings_.ToDEVMODE() | 226 // TODO(maruel): settings_.ToDEVMODE() |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 if (view && view->GetHost()) | 364 if (view && view->GetHost()) |
366 window = view->GetHost()->GetAcceleratedWidget(); | 365 window = view->GetHost()->GetAcceleratedWidget(); |
367 if (!window) { | 366 if (!window) { |
368 // TODO(maruel): crbug.com/1214347 Get the right browser window instead. | 367 // TODO(maruel): crbug.com/1214347 Get the right browser window instead. |
369 return GetDesktopWindow(); | 368 return GetDesktopWindow(); |
370 } | 369 } |
371 return window; | 370 return window; |
372 } | 371 } |
373 | 372 |
374 } // namespace printing | 373 } // namespace printing |
OLD | NEW |