| 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 | |
| 37 | namespace WebKit { |
| 38 | class NPIdentifierData; |
| 39 | class NPVariantData; |
| 40 | } |
| 41 | |
| 42 | namespace Messages { |
| 43 | namespace NPObjectMessageReceiver { |
| 44 | |
| 45 | static inline IPC::StringReference messageReceiverName() |
| 46 | { |
| 47 | return IPC::StringReference("NPObjectMessageReceiver" ); |
| 48 | } |
| 49 | |
| 50 | class Deallocate { |
| 51 | public: |
| 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 | |
| 67 | private: |
| 68 | Arguments m_arguments; |
| 69 | }; |
| 70 | |
| 71 | class HasMethod { |
| 72 | public: |
| 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 | |
| 93 | private: |
| 94 | Arguments m_arguments; |
| 95 | }; |
| 96 | |
| 97 | class Invoke { |
| 98 | public: |
| 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 | |
| 119 | private: |
| 120 | Arguments m_arguments; |
| 121 | }; |
| 122 | |
| 123 | class InvokeDefault { |
| 124 | public: |
| 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 | |
| 145 | private: |
| 146 | Arguments m_arguments; |
| 147 | }; |
| 148 | |
| 149 | class HasProperty { |
| 150 | public: |
| 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 | |
| 171 | private: |
| 172 | Arguments m_arguments; |
| 173 | }; |
| 174 | |
| 175 | class GetProperty { |
| 176 | public: |
| 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 | |
| 197 | private: |
| 198 | Arguments m_arguments; |
| 199 | }; |
| 200 | |
| 201 | class SetProperty { |
| 202 | public: |
| 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 | |
| 223 | private: |
| 224 | Arguments m_arguments; |
| 225 | }; |
| 226 | |
| 227 | class RemoveProperty { |
| 228 | public: |
| 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 | |
| 249 | private: |
| 250 | Arguments m_arguments; |
| 251 | }; |
| 252 | |
| 253 | class Enumerate { |
| 254 | public: |
| 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 | |
| 270 | private: |
| 271 | Arguments m_arguments; |
| 272 | }; |
| 273 | |
| 274 | class Construct { |
| 275 | public: |
| 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 | |
| 296 | private: |
| 297 | Arguments m_arguments; |
| 298 | }; |
| 299 | |
| 300 | } // namespace NPObjectMessageReceiver |
| 301 | } // namespace Messages |
| 302 | |
| 303 | #endif // ENABLE(NETSCAPE_PLUGIN_API) |
| 304 | |