Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1184)

Side by Side Diff: printing/printing_context_win.cc

Issue 557663002: Restored printing windows context for builds without preview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tue Sep 9 12:14:54 PDT 2014 Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « printing/printing_context_win.h ('k') | printing/printing_context_win_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "printing/backend/print_backend.h" 11 #include "printing/backend/print_backend.h"
12 #include "printing/backend/win_helper.h" 12 #include "printing/backend/win_helper.h"
13 #include "printing/print_settings_initializer_win.h" 13 #include "printing/print_settings_initializer_win.h"
14 #include "printing/printed_document.h" 14 #include "printing/printed_document.h"
15 #include "printing/printing_context_system_dialog_win.h"
15 #include "printing/printing_utils.h" 16 #include "printing/printing_utils.h"
16 #include "printing/units.h" 17 #include "printing/units.h"
17 #include "skia/ext/platform_device.h" 18 #include "skia/ext/platform_device.h"
18 19
19 #if defined(USE_AURA) 20 #if defined(USE_AURA)
20 #include "ui/aura/remote_window_tree_host_win.h" 21 #include "ui/aura/remote_window_tree_host_win.h"
21 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
22 #endif 23 #endif
23 24
24 namespace {
25
26 HWND GetRootWindow(gfx::NativeView view) {
27 HWND window = NULL;
28 #if defined(USE_AURA)
29 if (view)
30 window = view->GetHost()->GetAcceleratedWidget();
31 #else
32 if (view && IsWindow(view)) {
33 window = GetAncestor(view, GA_ROOTOWNER);
34 }
35 #endif
36 if (!window) {
37 // TODO(maruel): bug 1214347 Get the right browser window instead.
38 return GetDesktopWindow();
39 }
40 return window;
41 }
42
43 } // anonymous namespace
44
45 namespace printing { 25 namespace printing {
46 26
47 // static 27 // static
48 scoped_ptr<PrintingContext> PrintingContext::Create(Delegate* delegate) { 28 scoped_ptr<PrintingContext> PrintingContext::Create(Delegate* delegate) {
29 #if defined(DISABLE_BASIC_PRINTING)
49 return make_scoped_ptr<PrintingContext>(new PrintingContextWin(delegate)); 30 return make_scoped_ptr<PrintingContext>(new PrintingContextWin(delegate));
31 #else // DISABLE_BASIC_PRINTING
32 return make_scoped_ptr<PrintingContext>(
33 new PrintingContextSytemDialogWin(delegate));
34 #endif // DISABLE_BASIC_PRINTING
50 } 35 }
51 36
52 PrintingContextWin::PrintingContextWin(Delegate* delegate) 37 PrintingContextWin::PrintingContextWin(Delegate* delegate)
53 : PrintingContext(delegate), context_(NULL) { 38 : PrintingContext(delegate), context_(NULL) {
54 } 39 }
55 40
56 PrintingContextWin::~PrintingContextWin() { 41 PrintingContextWin::~PrintingContextWin() {
57 ReleaseContext(); 42 ReleaseContext();
58 } 43 }
59 44
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 skia::InitializeDC(context_); 342 skia::InitializeDC(context_);
358 343
359 DCHECK(!in_print_job_); 344 DCHECK(!in_print_job_);
360 settings_.set_device_name(device_name); 345 settings_.set_device_name(device_name);
361 PrintSettingsInitializerWin::InitPrintSettings( 346 PrintSettingsInitializerWin::InitPrintSettings(
362 context_, *dev_mode, &settings_); 347 context_, *dev_mode, &settings_);
363 348
364 return OK; 349 return OK;
365 } 350 }
366 351
352 HWND PrintingContextWin::GetRootWindow(gfx::NativeView view) {
353 HWND window = NULL;
354 #if defined(USE_AURA)
355 if (view)
356 window = view->GetHost()->GetAcceleratedWidget();
357 #else
358 if (view && IsWindow(view)) {
359 window = GetAncestor(view, GA_ROOTOWNER);
360 }
361 #endif
362 if (!window) {
363 // TODO(maruel): crbug.com/1214347 Get the right browser window instead.
364 return GetDesktopWindow();
365 }
366 return window;
367 }
368
367 scoped_ptr<DEVMODE, base::FreeDeleter> PrintingContextWin::ShowPrintDialog( 369 scoped_ptr<DEVMODE, base::FreeDeleter> PrintingContextWin::ShowPrintDialog(
368 HANDLE printer, 370 HANDLE printer,
369 gfx::NativeView parent_view, 371 gfx::NativeView parent_view,
370 DEVMODE* dev_mode) { 372 DEVMODE* dev_mode) {
371 // Note that this cannot use ui::BaseShellDialog as the print dialog is 373 // Note that this cannot use ui::BaseShellDialog as the print dialog is
372 // system modal: opening it from a background thread can cause Windows to 374 // system modal: opening it from a background thread can cause Windows to
373 // get the wrong Z-order which will make the print dialog appear behind the 375 // get the wrong Z-order which will make the print dialog appear behind the
374 // browser frame (but still being modal) so neither the browser frame nor 376 // browser frame (but still being modal) so neither the browser frame nor
375 // the print dialog will get any input. See http://crbug.com/342697 377 // the print dialog will get any input. See http://crbug.com/342697
376 // http://crbug.com/180997 for details. 378 // http://crbug.com/180997 for details.
(...skipping 10 matching lines...) Expand all
387 389
388 if (canceled) { 390 if (canceled) {
389 result.reset(); 391 result.reset();
390 abort_printing_ = true; 392 abort_printing_ = true;
391 } 393 }
392 394
393 return result.Pass(); 395 return result.Pass();
394 } 396 }
395 397
396 } // namespace printing 398 } // namespace printing
OLDNEW
« no previous file with comments | « printing/printing_context_win.h ('k') | printing/printing_context_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698