1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
// Copyright (c) 2011 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 "ppapi/proxy/ppp_input_event_proxy.h"
#include <algorithm>
#include "ppapi/c/ppp_input_event.h"
#include "ppapi/proxy/host_dispatcher.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/plugin_resource_tracker.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/ppb_input_event_proxy.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_input_event_api.h"
using ppapi::thunk::EnterResourceNoLock;
using ppapi::thunk::PPB_InputEvent_API;
namespace ppapi {
namespace proxy {
namespace {
PP_Bool HandleInputEvent(PP_Instance instance, PP_Resource input_event) {
EnterResourceNoLock<PPB_InputEvent_API> enter(input_event, false);
if (enter.failed()) {
NOTREACHED();
return PP_FALSE;
}
const InputEventData& data = enter.object()->GetInputEventData();
HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
if (!dispatcher) {
NOTREACHED();
return PP_FALSE;
}
// Need to send different messages depending on whether filtering is needed.
PP_Bool result = PP_FALSE;
if (data.is_filtered) {
dispatcher->Send(new PpapiMsg_PPPInputEvent_HandleFilteredInputEvent(
INTERFACE_ID_PPP_INPUT_EVENT, instance, data, &result));
} else {
dispatcher->Send(new PpapiMsg_PPPInputEvent_HandleInputEvent(
INTERFACE_ID_PPP_INPUT_EVENT, instance, data));
}
return result;
}
static const PPP_InputEvent input_event_interface = {
&HandleInputEvent
};
InterfaceProxy* CreateInputEventProxy(Dispatcher* dispatcher,
const void* target_interface) {
return new PPP_InputEvent_Proxy(dispatcher, target_interface);
}
} // namespace
PPP_InputEvent_Proxy::PPP_InputEvent_Proxy(Dispatcher* dispatcher,
const void* target_interface)
: InterfaceProxy(dispatcher, target_interface) {
}
PPP_InputEvent_Proxy::~PPP_InputEvent_Proxy() {
}
// static
const InterfaceProxy::Info* PPP_InputEvent_Proxy::GetInfo() {
static const Info info = {
&input_event_interface,
PPP_INPUT_EVENT_INTERFACE,
INTERFACE_ID_PPP_INPUT_EVENT,
false,
&CreateInputEventProxy,
};
return &info;
}
bool PPP_InputEvent_Proxy::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PPP_InputEvent_Proxy, msg)
IPC_MESSAGE_HANDLER(PpapiMsg_PPPInputEvent_HandleInputEvent,
OnMsgHandleInputEvent)
IPC_MESSAGE_HANDLER(PpapiMsg_PPPInputEvent_HandleFilteredInputEvent,
OnMsgHandleFilteredInputEvent)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void PPP_InputEvent_Proxy::OnMsgHandleInputEvent(PP_Instance instance,
const InputEventData& data) {
PP_Resource event_resource = PPB_InputEvent_Proxy::CreateProxyResource(
instance, data);
ppp_input_event_target()->HandleInputEvent(instance, event_resource);
PluginResourceTracker::GetInstance()->ReleaseResource(event_resource);
}
void PPP_InputEvent_Proxy::OnMsgHandleFilteredInputEvent(
PP_Instance instance,
const InputEventData& data,
PP_Bool* result) {
PP_Resource event_resource = PPB_InputEvent_Proxy::CreateProxyResource(
instance, data);
*result = ppp_input_event_target()->HandleInputEvent(instance,
event_resource);
PluginResourceTracker::GetInstance()->ReleaseResource(event_resource);
}
} // namespace proxy
} // namespace ppapi
|