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

Unified Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 11779035: Centralize keypress listener handling in non-platform-specific code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Keep ignoring input events Created 7 years, 11 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
Index: content/browser/renderer_host/render_widget_host_impl.cc
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index be9a48967f1112c9d7354848c63b7fe10b31c614..d433291906ddfc5c024d2362fa9e4c3a101f7c79 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -1033,6 +1033,11 @@ void RenderWidgetHostImpl::ForwardKeyboardEvent(
if (ignore_input_events_ || process_->IgnoreInputEvents())
return;
+ // First, let keypress listeners take a shot at handling the event. If a
+ // listener handles the event, it should not be propagated to the renderer.
+ if (KeyPressListenersHandleEvent(key_event))
+ return;
+
if (key_event.type == WebKeyboardEvent::Char &&
(key_event.windowsKeyCode == ui::VKEY_RETURN ||
key_event.windowsKeyCode == ui::VKEY_SPACE)) {
@@ -1163,20 +1168,6 @@ void RenderWidgetHostImpl::ForwardTouchEvent(
touch_event_queue_->QueueEvent(touch_event);
}
-bool RenderWidgetHostImpl::KeyPressListenersHandleEvent(
- const NativeWebKeyboardEvent& event) {
- if (event.type != WebKeyboardEvent::RawKeyDown)
- return false;
-
- for (std::list<KeyboardListener*>::iterator it = keyboard_listeners_.begin();
- it != keyboard_listeners_.end(); ++it) {
- if ((*it)->HandleKeyPressEvent(event))
- return true;
- }
-
- return false;
-}
-
void RenderWidgetHostImpl::AddKeyboardListener(KeyboardListener* listener) {
keyboard_listeners_.push_back(listener);
}
@@ -2086,6 +2077,20 @@ void RenderWidgetHostImpl::SetIgnoreInputEvents(bool ignore_input_events) {
ignore_input_events_ = ignore_input_events;
}
+bool RenderWidgetHostImpl::KeyPressListenersHandleEvent(
+ const NativeWebKeyboardEvent& event) {
+ if (event.skip_in_browser || event.type != WebKeyboardEvent::RawKeyDown)
+ return false;
+
+ for (std::list<KeyboardListener*>::iterator it = keyboard_listeners_.begin();
+ it != keyboard_listeners_.end(); ++it) {
+ if ((*it)->HandleKeyPressEvent(event))
+ return true;
+ }
+
+ return false;
+}
+
void RenderWidgetHostImpl::ProcessKeyboardEventAck(int type, bool processed) {
if (key_queue_.empty()) {
LOG(ERROR) << "Got a KeyEvent back from the renderer but we "
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/renderer_host/render_widget_host_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698