Commit a58ec6a8 authored by vitalybuka's avatar vitalybuka Committed by Commit bot

Block nested system print dialogs on Windows.

Browser needs to allow nested tasks to update backgroud tabs.
If rendered requests new system dialog, asan build crashes in COMDLG32.dll

NOTRY=true
BUG=451753

Review URL: https://codereview.chromium.org/934393003

Cr-Commit-Position: refs/heads/master@{#317611}
parent a68bc5fc
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "printing/printing_context_system_dialog_win.h" #include "printing/printing_context_system_dialog_win.h"
#include "base/auto_reset.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "printing/backend/win_helper.h" #include "printing/backend/win_helper.h"
#include "printing/print_settings_initializer_win.h" #include "printing/print_settings_initializer_win.h"
...@@ -84,6 +85,13 @@ void PrintingContextSytemDialogWin::Cancel() { ...@@ -84,6 +85,13 @@ void PrintingContextSytemDialogWin::Cancel() {
} }
HRESULT PrintingContextSytemDialogWin::ShowPrintDialog(PRINTDLGEX* options) { 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 // Note that this cannot use ui::BaseShellDialog as the print dialog is
// system modal: opening it from a background thread can cause Windows to // 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 // get the wrong Z-order which will make the print dialog appear behind the
......
...@@ -359,7 +359,7 @@ PrintingContext::Result PrintingContextWin::InitializeSettings( ...@@ -359,7 +359,7 @@ PrintingContext::Result PrintingContextWin::InitializeSettings(
HWND PrintingContextWin::GetRootWindow(gfx::NativeView view) { HWND PrintingContextWin::GetRootWindow(gfx::NativeView view) {
HWND window = NULL; HWND window = NULL;
if (view) if (view && view->GetHost())
window = view->GetHost()->GetAcceleratedWidget(); window = view->GetHost()->GetAcceleratedWidget();
if (!window) { if (!window) {
// TODO(maruel): crbug.com/1214347 Get the right browser window instead. // TODO(maruel): crbug.com/1214347 Get the right browser window instead.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment