summaryrefslogtreecommitdiffstats
path: root/ui/views
diff options
context:
space:
mode:
authorandresantoso <andresantoso@chromium.org>2014-10-24 14:36:44 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-24 21:37:03 +0000
commitf5d10685b975dd11be315133a099a8a980ad0716 (patch)
treeba29d2798c73bcab7396e84413fa63b018693745 /ui/views
parentd42b0f6875a5fa8b86487ca61d087eebdb4a9afe (diff)
downloadchromium_src-f5d10685b975dd11be315133a099a8a980ad0716.zip
chromium_src-f5d10685b975dd11be315133a099a8a980ad0716.tar.gz
chromium_src-f5d10685b975dd11be315133a099a8a980ad0716.tar.bz2
MacViews: UnhandledKeyboardEventHandler stub
Fix for missing UnhandledKeyboardEventHandler::HandleNativeKeyboardEvent on Mac, in preparation for compiling chrome/browser/ui/views for MacViews. Consolidate duplicated linux/windows code to be shared code and stub out the Mac implementation. BUG=425229 Review URL: https://codereview.chromium.org/679743002 Cr-Commit-Position: refs/heads/master@{#301198}
Diffstat (limited to 'ui/views')
-rw-r--r--ui/views/controls/webview/unhandled_keyboard_event_handler.cc49
-rw-r--r--ui/views/controls/webview/unhandled_keyboard_event_handler.h5
-rw-r--r--ui/views/controls/webview/unhandled_keyboard_event_handler_linux.cc52
-rw-r--r--ui/views/controls/webview/unhandled_keyboard_event_handler_mac.mm16
-rw-r--r--ui/views/controls/webview/unhandled_keyboard_event_handler_win.cc53
-rw-r--r--ui/views/controls/webview/webview.gyp1
6 files changed, 79 insertions, 97 deletions
diff --git a/ui/views/controls/webview/unhandled_keyboard_event_handler.cc b/ui/views/controls/webview/unhandled_keyboard_event_handler.cc
index 0a43353..7a331d5 100644
--- a/ui/views/controls/webview/unhandled_keyboard_event_handler.cc
+++ b/ui/views/controls/webview/unhandled_keyboard_event_handler.cc
@@ -4,9 +4,58 @@
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
+#include "content/public/browser/native_web_keyboard_event.h"
+#include "ui/views/focus/focus_manager.h"
+
namespace views {
+UnhandledKeyboardEventHandler::UnhandledKeyboardEventHandler()
+ : ignore_next_char_event_(false) {
+}
+
UnhandledKeyboardEventHandler::~UnhandledKeyboardEventHandler() {
}
+void UnhandledKeyboardEventHandler::HandleKeyboardEvent(
+ const content::NativeWebKeyboardEvent& event,
+ FocusManager* focus_manager) {
+ if (!focus_manager) {
+ NOTREACHED();
+ return;
+ }
+ // Previous calls to TranslateMessage can generate Char events as well as
+ // RawKeyDown events, even if the latter triggered an accelerator. In these
+ // cases, we discard the Char events.
+ if (event.type == blink::WebInputEvent::Char && ignore_next_char_event_) {
+ ignore_next_char_event_ = false;
+ return;
+ }
+ // It's necessary to reset this flag, because a RawKeyDown event may not
+ // always generate a Char event.
+ ignore_next_char_event_ = false;
+
+ if (event.type == blink::WebInputEvent::RawKeyDown) {
+ ui::Accelerator accelerator(
+ static_cast<ui::KeyboardCode>(event.windowsKeyCode),
+ content::GetModifiersFromNativeWebKeyboardEvent(event));
+
+ // This is tricky: we want to set ignore_next_char_event_ if
+ // ProcessAccelerator returns true. But ProcessAccelerator might delete
+ // |this| if the accelerator is a "close tab" one. So we speculatively
+ // set the flag and fix it if no event was handled.
+ ignore_next_char_event_ = true;
+
+ if (focus_manager->ProcessAccelerator(accelerator)) {
+ return;
+ }
+
+ // ProcessAccelerator didn't handle the accelerator, so we know both
+ // that |this| is still valid, and that we didn't want to set the flag.
+ ignore_next_char_event_ = false;
+ }
+
+ if (event.os_event && !event.skip_in_browser)
+ HandleNativeKeyboardEvent(event.os_event, focus_manager);
+}
+
} // namespace views
diff --git a/ui/views/controls/webview/unhandled_keyboard_event_handler.h b/ui/views/controls/webview/unhandled_keyboard_event_handler.h
index 6d30baf..e444b69 100644
--- a/ui/views/controls/webview/unhandled_keyboard_event_handler.h
+++ b/ui/views/controls/webview/unhandled_keyboard_event_handler.h
@@ -6,6 +6,7 @@
#define UI_VIEWS_CONTROLS_WEBVIEW_UNHANDLED_KEYBOARD_EVENT_HANDLER_H_
#include "base/basictypes.h"
+#include "ui/gfx/native_widget_types.h"
#include "ui/views/controls/webview/webview_export.h"
namespace content {
@@ -26,6 +27,10 @@ class WEBVIEW_EXPORT UnhandledKeyboardEventHandler {
FocusManager* focus_manager);
private:
+ // Platform specific handling for unhandled keyboard events.
+ static void HandleNativeKeyboardEvent(gfx::NativeEvent event,
+ FocusManager* focus_manager);
+
// Whether to ignore the next Char keyboard event.
// If a RawKeyDown event was handled as a shortcut key, then we're done
// handling it and should eat any Char event that the translate phase may
diff --git a/ui/views/controls/webview/unhandled_keyboard_event_handler_linux.cc b/ui/views/controls/webview/unhandled_keyboard_event_handler_linux.cc
index 45c51ad..8d30e36 100644
--- a/ui/views/controls/webview/unhandled_keyboard_event_handler_linux.cc
+++ b/ui/views/controls/webview/unhandled_keyboard_event_handler_linux.cc
@@ -4,60 +4,16 @@
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
-#include "base/logging.h"
-#include "content/public/browser/native_web_keyboard_event.h"
#include "ui/events/event.h"
#include "ui/views/focus/focus_manager.h"
-using content::NativeWebKeyboardEvent;
-
namespace views {
-UnhandledKeyboardEventHandler::UnhandledKeyboardEventHandler()
- : ignore_next_char_event_(false) {
-}
-
-void UnhandledKeyboardEventHandler::HandleKeyboardEvent(
- const NativeWebKeyboardEvent& event,
+// static
+void UnhandledKeyboardEventHandler::HandleNativeKeyboardEvent(
+ gfx::NativeEvent event,
FocusManager* focus_manager) {
- if (!focus_manager) {
- NOTREACHED();
- return;
- }
-
- // Previous calls to TranslateMessage can generate Char events as well as
- // RawKeyDown events, even if the latter triggered an accelerator. In these
- // cases, we discard the Char events.
- if (event.type == blink::WebInputEvent::Char && ignore_next_char_event_) {
- ignore_next_char_event_ = false;
- return;
- }
- // It's necessary to reset this flag, because a RawKeyDown event may not
- // always generate a Char event.
- ignore_next_char_event_ = false;
-
- if (event.type == blink::WebInputEvent::RawKeyDown) {
- ui::Accelerator accelerator(
- static_cast<ui::KeyboardCode>(event.windowsKeyCode),
- content::GetModifiersFromNativeWebKeyboardEvent(event));
-
- // This is tricky: we want to set ignore_next_char_event_ if
- // ProcessAccelerator returns true. But ProcessAccelerator might delete
- // |this| if the accelerator is a "close tab" one. So we speculatively
- // set the flag and fix it if no event was handled.
- ignore_next_char_event_ = true;
-
- if (focus_manager->ProcessAccelerator(accelerator)) {
- return;
- }
-
- // ProcessAccelerator didn't handle the accelerator, so we know both
- // that |this| is still valid, and that we didn't want to set the flag.
- ignore_next_char_event_ = false;
- }
-
- if (event.os_event && !event.skip_in_browser)
- focus_manager->OnKeyEvent(*static_cast<ui::KeyEvent*>(event.os_event));
+ focus_manager->OnKeyEvent(*static_cast<ui::KeyEvent*>(event));
}
} // namespace views
diff --git a/ui/views/controls/webview/unhandled_keyboard_event_handler_mac.mm b/ui/views/controls/webview/unhandled_keyboard_event_handler_mac.mm
new file mode 100644
index 0000000..d579c9e
--- /dev/null
+++ b/ui/views/controls/webview/unhandled_keyboard_event_handler_mac.mm
@@ -0,0 +1,16 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
+
+namespace views {
+
+// static
+void UnhandledKeyboardEventHandler::HandleNativeKeyboardEvent(
+ gfx::NativeEvent event,
+ FocusManager* focus_manager) {
+ NOTIMPLEMENTED();
+}
+
+} // namespace views
diff --git a/ui/views/controls/webview/unhandled_keyboard_event_handler_win.cc b/ui/views/controls/webview/unhandled_keyboard_event_handler_win.cc
index 463ef7e..e31aabb 100644
--- a/ui/views/controls/webview/unhandled_keyboard_event_handler_win.cc
+++ b/ui/views/controls/webview/unhandled_keyboard_event_handler_win.cc
@@ -4,62 +4,17 @@
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
-#include "base/logging.h"
-#include "content/public/browser/native_web_keyboard_event.h"
#include "ui/events/event.h"
-#include "ui/views/focus/focus_manager.h"
-
-using content::NativeWebKeyboardEvent;
namespace views {
-UnhandledKeyboardEventHandler::UnhandledKeyboardEventHandler() {
- ignore_next_char_event_ = false;
-}
-
-void UnhandledKeyboardEventHandler::HandleKeyboardEvent(
- const NativeWebKeyboardEvent& event,
+// static
+void UnhandledKeyboardEventHandler::HandleNativeKeyboardEvent(
+ gfx::NativeEvent event,
FocusManager* focus_manager) {
- if (!focus_manager) {
- NOTREACHED();
- return;
- }
- // Previous calls to TranslateMessage can generate Char events as well as
- // RawKeyDown events, even if the latter triggered an accelerator. In these
- // cases, we discard the Char events.
- if (event.type == blink::WebInputEvent::Char && ignore_next_char_event_) {
- ignore_next_char_event_ = false;
- return;
- }
- // It's necessary to reset this flag, because a RawKeyDown event may not
- // always generate a Char event.
- ignore_next_char_event_ = false;
-
- if (event.type == blink::WebInputEvent::RawKeyDown) {
- ui::Accelerator accelerator(
- static_cast<ui::KeyboardCode>(event.windowsKeyCode),
- content::GetModifiersFromNativeWebKeyboardEvent(event));
-
- // This is tricky: we want to set ignore_next_char_event_ if
- // ProcessAccelerator returns true. But ProcessAccelerator might delete
- // |this| if the accelerator is a "close tab" one. So we speculatively
- // set the flag and fix it if no event was handled.
- ignore_next_char_event_ = true;
-
- if (focus_manager->ProcessAccelerator(accelerator)) {
- return;
- }
-
- // ProcessAccelerator didn't handle the accelerator, so we know both
- // that |this| is still valid, and that we didn't want to set the flag.
- ignore_next_char_event_ = false;
- }
-
// Any unhandled keyboard/character messages should be defproced.
// This allows stuff like F10, etc to work correctly.
- if (!event.os_event)
- return;
- const MSG& message(event.os_event->native_event());
+ const MSG& message(event->native_event());
DefWindowProc(message.hwnd, message.message, message.wParam, message.lParam);
}
diff --git a/ui/views/controls/webview/webview.gyp b/ui/views/controls/webview/webview.gyp
index af284b7..45d832f 100644
--- a/ui/views/controls/webview/webview.gyp
+++ b/ui/views/controls/webview/webview.gyp
@@ -33,6 +33,7 @@
'unhandled_keyboard_event_handler.cc',
'unhandled_keyboard_event_handler.h',
'unhandled_keyboard_event_handler_linux.cc',
+ 'unhandled_keyboard_event_handler_mac.mm',
'unhandled_keyboard_event_handler_win.cc',
'web_dialog_view.cc',
'web_dialog_view.h',