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 <wtf/Forward.h>
32#include <wtf/ThreadSafeRefCounted.h>
33#include <wtf/Vector.h>
34#include <wtf/text/WTFString.h>
35
36namespace WebCore {
37class HTTPHeaderMap;
38class IntRect;
39class ProtectionSpace;
40}
41
42namespace WebKit {
43class NPVariantData;
44}
45
46namespace Messages {
47namespace PluginProxy {
48
49static inline IPC::StringReference messageReceiverName()
50{
51 return IPC::StringReference("PluginProxy");
52}
53
54class LoadURL {
55public:
56 typedef std::tuple<uint64_t, const String&, const String&, const String&, const WebCore::HTTPHeaderMap&, const Vector<uint8_t>&, bool> Arguments;
57
58 static IPC::StringReference receiverName() { return messageReceiverName(); }
59 static IPC::StringReference name() { return IPC::StringReference("LoadURL"); }
60 static const bool isSync = false;
61
62 LoadURL(uint64_t requestID, const String& method, const String& urlString, const String& target, const WebCore::HTTPHeaderMap& headerFields, const Vector<uint8_t>& httpBody, bool allowPopups)
63 : m_arguments(requestID, method, urlString, target, headerFields, httpBody, allowPopups)
64 {
65 }
66
67 const Arguments& arguments() const
68 {
69 return m_arguments;
70 }
71
72private:
73 Arguments m_arguments;
74};
75
76class Update {
77public:
78 typedef std::tuple<const WebCore::IntRect&> Arguments;
79
80 static IPC::StringReference receiverName() { return messageReceiverName(); }
81 static IPC::StringReference name() { return IPC::StringReference("Update"); }
82 static const bool isSync = false;
83
84 explicit Update(const WebCore::IntRect& paintedRect)
85 : m_arguments(paintedRect)
86 {
87 }
88
89 const Arguments& arguments() const
90 {
91 return m_arguments;
92 }
93
94private:
95 Arguments m_arguments;
96};
97
98class ProxiesForURL {
99public:
100 typedef std::tuple<const String&> Arguments;
101
102 static IPC::StringReference receiverName() { return messageReceiverName(); }
103 static IPC::StringReference name() { return IPC::StringReference("ProxiesForURL"); }
104 static const bool isSync = true;
105
106 using DelayedReply = CompletionHandler<void(const String& proxiesString)>;
107 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const String& proxiesString);
108 using Reply = std::tuple<String&>;
109 using ReplyArguments = std::tuple<String>;
110 explicit ProxiesForURL(const String& urlString)
111 : m_arguments(urlString)
112 {
113 }
114
115 const Arguments& arguments() const
116 {
117 return m_arguments;
118 }
119
120private:
121 Arguments m_arguments;
122};
123
124class CookiesForURL {
125public:
126 typedef std::tuple<const String&> Arguments;
127
128 static IPC::StringReference receiverName() { return messageReceiverName(); }
129 static IPC::StringReference name() { return IPC::StringReference("CookiesForURL"); }
130 static const bool isSync = true;
131
132 using DelayedReply = CompletionHandler<void(const String& cookieString)>;
133 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const String& cookieString);
134 using Reply = std::tuple<String&>;
135 using ReplyArguments = std::tuple<String>;
136 explicit CookiesForURL(const String& urlString)
137 : m_arguments(urlString)
138 {
139 }
140
141 const Arguments& arguments() const
142 {
143 return m_arguments;
144 }
145
146private:
147 Arguments m_arguments;
148};
149
150class SetCookiesForURL {
151public:
152 typedef std::tuple<const String&, const String&> Arguments;
153
154 static IPC::StringReference receiverName() { return messageReceiverName(); }
155 static IPC::StringReference name() { return IPC::StringReference("SetCookiesForURL"); }
156 static const bool isSync = false;
157
158 SetCookiesForURL(const String& urlString, const String& cookieString)
159 : m_arguments(urlString, cookieString)
160 {
161 }
162
163 const Arguments& arguments() const
164 {
165 return m_arguments;
166 }
167
168private:
169 Arguments m_arguments;
170};
171
172class GetAuthenticationInfo {
173public:
174 typedef std::tuple<const WebCore::ProtectionSpace&> Arguments;
175
176 static IPC::StringReference receiverName() { return messageReceiverName(); }
177 static IPC::StringReference name() { return IPC::StringReference("GetAuthenticationInfo"); }
178 static const bool isSync = true;
179
180 using DelayedReply = CompletionHandler<void(bool returnValue, const String& username, const String& password)>;
181 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, bool returnValue, const String& username, const String& password);
182 using Reply = std::tuple<bool&, String&, String&>;
183 using ReplyArguments = std::tuple<bool, String, String>;
184 explicit GetAuthenticationInfo(const WebCore::ProtectionSpace& protectionSpace)
185 : m_arguments(protectionSpace)
186 {
187 }
188
189 const Arguments& arguments() const
190 {
191 return m_arguments;
192 }
193
194private:
195 Arguments m_arguments;
196};
197
198class GetPluginElementNPObject {
199public:
200 typedef std::tuple<> Arguments;
201
202 static IPC::StringReference receiverName() { return messageReceiverName(); }
203 static IPC::StringReference name() { return IPC::StringReference("GetPluginElementNPObject"); }
204 static const bool isSync = true;
205
206 using DelayedReply = CompletionHandler<void(uint64_t pluginElementNPObjectID)>;
207 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, uint64_t pluginElementNPObjectID);
208 using Reply = std::tuple<uint64_t&>;
209 using ReplyArguments = std::tuple<uint64_t>;
210 const Arguments& arguments() const
211 {
212 return m_arguments;
213 }
214
215private:
216 Arguments m_arguments;
217};
218
219class Evaluate {
220public:
221 typedef std::tuple<const WebKit::NPVariantData&, const String&, bool> Arguments;
222
223 static IPC::StringReference receiverName() { return messageReceiverName(); }
224 static IPC::StringReference name() { return IPC::StringReference("Evaluate"); }
225 static const bool isSync = true;
226
227 using DelayedReply = CompletionHandler<void(bool returnValue, const WebKit::NPVariantData& resultData)>;
228 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, bool returnValue, const WebKit::NPVariantData& resultData);
229 using Reply = std::tuple<bool&, WebKit::NPVariantData&>;
230 using ReplyArguments = std::tuple<bool, WebKit::NPVariantData>;
231 Evaluate(const WebKit::NPVariantData& npObjectAsVariantData, const String& scriptString, bool allowPopups)
232 : m_arguments(npObjectAsVariantData, scriptString, allowPopups)
233 {
234 }
235
236 const Arguments& arguments() const
237 {
238 return m_arguments;
239 }
240
241private:
242 Arguments m_arguments;
243};
244
245class CancelStreamLoad {
246public:
247 typedef std::tuple<uint64_t> Arguments;
248
249 static IPC::StringReference receiverName() { return messageReceiverName(); }
250 static IPC::StringReference name() { return IPC::StringReference("CancelStreamLoad"); }
251 static const bool isSync = false;
252
253 explicit CancelStreamLoad(uint64_t streamID)
254 : m_arguments(streamID)
255 {
256 }
257
258 const Arguments& arguments() const
259 {
260 return m_arguments;
261 }
262
263private:
264 Arguments m_arguments;
265};
266
267class ContinueStreamLoad {
268public:
269 typedef std::tuple<uint64_t> Arguments;
270
271 static IPC::StringReference receiverName() { return messageReceiverName(); }
272 static IPC::StringReference name() { return IPC::StringReference("ContinueStreamLoad"); }
273 static const bool isSync = false;
274
275 explicit ContinueStreamLoad(uint64_t streamID)
276 : m_arguments(streamID)
277 {
278 }
279
280 const Arguments& arguments() const
281 {
282 return m_arguments;
283 }
284
285private:
286 Arguments m_arguments;
287};
288
289class CancelManualStreamLoad {
290public:
291 typedef std::tuple<> Arguments;
292
293 static IPC::StringReference receiverName() { return messageReceiverName(); }
294 static IPC::StringReference name() { return IPC::StringReference("CancelManualStreamLoad"); }
295 static const bool isSync = false;
296
297 const Arguments& arguments() const
298 {
299 return m_arguments;
300 }
301
302private:
303 Arguments m_arguments;
304};
305
306class SetStatusbarText {
307public:
308 typedef std::tuple<const String&> Arguments;
309
310 static IPC::StringReference receiverName() { return messageReceiverName(); }
311 static IPC::StringReference name() { return IPC::StringReference("SetStatusbarText"); }
312 static const bool isSync = false;
313
314 explicit SetStatusbarText(const String& statusbarText)
315 : m_arguments(statusbarText)
316 {
317 }
318
319 const Arguments& arguments() const
320 {
321 return m_arguments;
322 }
323
324private:
325 Arguments m_arguments;
326};
327
328#if PLATFORM(COCOA)
329class PluginFocusOrWindowFocusChanged {
330public:
331 typedef std::tuple<bool> Arguments;
332
333 static IPC::StringReference receiverName() { return messageReceiverName(); }
334 static IPC::StringReference name() { return IPC::StringReference("PluginFocusOrWindowFocusChanged"); }
335 static const bool isSync = false;
336
337 explicit PluginFocusOrWindowFocusChanged(bool pluginHasFocusAndWindowHasFocus)
338 : m_arguments(pluginHasFocusAndWindowHasFocus)
339 {
340 }
341
342 const Arguments& arguments() const
343 {
344 return m_arguments;
345 }
346
347private:
348 Arguments m_arguments;
349};
350#endif
351
352#if PLATFORM(COCOA)
353class SetComplexTextInputState {
354public:
355 typedef std::tuple<uint64_t> Arguments;
356
357 static IPC::StringReference receiverName() { return messageReceiverName(); }
358 static IPC::StringReference name() { return IPC::StringReference("SetComplexTextInputState"); }
359 static const bool isSync = false;
360
361 explicit SetComplexTextInputState(uint64_t complexTextInputState)
362 : m_arguments(complexTextInputState)
363 {
364 }
365
366 const Arguments& arguments() const
367 {
368 return m_arguments;
369 }
370
371private:
372 Arguments m_arguments;
373};
374#endif
375
376#if PLATFORM(COCOA)
377class SetLayerHostingContextID {
378public:
379 typedef std::tuple<uint32_t> Arguments;
380
381 static IPC::StringReference receiverName() { return messageReceiverName(); }
382 static IPC::StringReference name() { return IPC::StringReference("SetLayerHostingContextID"); }
383 static const bool isSync = false;
384
385 explicit SetLayerHostingContextID(uint32_t layerHostingContextID)
386 : m_arguments(layerHostingContextID)
387 {
388 }
389
390 const Arguments& arguments() const
391 {
392 return m_arguments;
393 }
394
395private:
396 Arguments m_arguments;
397};
398#endif
399
400#if PLATFORM(X11)
401class CreatePluginContainer {
402public:
403 typedef std::tuple<> Arguments;
404
405 static IPC::StringReference receiverName() { return messageReceiverName(); }
406 static IPC::StringReference name() { return IPC::StringReference("CreatePluginContainer"); }
407 static const bool isSync = true;
408
409 using DelayedReply = CompletionHandler<void(uint64_t windowID)>;
410 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, uint64_t windowID);
411 using Reply = std::tuple<uint64_t&>;
412 using ReplyArguments = std::tuple<uint64_t>;
413 const Arguments& arguments() const
414 {
415 return m_arguments;
416 }
417
418private:
419 Arguments m_arguments;
420};
421#endif
422
423#if PLATFORM(X11)
424class WindowedPluginGeometryDidChange {
425public:
426 typedef std::tuple<const WebCore::IntRect&, const WebCore::IntRect&, uint64_t> Arguments;
427
428 static IPC::StringReference receiverName() { return messageReceiverName(); }
429 static IPC::StringReference name() { return IPC::StringReference("WindowedPluginGeometryDidChange"); }
430 static const bool isSync = false;
431
432 WindowedPluginGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, uint64_t windowID)
433 : m_arguments(frameRect, clipRect, windowID)
434 {
435 }
436
437 const Arguments& arguments() const
438 {
439 return m_arguments;
440 }
441
442private:
443 Arguments m_arguments;
444};
445#endif
446
447#if PLATFORM(X11)
448class WindowedPluginVisibilityDidChange {
449public:
450 typedef std::tuple<bool, uint64_t> Arguments;
451
452 static IPC::StringReference receiverName() { return messageReceiverName(); }
453 static IPC::StringReference name() { return IPC::StringReference("WindowedPluginVisibilityDidChange"); }
454 static const bool isSync = false;
455
456 WindowedPluginVisibilityDidChange(bool isVisible, uint64_t windowID)
457 : m_arguments(isVisible, windowID)
458 {
459 }
460
461 const Arguments& arguments() const
462 {
463 return m_arguments;
464 }
465
466private:
467 Arguments m_arguments;
468};
469#endif
470
471class DidCreatePlugin {
472public:
473 typedef std::tuple<bool, uint32_t> Arguments;
474
475 static IPC::StringReference receiverName() { return messageReceiverName(); }
476 static IPC::StringReference name() { return IPC::StringReference("DidCreatePlugin"); }
477 static const bool isSync = true;
478
479 using DelayedReply = CompletionHandler<void()>;
480 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&);
481 using Reply = std::tuple<>;
482 using ReplyArguments = std::tuple<>;
483 DidCreatePlugin(bool wantsWheelEvents, uint32_t remoteLayerClientID)
484 : m_arguments(wantsWheelEvents, remoteLayerClientID)
485 {
486 }
487
488 const Arguments& arguments() const
489 {
490 return m_arguments;
491 }
492
493private:
494 Arguments m_arguments;
495};
496
497class DidFailToCreatePlugin {
498public:
499 typedef std::tuple<> Arguments;
500
501 static IPC::StringReference receiverName() { return messageReceiverName(); }
502 static IPC::StringReference name() { return IPC::StringReference("DidFailToCreatePlugin"); }
503 static const bool isSync = true;
504
505 using DelayedReply = CompletionHandler<void()>;
506 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&);
507 using Reply = std::tuple<>;
508 using ReplyArguments = std::tuple<>;
509 const Arguments& arguments() const
510 {
511 return m_arguments;
512 }
513
514private:
515 Arguments m_arguments;
516};
517
518class SetPluginIsPlayingAudio {
519public:
520 typedef std::tuple<bool> Arguments;
521
522 static IPC::StringReference receiverName() { return messageReceiverName(); }
523 static IPC::StringReference name() { return IPC::StringReference("SetPluginIsPlayingAudio"); }
524 static const bool isSync = false;
525
526 explicit SetPluginIsPlayingAudio(bool pluginIsPlayingAudio)
527 : m_arguments(pluginIsPlayingAudio)
528 {
529 }
530
531 const Arguments& arguments() const
532 {
533 return m_arguments;
534 }
535
536private:
537 Arguments m_arguments;
538};
539
540} // namespace PluginProxy
541} // namespace Messages
542
543#endif // ENABLE(NETSCAPE_PLUGIN_API)
544