summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorgeorgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-13 01:18:00 +0000
committergeorgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-13 01:18:00 +0000
commit6fdf27572a1683448fc8c22f47c3f11391e580ef (patch)
treeacdd728acea319d433e9b6ffcba0bc809d24d873 /chrome
parent30447b6a5d6109d455f2c6262454105d5adf8f94 (diff)
downloadchromium_src-6fdf27572a1683448fc8c22f47c3f11391e580ef.zip
chromium_src-6fdf27572a1683448fc8c22f47c3f11391e580ef.tar.gz
chromium_src-6fdf27572a1683448fc8c22f47c3f11391e580ef.tar.bz2
Ignore keyboard messages from enter key in renderer if they were not initiated there.
BUG=26755 TEST=Enter messages initiated in omnibox should not propagate to renderer Review URL: http://codereview.chromium.org/384101 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31869 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_win.cc28
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_win.h3
2 files changed, 30 insertions, 1 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc
index 837cdf9..76ff9f5 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_win.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc
@@ -216,6 +216,7 @@ RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget)
: render_widget_host_(widget),
track_mouse_leave_(false),
ime_notification_(false),
+ capture_enter_key_(false),
is_hidden_(false),
about_to_validate_and_paint_(false),
close_on_deactivate_(false),
@@ -1187,7 +1188,32 @@ LRESULT RenderWidgetHostViewWin::OnKeyEvent(UINT message, WPARAM wparam,
}
}
- if (render_widget_host_) {
+ // Special processing for enter key: When user hits enter in omnibox
+ // we change focus to render host after the navigation, so repeat WM_KEYDOWNs
+ // and WM_KEYUP are going to render host, despite being initiated in other
+ // window. This code filters out these messages.
+ bool ignore_keyboard_event = false;
+ if (wparam == VK_RETURN) {
+ if (message == WM_KEYDOWN) {
+ if (KF_REPEAT & HIWORD(lparam)) {
+ // this is a repeated key
+ if (!capture_enter_key_)
+ ignore_keyboard_event = true;
+ } else {
+ capture_enter_key_ = true;
+ }
+ } else if (message == WM_KEYUP) {
+ if (!capture_enter_key_)
+ ignore_keyboard_event = true;
+ capture_enter_key_ = false;
+ } else {
+ // Ignore all other keyboard events for the enter key if not captured.
+ if (!capture_enter_key_)
+ ignore_keyboard_event = true;
+ }
+ }
+
+ if (render_widget_host_ && !ignore_keyboard_event) {
render_widget_host_->ForwardKeyboardEvent(
NativeWebKeyboardEvent(m_hWnd, message, wparam, lparam));
}
diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.h b/chrome/browser/renderer_host/render_widget_host_view_win.h
index 4601ec2..2fc3d80 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_win.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_win.h
@@ -241,6 +241,9 @@ class RenderWidgetHostViewWin :
// messages about the focused edit control from a renderer process.
bool ime_notification_;
+ // true if Enter was hit when render widget host was in focus.
+ bool capture_enter_key_;
+
// true if the View is not visible.
bool is_hidden_;