Commit 7ed352b8 authored by sammc's avatar sammc Committed by Commit bot

OOP PDF: Forward keyboard events to a constrained web dialog's initiator's delegate.

WebDialogWebContentsDelegateViews forwards keyboard events that it
receives to the Browser for its initiating WebContents. The
out-of-process PDF plugin is implemented as a nested WebContents
containing the extension implementation within the WebContents of the
tab.

When a print-preview dialog is launched for a PDF from the
out-of-process plugin, the dialog's initiator is the nested WebContents,
which does not have an associated Browser. This causes keyboard events
to be dropped, breaking keyboard shortcuts. This CL fixes this by
changing WebDialogWebContentsDelegateViews to forward keyboard events to
its initiator's delegate.

BUG=423453
TEST=Run with --out-of-process-pdf. Open a PDF and use the print toolbar
button to launch the print preview dialog. From this dialog, keyboard
shortcuts should work, e.g. escape should cancel the dialog.

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

Cr-Commit-Position: refs/heads/master@{#305125}
parent b56ec365
......@@ -41,13 +41,14 @@ class WebDialogWebContentsDelegateViews
void HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) override {
// Forward shortcut keys in dialog to the browser. http://crbug.com/104586
// Forward shortcut keys in dialog to our initiator's delegate.
// http://crbug.com/104586
// Disabled on Mac due to http://crbug.com/112173
#if !defined(OS_MACOSX)
Browser* current_browser = chrome::FindBrowserWithWebContents(initiator_);
if (!current_browser)
auto delegate = initiator_->GetDelegate();
if (!delegate)
return;
current_browser->window()->HandleKeyboardEvent(event);
delegate->HandleKeyboardEvent(initiator_, event);
#endif
}
......
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