diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 10:05:04 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 10:05:04 +0000 |
commit | 255184bcbc7f41bccaf11c67dd3f41a79f3950cd (patch) | |
tree | ce8d441b3828ed3e13ffd943c51dc9221521d78f | |
parent | 65c117758c5acf163331415e6175fcdb85fefde7 (diff) | |
download | chromium_src-255184bcbc7f41bccaf11c67dd3f41a79f3950cd.zip chromium_src-255184bcbc7f41bccaf11c67dd3f41a79f3950cd.tar.gz chromium_src-255184bcbc7f41bccaf11c67dd3f41a79f3950cd.tar.bz2 |
A Chrome-side fix for Issue 13233.
To investigate this issue deeply, it seems Flash uses ToUnicode() to verify WM_CHAR events sent from a browser. That is, Flash discards WM_CHAR events if they are different from the characters returned from ToUnicode() calls. So, to fix this issue, we need not only to send WM_CHAR events, but also to synchronize the keyboard layout of a plug-in process with a browser process. To retrieve the keyboard layout of a browser process, this change call GetKeyboardLayout() with the thread id of the parent window. (Even though I'm wondering if this is a good way, I used it since it is not so easy to dispatch the keyboard layout from a browser process to a plug-in process.)
BUG=13233
TEST=LayoutTests/plugins/keyboard-events.html (in my WebKit-side change <https://bugs.webkit.org/show_bug.cgi?id=34936>).
Review URL: http://codereview.chromium.org/267072
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42445 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.h | 6 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl_win.cc | 26 |
2 files changed, 32 insertions, 0 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index e87522c..63d90b1 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -290,6 +290,12 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { // Used to throttle WM_USER+1 messages in Flash. uint32 last_message_; bool is_calling_wndproc; + + // The current keyboard layout of this process and the main thread ID of the + // browser process. These variables are used for synchronizing the keyboard + // layout of this process with the one of the browser process. + HKL keyboard_layout_; + int parent_thread_id_; #endif // OS_WIN #if defined(USE_X11) diff --git a/webkit/glue/plugins/webplugin_delegate_impl_win.cc b/webkit/glue/plugins/webplugin_delegate_impl_win.cc index e4f58c3..2c31856 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_win.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl_win.cc @@ -241,6 +241,8 @@ WebPluginDelegateImpl::WebPluginDelegateImpl( plugin_wnd_proc_(NULL), last_message_(0), is_calling_wndproc(false), + keyboard_layout_(NULL), + parent_thread_id_(0), dummy_window_for_activation_(NULL), handle_event_message_filter_hook_(NULL), handle_event_pump_messages_event_(NULL), @@ -1071,6 +1073,10 @@ static bool NPEventFromWebKeyboardEvent(const WebKeyboardEvent& event, np_event->event = WM_KEYDOWN; np_event->lParam = 0; return true; + case WebInputEvent::Char: + np_event->event = WM_CHAR; + np_event->lParam = 0; + return true; case WebInputEvent::KeyUp: np_event->event = WM_KEYUP; np_event->lParam = 0x8000; @@ -1096,6 +1102,7 @@ static bool NPEventFromWebInputEvent(const WebInputEvent& event, return NPEventFromWebMouseEvent( *static_cast<const WebMouseEvent*>(&event), np_event); case WebInputEvent::KeyDown: + case WebInputEvent::Char: case WebInputEvent::KeyUp: if (event.size < sizeof(WebKeyboardEvent)) { NOTREACHED(); @@ -1117,6 +1124,25 @@ bool WebPluginDelegateImpl::PlatformHandleInputEvent( return false; } + // Synchronize the keyboard layout with the one of the browser process. Flash + // uses the keyboard layout of this window to verify a WM_CHAR message is + // valid. That is, Flash discards a WM_CHAR message unless its character is + // the one translated with ToUnicode(). (Since a plug-in is running on a + // separate process from the browser process, we need to syncronize it + // manually.) + if (np_event.event == WM_CHAR) { + if (!keyboard_layout_) + keyboard_layout_ = GetKeyboardLayout(GetCurrentThreadId()); + if (!parent_thread_id_) + parent_thread_id_ = GetWindowThreadProcessId(parent_, NULL); + HKL parent_layout = GetKeyboardLayout(parent_thread_id_); + if (keyboard_layout_ != parent_layout) { + std::wstring layout_name(StringPrintf(L"%08x", parent_layout)); + LoadKeyboardLayout(layout_name.c_str(), KLF_ACTIVATE); + keyboard_layout_ = parent_layout; + } + } + if (ShouldTrackEventForModalLoops(&np_event)) { // A windowless plugin can enter a modal loop in a NPP_HandleEvent call. // For e.g. Flash puts up a context menu when we right click on the |