diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-22 01:29:05 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-22 01:29:05 +0000 |
commit | 41fbf097c8e01c4971de118eb8fb791b9abaa6eb (patch) | |
tree | 8216ee10224ebb84ace23ef8d227e8ec07666bac /chrome/common/plugin_messages.h | |
parent | d77232f96be7900e1e7230d145c06bb9e5ed7e44 (diff) | |
download | chromium_src-41fbf097c8e01c4971de118eb8fb791b9abaa6eb.zip chromium_src-41fbf097c8e01c4971de118eb8fb791b9abaa6eb.tar.gz chromium_src-41fbf097c8e01c4971de118eb8fb791b9abaa6eb.tar.bz2 |
Add events to windowless plugins on linux. This CL also refactors the event
communication between WebPlugin and WebPluginDelegate, to use a cross-platform
message based on WebInputEvent.
BUG=8202
TEST=A lot of manual testing on Linux and Windows, with Flash plugins and a
custom plugin that dumps events on Linux.
Review URL: http://codereview.chromium.org/115330
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16692 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/plugin_messages.h')
-rw-r--r-- | chrome/common/plugin_messages.h | 96 |
1 files changed, 25 insertions, 71 deletions
diff --git a/chrome/common/plugin_messages.h b/chrome/common/plugin_messages.h index 7b5ce73..111a7db 100644 --- a/chrome/common/plugin_messages.h +++ b/chrome/common/plugin_messages.h @@ -17,8 +17,10 @@ #include "base/gfx/rect.h" #include "base/basictypes.h" #include "chrome/common/ipc_message_utils.h" +#include "chrome/common/webkit_param_traits.h" #include "googleurl/src/gurl.h" #include "third_party/npapi/bindings/npapi.h" +#include "webkit/api/public/WebInputEvent.h" #include "webkit/glue/npruntime_util.h" // Name prefix of the event handle when a message box is displayed. @@ -263,91 +265,43 @@ struct ParamTraits<PluginMsg_DidReceiveResponseParams> { } }; +typedef const WebKit::WebInputEvent* WebInputEventPointer; template <> -struct ParamTraits<NPEvent> { - typedef NPEvent param_type; +struct ParamTraits<WebInputEventPointer> { + typedef WebInputEventPointer param_type; static void Write(Message* m, const param_type& p) { - m->WriteData(reinterpret_cast<const char*>(&p), sizeof(NPEvent)); + m->WriteData(reinterpret_cast<const char*>(p), p->size); } + // Note: upon read, the event has the lifetime of the message. static bool Read(const Message* m, void** iter, param_type* r) { - const char *data; - int data_size = 0; - bool result = m->ReadData(iter, &data, &data_size); - if (!result || data_size != sizeof(NPEvent)) { + const char* data; + int data_length; + if (!m->ReadData(iter, &data, &data_length)) { NOTREACHED(); return false; } - - memcpy(r, data, sizeof(NPEvent)); + if (data_length < static_cast<int>(sizeof(WebKit::WebInputEvent))) { + NOTREACHED(); + return false; + } + param_type event = reinterpret_cast<param_type>(data); + // Check that the data size matches that of the event (we check the latter + // in the delegate). + if (data_length != static_cast<int>(event->size)) { + NOTREACHED(); + return false; + } + *r = event; return true; } static void Log(const param_type& p, std::wstring* l) { -#if defined(OS_WIN) - std::wstring event, wparam, lparam; - lparam = StringPrintf(L"(%d, %d)", LOWORD(p.lParam), HIWORD(p.lParam)); - switch(p.event) { - case WM_KEYDOWN: - event = L"WM_KEYDOWN"; - wparam = StringPrintf(L"%d", p.wParam); - lparam = StringPrintf(L"%d", p.lParam); - break; - case WM_KEYUP: - event = L"WM_KEYDOWN"; - wparam = StringPrintf(L"%d", p.wParam); - lparam = StringPrintf(L"%x", p.lParam); - break; - case WM_MOUSEMOVE: - event = L"WM_MOUSEMOVE"; - if (p.wParam & MK_LBUTTON) { - wparam = L"MK_LBUTTON"; - } else if (p.wParam & MK_MBUTTON) { - wparam = L"MK_MBUTTON"; - } else if (p.wParam & MK_RBUTTON) { - wparam = L"MK_RBUTTON"; - } - break; - case WM_LBUTTONDOWN: - event = L"WM_LBUTTONDOWN"; - break; - case WM_MBUTTONDOWN: - event = L"WM_MBUTTONDOWN"; - break; - case WM_RBUTTONDOWN: - event = L"WM_RBUTTONDOWN"; - break; - case WM_LBUTTONUP: - event = L"WM_LBUTTONUP"; - break; - case WM_MBUTTONUP: - event = L"WM_MBUTTONUP"; - break; - case WM_RBUTTONUP: - event = L"WM_RBUTTONUP"; - break; - } - - if (p.wParam & MK_CONTROL) { - if (!wparam.empty()) - wparam += L" "; - wparam += L"MK_CONTROL"; - } - - if (p.wParam & MK_SHIFT) { - if (!wparam.empty()) - wparam += L" "; - wparam += L"MK_SHIFT"; - } - l->append(L"("); - LogParam(event, l); + LogParam(p->size, l); l->append(L", "); - LogParam(wparam, l); + LogParam(p->type, l); l->append(L", "); - LogParam(lparam, l); + LogParam(p->timeStampSeconds, l); l->append(L")"); -#else - l->append(L"<NPEvent>"); -#endif } }; |