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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
// Copyright (c) 2010 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/ppb_instance_proxy.h"
#include "ppapi/c/pp_var.h"
#include "ppapi/c/ppb_instance.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/serialized_var.h"
namespace pp {
namespace proxy {
namespace {
PP_Var GetWindowObject(PP_Instance instance) {
Dispatcher* dispatcher = PluginDispatcher::Get();
ReceiveSerializedVarReturnValue result;
dispatcher->Send(new PpapiHostMsg_PPBInstance_GetWindowObject(
INTERFACE_ID_PPB_INSTANCE, instance, &result));
return result.Return(dispatcher);
}
PP_Var GetOwnerElementObject(PP_Instance instance) {
Dispatcher* dispatcher = PluginDispatcher::Get();
ReceiveSerializedVarReturnValue result;
dispatcher->Send(new PpapiHostMsg_PPBInstance_GetOwnerElementObject(
INTERFACE_ID_PPB_INSTANCE, instance, &result));
return result.Return(dispatcher);
}
PP_Bool BindGraphics(PP_Instance instance, PP_Resource device) {
PP_Bool result;
PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBInstance_BindGraphics(
INTERFACE_ID_PPB_INSTANCE, instance, device, &result));
return result;
}
PP_Bool IsFullFrame(PP_Instance instance) {
PP_Bool result;
PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBInstance_IsFullFrame(
INTERFACE_ID_PPB_INSTANCE, instance, &result));
return result;
}
PP_Var ExecuteScript(PP_Instance instance, PP_Var script, PP_Var* exception) {
Dispatcher* dispatcher = PluginDispatcher::Get();
ReceiveSerializedException se(dispatcher, exception);
if (se.IsThrown())
return PP_MakeUndefined();
ReceiveSerializedVarReturnValue result;
dispatcher->Send(new PpapiHostMsg_PPBInstance_ExecuteScript(
INTERFACE_ID_PPB_INSTANCE, instance,
SerializedVarSendInput(dispatcher, script), &se, &result));
return result.Return(dispatcher);
}
const PPB_Instance instance_interface = {
&GetWindowObject,
&GetOwnerElementObject,
&BindGraphics,
&IsFullFrame,
&ExecuteScript
};
} // namespace
PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher* dispatcher,
const void* target_interface)
: InterfaceProxy(dispatcher, target_interface) {
}
PPB_Instance_Proxy::~PPB_Instance_Proxy() {
}
const void* PPB_Instance_Proxy::GetSourceInterface() const {
return &instance_interface;
}
InterfaceID PPB_Instance_Proxy::GetInterfaceId() const {
return INTERFACE_ID_PPB_INSTANCE;
}
void PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP(PPB_Instance_Proxy, msg)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetWindowObject,
OnMsgGetWindowObject)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetOwnerElementObject,
OnMsgGetOwnerElementObject)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_BindGraphics,
OnMsgBindGraphics)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_IsFullFrame,
OnMsgIsFullFrame)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ExecuteScript,
OnMsgExecuteScript)
IPC_END_MESSAGE_MAP()
}
void PPB_Instance_Proxy::OnMsgGetWindowObject(
PP_Instance instance,
SerializedVarReturnValue result) {
result.Return(dispatcher(),
ppb_instance_target()->GetWindowObject(instance));
}
void PPB_Instance_Proxy::OnMsgGetOwnerElementObject(
PP_Instance instance,
SerializedVarReturnValue result) {
result.Return(dispatcher(),
ppb_instance_target()->GetOwnerElementObject(instance));
}
void PPB_Instance_Proxy::OnMsgBindGraphics(PP_Instance instance,
PP_Resource device,
PP_Bool* result) {
*result = ppb_instance_target()->BindGraphics(instance, device);
}
void PPB_Instance_Proxy::OnMsgIsFullFrame(PP_Instance instance,
PP_Bool* result) {
*result = ppb_instance_target()->IsFullFrame(instance);
}
void PPB_Instance_Proxy::OnMsgExecuteScript(
PP_Instance instance,
SerializedVarReceiveInput script,
SerializedVarOutParam out_exception,
SerializedVarReturnValue result) {
result.Return(dispatcher(), ppb_instance_target()->ExecuteScript(
instance,
script.Get(dispatcher()),
out_exception.OutParam(dispatcher())));
}
} // namespace proxy
} // namespace pp
|