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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | printing/printing_context_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/printing_context_system_dialog_win.cc
diff --git a/printing/printing_context_system_dialog_win.cc b/printing/printing_context_system_dialog_win.cc
index 19fc42719ce990af1cd4abe16f25b0657aa3f8b8..b89f1a4e469ac89ca10b34942a95f8fd35a21010 100644
--- a/printing/printing_context_system_dialog_win.cc
+++ b/printing/printing_context_system_dialog_win.cc
@@ -4,6 +4,7 @@
#include "printing/printing_context_system_dialog_win.h"
+#include "base/auto_reset.h"
#include "base/message_loop/message_loop.h"
#include "printing/backend/win_helper.h"
#include "printing/print_settings_initializer_win.h"
@@ -84,6 +85,13 @@ void PrintingContextSytemDialogWin::Cancel() {
}
HRESULT PrintingContextSytemDialogWin::ShowPrintDialog(PRINTDLGEX* options) {
+ // Runs always on the UI thread.
+ static bool is_dialog_shown = false;
+ if (is_dialog_shown)
+ return E_FAIL;
+ // Block opening dialog from nested task. It crashes PrintDlgEx.
+ base::AutoReset<bool> auto_reset(&is_dialog_shown, true);
+
// Note that this cannot use ui::BaseShellDialog as the print dialog is
// system modal: opening it from a background thread can cause Windows to
// get the wrong Z-order which will make the print dialog appear behind the
« 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