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 " |