1/*
2 * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#pragma once
26
27#if ENABLE(NETSCAPE_PLUGIN_API)
28
29#include "ArgumentCoders.h"
30#include "Connection.h"
31#include "NPIdentifierData.h"
32#include "NPVariantData.h"
33#include <wtf/Forward.h>
34#include <wtf/ThreadSafeRefCounted.h>
35#include <wtf/Vector.h>
36
37namespace WebKit {
38class NPIdentifierData;
39class NPVariantData;
40}
41
42namespace Messages {
43namespace NPObjectMessageReceiver {
44
45static inline IPC::StringReference messageReceiverName()
46{
47 return IPC::StringReference("NPObjectMessageReceiver");
48}
49
50class Deallocate {
51public:
52 typedef std::tuple<> Arguments;
53
54 static IPC::StringReference receiverName() { return messageReceiverName(); }
55 static IPC::StringReference name() { return IPC::StringReference("Deallocate"); }
56 static const bool isSync = true;
57
58 using DelayedReply = CompletionHandler<void()>;
59 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&);
60 using Reply = std::tuple<>;
61 using ReplyArguments = std::tuple<>;
62 const Arguments& arguments() const
63 {
64 return m_arguments;
65 }
66
67private:
68 Arguments m_arguments;
69};
70
71class HasMethod {
72public:
73 typedef std::tuple<const WebKit::NPIdentifierData&> Arguments;
74
75 static IPC::StringReference receiverName() { return messageReceiverName(); }
76 static IPC::StringReference name() { return IPC::StringReference("HasMethod"); }
77 static const bool isSync = true;
78
79 using DelayedReply = CompletionHandler<void(bool returnValue)>;
80 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, bool returnValue);
81 using Reply = std::tuple<bool&>;
82 using ReplyArguments = std::tuple<bool>;
83 explicit HasMethod(const WebKit::NPIdentifierData& methodName)
84 : m_arguments(methodName)
85 {
86 }
87
88 const Arguments& arguments() const
89 {
90 return m_arguments;
91 }
92
93private:
94 Arguments m_arguments;
95};
96
97class Invoke {
98public:
99 typedef std::tuple<const WebKit::NPIdentifierData&, const Vector<WebKit::NPVariantData>&> Arguments;
100
101 static IPC::StringReference receiverName() { return messageReceiverName(); }
102 static IPC::StringReference name() { return IPC::StringReference("Invoke"); }
103 static const bool isSync = true;
104
105 using DelayedReply = CompletionHandler<void(bool returnValue, const WebKit::NPVariantData& resultData)>;
106 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, bool returnValue, const WebKit::NPVariantData& resultData);
107 using Reply = std::tuple<bool&, WebKit::NPVariantData&>;
108 using ReplyArguments = std::tuple<bool, WebKit::NPVariantData>;
109 Invoke(const WebKit::NPIdentifierData& methodName, const Vector<WebKit::NPVariantData>& argumentsData)
110 : m_arguments(methodName, argumentsData)
111 {
112 }
113
114 const Arguments& arguments() const
115 {
116 return m_arguments;
117 }
118
119private:
120 Arguments m_arguments;
121};
122
123class InvokeDefault {
124public:
125 typedef std::tuple<const Vector<WebKit::NPVariantData>&> Arguments;
126
127 static IPC::StringReference receiverName() { return messageReceiverName(); }
128 static IPC::StringReference name() { return IPC::StringReference("InvokeDefault"); }
129 static const bool isSync = true;
130
131 using DelayedReply = CompletionHandler<void(bool returnValue, const WebKit::NPVariantData& resultData)>;
132 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, bool returnValue, const WebKit::NPVariantData& resultData);
133 using Reply = std::tuple<bool&, WebKit::NPVariantData&>;
134 using ReplyArguments = std::tuple<bool, WebKit::NPVariantData>;
135 explicit InvokeDefault(const Vector<WebKit::NPVariantData>& argumentsData)
136 : m_arguments(argumentsData)
137 {
138 }
139
140 const Arguments& arguments() const
141 {
142 return m_arguments;
143 }
144
145private:
146 Arguments m_arguments;
147};
148
149class HasProperty {
150public:
151 typedef std::tuple<const WebKit::NPIdentifierData&> Arguments;
152
153 static IPC::StringReference receiverName() { return messageReceiverName(); }
154 static IPC::StringReference name() { return IPC::StringReference("HasProperty"); }
155 static const bool isSync = true;
156
157 using DelayedReply = CompletionHandler<void(bool returnValue)>;
158 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, bool returnValue);
159 using Reply = std::tuple<bool&>;
160 using ReplyArguments = std::tuple<bool>;
161 explicit HasProperty(const WebKit::NPIdentifierData& propertyName)
162 : m_arguments(propertyName)
163 {
164 }
165
166 const Arguments& arguments() const
167 {
168 return m_arguments;
169 }
170
171private:
172 Arguments m_arguments;
173};
174
175class GetProperty {
176public:
177 typedef std::tuple<const WebKit::NPIdentifierData&> Arguments;
178
179 static IPC::StringReference receiverName() { return messageReceiverName(); }
180 static IPC::StringReference name() { return IPC::StringReference("GetProperty"); }
181 static const bool isSync = true;
182
183 using DelayedReply = CompletionHandler<void(bool returnValue, const WebKit::NPVariantData& resultData)>;
184 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, bool returnValue, const WebKit::NPVariantData& resultData);
185 using Reply = std::tuple<bool&, WebKit::NPVariantData&>;
186 using ReplyArguments = std::tuple<bool, WebKit::NPVariantData>;
187 explicit GetProperty(const WebKit::NPIdentifierData& propertyName)
188 : m_arguments(propertyName)
189 {
190 }
191
192 const Arguments& arguments() const
193 {
194 return m_arguments;
195 }
196
197private:
198 Arguments m_arguments;
199};
200
201class SetProperty {
202public:
203 typedef std::tuple<const WebKit::NPIdentifierData&, const WebKit::NPVariantData&> Arguments;
204
205 static IPC::StringReference receiverName() { return messageReceiverName(); }
206 static IPC::StringReference name() { return IPC::StringReference("SetProperty"); }
207 static const bool isSync = true;
208
209 using DelayedReply = CompletionHandler<void(bool returnValue)>;
210 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, bool returnValue);
211 using Reply = std::tuple<bool&>;
212 using ReplyArguments = std::tuple<bool>;
213 SetProperty(const WebKit::NPIdentifierData& propertyName, const WebKit::NPVariantData& propertyValueData)
214 : m_arguments(propertyName, propertyValueData)
215 {
216 }
217
218 const Arguments& arguments() const
219 {
220 return m_arguments;
221 }
222
223private:
224 Arguments m_arguments;
225};
226
227class RemoveProperty {
228public:
229 typedef std::tuple<const WebKit::NPIdentifierData&> Arguments;
230
231 static IPC::StringReference receiverName() { return messageReceiverName(); }
232 static IPC::StringReference name() { return IPC::StringReference("RemoveProperty"); }
233 static const bool isSync = true;
234
235 using DelayedReply = CompletionHandler<void(bool returnValue)>;
236 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, bool returnValue);
237 using Reply = std::tuple<bool&>;
238 using ReplyArguments = std::tuple<bool>;
239 explicit RemoveProperty(const WebKit::NPIdentifierData& propertyName)
240 : m_arguments(propertyName)
241 {
242 }
243
244 const Arguments& arguments() const
245 {
246 return m_arguments;
247 }
248
249private:
250 Arguments m_arguments;
251};
252
253class Enumerate {
254public:
255 typedef std::tuple<> Arguments;
256
257 static IPC::StringReference receiverName() { return messageReceiverName(); }
258 static IPC::StringReference name() { return IPC::StringReference("Enumerate"); }
259 static const bool isSync = true;
260
261 using DelayedReply = CompletionHandler<void(bool returnValue, const Vector<WebKit::NPIdentifierData>& identifiersData)>;
262 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, bool returnValue, const Vector<WebKit::NPIdentifierData>& identifiersData);
263 using Reply = std::tuple<bool&, Vector<WebKit::NPIdentifierData>&>;
264 using ReplyArguments = std::tuple<bool, Vector<WebKit::NPIdentifierData>>;
265 const Arguments& arguments() const
266 {
267 return m_arguments;
268 }
269
270private:
271 Arguments m_arguments;
272};
273
274class Construct {
275public:
276 typedef std::tuple<const Vector<WebKit::NPVariantData>&> Arguments;
277
278 static IPC::StringReference receiverName() { return messageReceiverName(); }
279 static IPC::StringReference name() { return IPC::StringReference("Construct"); }
280 static const bool isSync = true;
281
282 using DelayedReply = CompletionHandler<void(bool returnValue, const WebKit::NPVariantData& resultData)>;
283 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, bool returnValue, const WebKit::NPVariantData& resultData);
284 using Reply = std::tuple<bool&, WebKit::NPVariantData&>;
285 using ReplyArguments = std::tuple<bool, WebKit::NPVariantData>;
286 explicit Construct(const Vector<WebKit::NPVariantData>& argumentsData)
287 : m_arguments(argumentsData)
288 {
289 }
290
291 const Arguments& arguments() const
292 {
293 return m_arguments;
294 }
295
296private:
297 Arguments m_arguments;
298};
299
300} // namespace NPObjectMessageReceiver
301} // namespace Messages
302
303#endif // ENABLE(NETSCAPE_PLUGIN_API)
304