Commit b8291463 authored by Thomas Lukaszewicz's avatar Thomas Lukaszewicz Committed by Commit Bot

Views: Fix BubbleWebView not properly handling accelerators

Adds an UnhandledKeyboardEventHandler member to the BubbleWebView
to allow the WebView and embedder to deal with key events that
were not handled by the WebContents.

Sets allow_accelerators_ to true to ensure that embedders of the
BubbleWebView are able to capture and respond to accelerators.

Bug: 1138967
Change-Id: Ib629de2dbb0f1b6e41f4116fcff6d1413fc3061c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2496504Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821040}
parent eba6823d
......@@ -9,6 +9,7 @@
#include "content/public/browser/keyboard_event_processing_result.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "ui/gfx/geometry/rounded_corners_f.h"
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/widget/widget.h"
......@@ -35,6 +36,8 @@ class BubbleWebView : public WebView {
WebBubbleDialogView* parent)
: WebView(browser_context), parent_(parent) {
EnableSizingFromWebContents(kMinSize, kMaxSize);
// Allow the embedder to handle accelerators not handled by the WebContents.
set_allow_accelerators(true);
}
~BubbleWebView() override = default;
......@@ -62,9 +65,19 @@ class BubbleWebView : public WebView {
}
return content::KeyboardEventProcessingResult::NOT_HANDLED;
}
bool HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) override {
return unhandled_keyboard_event_handler_.HandleKeyboardEvent(
event, GetFocusManager());
}
private:
WebBubbleDialogView* parent_;
// A handler to handle unhandled keyboard messages coming back from the
// renderer process.
views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_;
};
} // namespace
......
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