summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/common/plugin_messages.h96
-rw-r--r--chrome/common/plugin_messages_internal.h4
-rw-r--r--chrome/common/webkit_param_traits.h3
-rw-r--r--chrome/plugin/webplugin_delegate_stub.cc11
-rw-r--r--chrome/plugin/webplugin_delegate_stub.h8
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.cc9
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.h3
7 files changed, 49 insertions, 85 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
}
};
diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h
index ed2e219..20a21f6 100644
--- a/chrome/common/plugin_messages_internal.h
+++ b/chrome/common/plugin_messages_internal.h
@@ -148,8 +148,8 @@ IPC_BEGIN_MESSAGES(Plugin)
IPC_SYNC_MESSAGE_ROUTED0_0(PluginMsg_SetFocus)
- IPC_SYNC_MESSAGE_ROUTED1_2(PluginMsg_HandleEvent,
- NPEvent /* event */,
+ IPC_SYNC_MESSAGE_ROUTED1_2(PluginMsg_HandleInputEvent,
+ IPC::WebInputEventPointer /* event */,
bool /* handled */,
WebCursor /* cursor type*/)
diff --git a/chrome/common/webkit_param_traits.h b/chrome/common/webkit_param_traits.h
index bf2630f6..733694a 100644
--- a/chrome/common/webkit_param_traits.h
+++ b/chrome/common/webkit_param_traits.h
@@ -165,6 +165,9 @@ struct ParamTraits<WebKit::WebInputEvent::Type> {
case WebKit::WebInputEvent::MouseLeave:
type = L"MouseLeave";
break;
+ case WebKit::WebInputEvent::MouseEnter:
+ type = L"MouseEnter";
+ break;
case WebKit::WebInputEvent::MouseWheel:
type = L"MouseWheel";
break;
diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc
index b76fc14..2188627 100644
--- a/chrome/plugin/webplugin_delegate_stub.cc
+++ b/chrome/plugin/webplugin_delegate_stub.cc
@@ -82,7 +82,7 @@ void WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(PluginMsg_DidFinishLoadWithReason,
OnDidFinishLoadWithReason)
IPC_MESSAGE_HANDLER(PluginMsg_SetFocus, OnSetFocus)
- IPC_MESSAGE_HANDLER(PluginMsg_HandleEvent, OnHandleEvent)
+ IPC_MESSAGE_HANDLER(PluginMsg_HandleInputEvent, OnHandleInputEvent)
IPC_MESSAGE_HANDLER(PluginMsg_Paint, OnPaint)
IPC_MESSAGE_HANDLER(PluginMsg_DidPaint, OnDidPaint)
IPC_MESSAGE_HANDLER(PluginMsg_Print, OnPrint)
@@ -212,10 +212,11 @@ void WebPluginDelegateStub::OnSetFocus() {
delegate_->SetFocus();
}
-void WebPluginDelegateStub::OnHandleEvent(const NPEvent& event,
- bool* handled,
- WebCursor* cursor) {
- *handled = delegate_->HandleEvent(const_cast<NPEvent*>(&event), cursor);
+void WebPluginDelegateStub::OnHandleInputEvent(
+ const WebKit::WebInputEvent *event,
+ bool* handled,
+ WebCursor* cursor) {
+ *handled = delegate_->HandleInputEvent(*event, cursor);
}
void WebPluginDelegateStub::OnPaint(const gfx::Rect& damaged_rect) {
diff --git a/chrome/plugin/webplugin_delegate_stub.h b/chrome/plugin/webplugin_delegate_stub.h
index d2103a0..b09038c 100644
--- a/chrome/plugin/webplugin_delegate_stub.h
+++ b/chrome/plugin/webplugin_delegate_stub.h
@@ -24,6 +24,10 @@ struct PluginMsg_DidReceiveResponseParams;
struct PluginMsg_URLRequestReply_Params;
class WebCursor;
+namespace WebKit {
+class WebInputEvent;
+}
+
// Converts the IPC messages from WebPluginDelegateProxy into calls to the
// actual WebPluginDelegate object.
class WebPluginDelegateStub : public IPC::Channel::Listener,
@@ -57,8 +61,8 @@ class WebPluginDelegateStub : public IPC::Channel::Listener,
void OnDidFinishLoadWithReason(int reason);
void OnSetFocus();
- void OnHandleEvent(const NPEvent& event, bool* handled,
- WebCursor* cursor);
+ void OnHandleInputEvent(const WebKit::WebInputEvent* event,
+ bool* handled, WebCursor* cursor);
void OnPaint(const gfx::Rect& damaged_rect);
void OnDidPaint();
diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc
index 24a8ee4..27f5422 100644
--- a/chrome/renderer/webplugin_delegate_proxy.cc
+++ b/chrome/renderer/webplugin_delegate_proxy.cc
@@ -610,15 +610,16 @@ void WebPluginDelegateProxy::SetFocus() {
Send(new PluginMsg_SetFocus(instance_id_));
}
-bool WebPluginDelegateProxy::HandleEvent(NPEvent* event, WebCursor* cursor) {
+bool WebPluginDelegateProxy::HandleInputEvent(
+ const WebKit::WebInputEvent& event,
+ WebCursor* cursor) {
bool handled;
// A windowless plugin can enter a modal loop in the context of a
// NPP_HandleEvent call, in which case we need to pump messages to
// the plugin. We pass of the corresponding event handle to the
// plugin process, which is set if the plugin does enter a modal loop.
- IPC::SyncMessage* message = new PluginMsg_HandleEvent(instance_id_,
- *event, &handled,
- cursor);
+ IPC::SyncMessage* message = new PluginMsg_HandleInputEvent(
+ instance_id_, &event, &handled, cursor);
message->set_pump_messages_event(modal_loop_pump_messages_event_.get());
Send(message);
return handled;
diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h
index 99bd1e1..be7d6d7 100644
--- a/chrome/renderer/webplugin_delegate_proxy.h
+++ b/chrome/renderer/webplugin_delegate_proxy.h
@@ -59,7 +59,8 @@ class WebPluginDelegateProxy : public WebPluginDelegate,
virtual NPObject* GetPluginScriptableObject();
virtual void DidFinishLoadWithReason(NPReason reason);
virtual void SetFocus();
- virtual bool HandleEvent(NPEvent* event, WebCursor* cursor);
+ virtual bool HandleInputEvent(const WebKit::WebInputEvent& event,
+ WebCursor* cursor);
virtual int GetProcessId();
// IPC::Channel::Listener implementation: