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

Side by Side Diff: printing/printing_context_system_dialog_win.cc

Issue 934393003: Block nested system print dialogs on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no_crash
Patch Set: Mon Feb 23 09:47:28 PST 2015 Created 5 years, 10 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 | « no previous file | printing/printing_context_win.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_system_dialog_win.h" 5 #include "printing/printing_context_system_dialog_win.h"
6 6
7 #include "base/auto_reset.h"
7 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
8 #include "printing/backend/win_helper.h" 9 #include "printing/backend/win_helper.h"
9 #include "printing/print_settings_initializer_win.h" 10 #include "printing/print_settings_initializer_win.h"
10 #include "skia/ext/platform_device.h" 11 #include "skia/ext/platform_device.h"
11 12
12 namespace printing { 13 namespace printing {
13 14
14 PrintingContextSytemDialogWin::PrintingContextSytemDialogWin(Delegate* delegate) 15 PrintingContextSytemDialogWin::PrintingContextSytemDialogWin(Delegate* delegate)
15 : PrintingContextWin(delegate), dialog_box_(NULL) { 16 : PrintingContextWin(delegate), dialog_box_(NULL) {
16 } 17 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 78
78 void PrintingContextSytemDialogWin::Cancel() { 79 void PrintingContextSytemDialogWin::Cancel() {
79 PrintingContextWin::Cancel(); 80 PrintingContextWin::Cancel();
80 if (dialog_box_) { 81 if (dialog_box_) {
81 DestroyWindow(dialog_box_); 82 DestroyWindow(dialog_box_);
82 dialog_box_dismissed_ = true; 83 dialog_box_dismissed_ = true;
83 } 84 }
84 } 85 }
85 86
86 HRESULT PrintingContextSytemDialogWin::ShowPrintDialog(PRINTDLGEX* options) { 87 HRESULT PrintingContextSytemDialogWin::ShowPrintDialog(PRINTDLGEX* options) {
88 // Runs always on the UI thread.
89 static bool is_dialog_shown = false;
90 if (is_dialog_shown)
91 return E_FAIL;
92 // Block opening dialog from nested task. It crashes PrintDlgEx.
93 base::AutoReset<bool> auto_reset(&is_dialog_shown, true);
94
87 // Note that this cannot use ui::BaseShellDialog as the print dialog is 95 // Note that this cannot use ui::BaseShellDialog as the print dialog is
88 // system modal: opening it from a background thread can cause Windows to 96 // system modal: opening it from a background thread can cause Windows to
89 // get the wrong Z-order which will make the print dialog appear behind the 97 // get the wrong Z-order which will make the print dialog appear behind the
90 // browser frame (but still being modal) so neither the browser frame nor 98 // browser frame (but still being modal) so neither the browser frame nor
91 // the print dialog will get any input. See http://crbug.com/342697 99 // the print dialog will get any input. See http://crbug.com/342697
92 // http://crbug.com/180997 for details. 100 // http://crbug.com/180997 for details.
93 base::MessageLoop::ScopedNestableTaskAllower allow( 101 base::MessageLoop::ScopedNestableTaskAllower allow(
94 base::MessageLoop::current()); 102 base::MessageLoop::current());
95 103
96 return PrintDlgEx(options); 104 return PrintDlgEx(options);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 269
262 if (dialog_options.hDevMode != NULL) 270 if (dialog_options.hDevMode != NULL)
263 GlobalFree(dialog_options.hDevMode); 271 GlobalFree(dialog_options.hDevMode);
264 if (dialog_options.hDevNames != NULL) 272 if (dialog_options.hDevNames != NULL)
265 GlobalFree(dialog_options.hDevNames); 273 GlobalFree(dialog_options.hDevNames);
266 274
267 return context() ? OK : FAILED; 275 return context() ? OK : FAILED;
268 } 276 }
269 277
270 } // namespace printing 278 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | printing/printing_context_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698