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