Skip to content

Commit

Permalink
Merge: Block nested system print dialogs on Windows.
Browse files Browse the repository at this point in the history
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}
(cherry picked from commit a58ec6a)

Conflicts:
    printing/printing_context_win.cc

R=alekseys@chromium.org

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

Cr-Commit-Position: refs/branch-heads/2272@{#365}
Cr-Branched-From: 827a380-refs/heads/master@{#310958}

Committed: https://chromium.googlesource.com/chromium/src/+/4c02af6cec7529da8acf1cffdbd468afe0cbc36e

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

Cr-Commit-Position: refs/branch-heads/2272@{#367}
Cr-Branched-From: 827a380-refs/heads/master@{#310958}
  • Loading branch information
vitalybuka committed Feb 23, 2015
1 parent 4c02af6 commit 21f0a4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions printing/printing_context_system_dialog_win.cc
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion printing/printing_context_win.cc
Expand Up @@ -363,7 +363,7 @@ PrintingContext::Result PrintingContextWin::InitializeSettings(
HWND PrintingContextWin::GetRootWindow(gfx::NativeView view) {
HWND window = NULL;
#if defined(USE_AURA)
if (view)
if (view && view->GetHost())
window = view->GetHost()->GetAcceleratedWidget();
#else
if (view && IsWindow(view)) {
Expand Down

0 comments on commit 21f0a4c

Please sign in to comment.