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 | #include "ArgumentCoders.h" |
28 | #include "Connection.h" |
29 | #include <WebCore/Cookie.h> |
30 | #include <WebCore/IntPoint.h> |
31 | #include <wtf/Forward.h> |
32 | #include <wtf/Optional.h> |
33 | #include <wtf/ThreadSafeRefCounted.h> |
34 | #include <wtf/Vector.h> |
35 | #include <wtf/text/WTFString.h> |
36 | |
37 | namespace WebCore { |
38 | class IntRect; |
39 | } |
40 | |
41 | namespace WebKit { |
42 | enum class CoordinateSystem : uint8_t; |
43 | } |
44 | |
45 | namespace Messages { |
46 | namespace WebAutomationSessionProxy { |
47 | |
48 | static inline IPC::StringReference messageReceiverName() |
49 | { |
50 | return IPC::StringReference("WebAutomationSessionProxy" ); |
51 | } |
52 | |
53 | class EvaluateJavaScriptFunction { |
54 | public: |
55 | typedef std::tuple<uint64_t, uint64_t, const String&, const Vector<String>&, bool, const int&, uint64_t> Arguments; |
56 | |
57 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
58 | static IPC::StringReference name() { return IPC::StringReference("EvaluateJavaScriptFunction" ); } |
59 | static const bool isSync = false; |
60 | |
61 | EvaluateJavaScriptFunction(uint64_t pageID, uint64_t frameID, const String& function, const Vector<String>& arguments, bool expectsImplicitCallbackArgument, const int& callbackTimeout, uint64_t callbackID) |
62 | : m_arguments(pageID, frameID, function, arguments, expectsImplicitCallbackArgument, callbackTimeout, callbackID) |
63 | { |
64 | } |
65 | |
66 | const Arguments& arguments() const |
67 | { |
68 | return m_arguments; |
69 | } |
70 | |
71 | private: |
72 | Arguments m_arguments; |
73 | }; |
74 | |
75 | class ResolveChildFrameWithOrdinal { |
76 | public: |
77 | typedef std::tuple<uint64_t, uint64_t, uint32_t> Arguments; |
78 | |
79 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
80 | static IPC::StringReference name() { return IPC::StringReference("ResolveChildFrameWithOrdinal" ); } |
81 | static const bool isSync = false; |
82 | |
83 | static void callReply(IPC::Decoder&, CompletionHandler<void(Optional<String>&&, uint64_t&&)>&&); |
84 | static void cancelReply(CompletionHandler<void(Optional<String>&&, uint64_t&&)>&&); |
85 | static IPC::StringReference asyncMessageReplyName() { return { "ResolveChildFrameWithOrdinalReply" }; } |
86 | using AsyncReply = CompletionHandler<void(const Optional<String>& errorType, uint64_t frameID)>; |
87 | static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const Optional<String>& errorType, uint64_t frameID); |
88 | using Reply = std::tuple<Optional<String>&, uint64_t&>; |
89 | using ReplyArguments = std::tuple<Optional<String>, uint64_t>; |
90 | ResolveChildFrameWithOrdinal(uint64_t pageID, uint64_t frameID, uint32_t ordinal) |
91 | : m_arguments(pageID, frameID, ordinal) |
92 | { |
93 | } |
94 | |
95 | const Arguments& arguments() const |
96 | { |
97 | return m_arguments; |
98 | } |
99 | |
100 | private: |
101 | Arguments m_arguments; |
102 | }; |
103 | |
104 | class ResolveChildFrameWithNodeHandle { |
105 | public: |
106 | typedef std::tuple<uint64_t, uint64_t, const String&> Arguments; |
107 | |
108 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
109 | static IPC::StringReference name() { return IPC::StringReference("ResolveChildFrameWithNodeHandle" ); } |
110 | static const bool isSync = false; |
111 | |
112 | static void callReply(IPC::Decoder&, CompletionHandler<void(Optional<String>&&, uint64_t&&)>&&); |
113 | static void cancelReply(CompletionHandler<void(Optional<String>&&, uint64_t&&)>&&); |
114 | static IPC::StringReference asyncMessageReplyName() { return { "ResolveChildFrameWithNodeHandleReply" }; } |
115 | using AsyncReply = CompletionHandler<void(const Optional<String>& errorType, uint64_t frameID)>; |
116 | static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const Optional<String>& errorType, uint64_t frameID); |
117 | using Reply = std::tuple<Optional<String>&, uint64_t&>; |
118 | using ReplyArguments = std::tuple<Optional<String>, uint64_t>; |
119 | ResolveChildFrameWithNodeHandle(uint64_t pageID, uint64_t frameID, const String& nodeHandle) |
120 | : m_arguments(pageID, frameID, nodeHandle) |
121 | { |
122 | } |
123 | |
124 | const Arguments& arguments() const |
125 | { |
126 | return m_arguments; |
127 | } |
128 | |
129 | private: |
130 | Arguments m_arguments; |
131 | }; |
132 | |
133 | class ResolveChildFrameWithName { |
134 | public: |
135 | typedef std::tuple<uint64_t, uint64_t, const String&> Arguments; |
136 | |
137 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
138 | static IPC::StringReference name() { return IPC::StringReference("ResolveChildFrameWithName" ); } |
139 | static const bool isSync = false; |
140 | |
141 | static void callReply(IPC::Decoder&, CompletionHandler<void(Optional<String>&&, uint64_t&&)>&&); |
142 | static void cancelReply(CompletionHandler<void(Optional<String>&&, uint64_t&&)>&&); |
143 | static IPC::StringReference asyncMessageReplyName() { return { "ResolveChildFrameWithNameReply" }; } |
144 | using AsyncReply = CompletionHandler<void(const Optional<String>& errorType, uint64_t frameID)>; |
145 | static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const Optional<String>& errorType, uint64_t frameID); |
146 | using Reply = std::tuple<Optional<String>&, uint64_t&>; |
147 | using ReplyArguments = std::tuple<Optional<String>, uint64_t>; |
148 | ResolveChildFrameWithName(uint64_t pageID, uint64_t frameID, const String& name) |
149 | : m_arguments(pageID, frameID, name) |
150 | { |
151 | } |
152 | |
153 | const Arguments& arguments() const |
154 | { |
155 | return m_arguments; |
156 | } |
157 | |
158 | private: |
159 | Arguments m_arguments; |
160 | }; |
161 | |
162 | class ResolveParentFrame { |
163 | public: |
164 | typedef std::tuple<uint64_t, uint64_t> Arguments; |
165 | |
166 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
167 | static IPC::StringReference name() { return IPC::StringReference("ResolveParentFrame" ); } |
168 | static const bool isSync = false; |
169 | |
170 | static void callReply(IPC::Decoder&, CompletionHandler<void(Optional<String>&&, uint64_t&&)>&&); |
171 | static void cancelReply(CompletionHandler<void(Optional<String>&&, uint64_t&&)>&&); |
172 | static IPC::StringReference asyncMessageReplyName() { return { "ResolveParentFrameReply" }; } |
173 | using AsyncReply = CompletionHandler<void(const Optional<String>& errorType, uint64_t frameID)>; |
174 | static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const Optional<String>& errorType, uint64_t frameID); |
175 | using Reply = std::tuple<Optional<String>&, uint64_t&>; |
176 | using ReplyArguments = std::tuple<Optional<String>, uint64_t>; |
177 | ResolveParentFrame(uint64_t pageID, uint64_t frameID) |
178 | : m_arguments(pageID, frameID) |
179 | { |
180 | } |
181 | |
182 | const Arguments& arguments() const |
183 | { |
184 | return m_arguments; |
185 | } |
186 | |
187 | private: |
188 | Arguments m_arguments; |
189 | }; |
190 | |
191 | class FocusFrame { |
192 | public: |
193 | typedef std::tuple<uint64_t, uint64_t> Arguments; |
194 | |
195 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
196 | static IPC::StringReference name() { return IPC::StringReference("FocusFrame" ); } |
197 | static const bool isSync = false; |
198 | |
199 | FocusFrame(uint64_t pageID, uint64_t frameID) |
200 | : m_arguments(pageID, frameID) |
201 | { |
202 | } |
203 | |
204 | const Arguments& arguments() const |
205 | { |
206 | return m_arguments; |
207 | } |
208 | |
209 | private: |
210 | Arguments m_arguments; |
211 | }; |
212 | |
213 | class ComputeElementLayout { |
214 | public: |
215 | typedef std::tuple<uint64_t, uint64_t, const String&, bool, WebKit::CoordinateSystem> Arguments; |
216 | |
217 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
218 | static IPC::StringReference name() { return IPC::StringReference("ComputeElementLayout" ); } |
219 | static const bool isSync = false; |
220 | |
221 | static void callReply(IPC::Decoder&, CompletionHandler<void(Optional<String>&&, WebCore::IntRect&&, Optional<WebCore::IntPoint>&&, bool&&)>&&); |
222 | static void cancelReply(CompletionHandler<void(Optional<String>&&, WebCore::IntRect&&, Optional<WebCore::IntPoint>&&, bool&&)>&&); |
223 | static IPC::StringReference asyncMessageReplyName() { return { "ComputeElementLayoutReply" }; } |
224 | using AsyncReply = CompletionHandler<void(const Optional<String>& errorType, const WebCore::IntRect& rect, const Optional<WebCore::IntPoint>& inViewCenterPoint, bool isObscured)>; |
225 | static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const Optional<String>& errorType, const WebCore::IntRect& rect, const Optional<WebCore::IntPoint>& inViewCenterPoint, bool isObscured); |
226 | using Reply = std::tuple<Optional<String>&, WebCore::IntRect&, Optional<WebCore::IntPoint>&, bool&>; |
227 | using ReplyArguments = std::tuple<Optional<String>, WebCore::IntRect, Optional<WebCore::IntPoint>, bool>; |
228 | ComputeElementLayout(uint64_t pageID, uint64_t frameID, const String& nodeHandle, bool scrollIntoViewIfNeeded, WebKit::CoordinateSystem coordinateSystem) |
229 | : m_arguments(pageID, frameID, nodeHandle, scrollIntoViewIfNeeded, coordinateSystem) |
230 | { |
231 | } |
232 | |
233 | const Arguments& arguments() const |
234 | { |
235 | return m_arguments; |
236 | } |
237 | |
238 | private: |
239 | Arguments m_arguments; |
240 | }; |
241 | |
242 | class SelectOptionElement { |
243 | public: |
244 | typedef std::tuple<uint64_t, uint64_t, const String&> Arguments; |
245 | |
246 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
247 | static IPC::StringReference name() { return IPC::StringReference("SelectOptionElement" ); } |
248 | static const bool isSync = false; |
249 | |
250 | static void callReply(IPC::Decoder&, CompletionHandler<void(Optional<String>&&)>&&); |
251 | static void cancelReply(CompletionHandler<void(Optional<String>&&)>&&); |
252 | static IPC::StringReference asyncMessageReplyName() { return { "SelectOptionElementReply" }; } |
253 | using AsyncReply = CompletionHandler<void(const Optional<String>& errorType)>; |
254 | static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const Optional<String>& errorType); |
255 | using Reply = std::tuple<Optional<String>&>; |
256 | using ReplyArguments = std::tuple<Optional<String>>; |
257 | SelectOptionElement(uint64_t pageID, uint64_t frameID, const String& nodeHandle) |
258 | : m_arguments(pageID, frameID, nodeHandle) |
259 | { |
260 | } |
261 | |
262 | const Arguments& arguments() const |
263 | { |
264 | return m_arguments; |
265 | } |
266 | |
267 | private: |
268 | Arguments m_arguments; |
269 | }; |
270 | |
271 | class TakeScreenshot { |
272 | public: |
273 | typedef std::tuple<uint64_t, uint64_t, const String&, bool, bool, uint64_t> Arguments; |
274 | |
275 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
276 | static IPC::StringReference name() { return IPC::StringReference("TakeScreenshot" ); } |
277 | static const bool isSync = false; |
278 | |
279 | TakeScreenshot(uint64_t pageID, uint64_t frameID, const String& nodeHandle, bool scrollIntoViewIfNeeded, bool clipToViewport, uint64_t callbackID) |
280 | : m_arguments(pageID, frameID, nodeHandle, scrollIntoViewIfNeeded, clipToViewport, callbackID) |
281 | { |
282 | } |
283 | |
284 | const Arguments& arguments() const |
285 | { |
286 | return m_arguments; |
287 | } |
288 | |
289 | private: |
290 | Arguments m_arguments; |
291 | }; |
292 | |
293 | class GetCookiesForFrame { |
294 | public: |
295 | typedef std::tuple<uint64_t, uint64_t> Arguments; |
296 | |
297 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
298 | static IPC::StringReference name() { return IPC::StringReference("GetCookiesForFrame" ); } |
299 | static const bool isSync = false; |
300 | |
301 | static void callReply(IPC::Decoder&, CompletionHandler<void(Optional<String>&&, Vector<WebCore::Cookie>&&)>&&); |
302 | static void cancelReply(CompletionHandler<void(Optional<String>&&, Vector<WebCore::Cookie>&&)>&&); |
303 | static IPC::StringReference asyncMessageReplyName() { return { "GetCookiesForFrameReply" }; } |
304 | using AsyncReply = CompletionHandler<void(const Optional<String>& errorType, const Vector<WebCore::Cookie>& cookies)>; |
305 | static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const Optional<String>& errorType, const Vector<WebCore::Cookie>& cookies); |
306 | using Reply = std::tuple<Optional<String>&, Vector<WebCore::Cookie>&>; |
307 | using ReplyArguments = std::tuple<Optional<String>, Vector<WebCore::Cookie>>; |
308 | GetCookiesForFrame(uint64_t pageID, uint64_t frameID) |
309 | : m_arguments(pageID, frameID) |
310 | { |
311 | } |
312 | |
313 | const Arguments& arguments() const |
314 | { |
315 | return m_arguments; |
316 | } |
317 | |
318 | private: |
319 | Arguments m_arguments; |
320 | }; |
321 | |
322 | class DeleteCookie { |
323 | public: |
324 | typedef std::tuple<uint64_t, uint64_t, const String&> Arguments; |
325 | |
326 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
327 | static IPC::StringReference name() { return IPC::StringReference("DeleteCookie" ); } |
328 | static const bool isSync = false; |
329 | |
330 | static void callReply(IPC::Decoder&, CompletionHandler<void(Optional<String>&&)>&&); |
331 | static void cancelReply(CompletionHandler<void(Optional<String>&&)>&&); |
332 | static IPC::StringReference asyncMessageReplyName() { return { "DeleteCookieReply" }; } |
333 | using AsyncReply = CompletionHandler<void(const Optional<String>& errorType)>; |
334 | static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const Optional<String>& errorType); |
335 | using Reply = std::tuple<Optional<String>&>; |
336 | using ReplyArguments = std::tuple<Optional<String>>; |
337 | DeleteCookie(uint64_t pageID, uint64_t frameID, const String& cookieName) |
338 | : m_arguments(pageID, frameID, cookieName) |
339 | { |
340 | } |
341 | |
342 | const Arguments& arguments() const |
343 | { |
344 | return m_arguments; |
345 | } |
346 | |
347 | private: |
348 | Arguments m_arguments; |
349 | }; |
350 | |
351 | } // namespace WebAutomationSessionProxy |
352 | } // namespace Messages |
353 | |