| 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 | #include "config.h" |
| 26 | |
| 27 | #if ENABLE(NETSCAPE_PLUGIN_API) |
| 28 | |
| 29 | #include "NPObjectMessageReceiver.h" |
| 30 | |
| 31 | #include "ArgumentCoders.h" |
| 32 | #include "Decoder.h" |
| 33 | #include "HandleMessage.h" |
| 34 | #include "NPIdentifierData.h" |
| 35 | #include "NPObjectMessageReceiverMessages.h" |
| 36 | #include "NPVariantData.h" |
| 37 | #include <wtf/Vector.h> |
| 38 | |
| 39 | namespace Messages { |
| 40 | |
| 41 | namespace NPObjectMessageReceiver { |
| 42 | |
| 43 | void Deallocate::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection) |
| 44 | { |
| 45 | connection.sendSyncReply(WTFMove(encoder)); |
| 46 | } |
| 47 | |
| 48 | void HasMethod::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool returnValue) |
| 49 | { |
| 50 | *encoder << returnValue; |
| 51 | connection.sendSyncReply(WTFMove(encoder)); |
| 52 | } |
| 53 | |
| 54 | void Invoke::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool returnValue, const WebKit::NPVariantData& resultData) |
| 55 | { |
| 56 | *encoder << returnValue; |
| 57 | *encoder << resultData; |
| 58 | connection.sendSyncReply(WTFMove(encoder)); |
| 59 | } |
| 60 | |
| 61 | void InvokeDefault::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool returnValue, const WebKit::NPVariantData& resultData) |
| 62 | { |
| 63 | *encoder << returnValue; |
| 64 | *encoder << resultData; |
| 65 | connection.sendSyncReply(WTFMove(encoder)); |
| 66 | } |
| 67 | |
| 68 | void HasProperty::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool returnValue) |
| 69 | { |
| 70 | *encoder << returnValue; |
| 71 | connection.sendSyncReply(WTFMove(encoder)); |
| 72 | } |
| 73 | |
| 74 | void GetProperty::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool returnValue, const WebKit::NPVariantData& resultData) |
| 75 | { |
| 76 | *encoder << returnValue; |
| 77 | *encoder << resultData; |
| 78 | connection.sendSyncReply(WTFMove(encoder)); |
| 79 | } |
| 80 | |
| 81 | void SetProperty::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool returnValue) |
| 82 | { |
| 83 | *encoder << returnValue; |
| 84 | connection.sendSyncReply(WTFMove(encoder)); |
| 85 | } |
| 86 | |
| 87 | void RemoveProperty::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool returnValue) |
| 88 | { |
| 89 | *encoder << returnValue; |
| 90 | connection.sendSyncReply(WTFMove(encoder)); |
| 91 | } |
| 92 | |
| 93 | void Enumerate::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool returnValue, const Vector<WebKit::NPIdentifierData>& identifiersData) |
| 94 | { |
| 95 | *encoder << returnValue; |
| 96 | *encoder << identifiersData; |
| 97 | connection.sendSyncReply(WTFMove(encoder)); |
| 98 | } |
| 99 | |
| 100 | void Construct::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool returnValue, const WebKit::NPVariantData& resultData) |
| 101 | { |
| 102 | *encoder << returnValue; |
| 103 | *encoder << resultData; |
| 104 | connection.sendSyncReply(WTFMove(encoder)); |
| 105 | } |
| 106 | |
| 107 | } // namespace NPObjectMessageReceiver |
| 108 | |
| 109 | } // namespace Messages |
| 110 | |
| 111 | namespace WebKit { |
| 112 | |
| 113 | |
| 114 | void NPObjectMessageReceiver::didReceiveSyncNPObjectMessageReceiverMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder) |
| 115 | { |
| 116 | if (decoder.messageName() == Messages::NPObjectMessageReceiver::Deallocate::name()) { |
| 117 | IPC::handleMessageSynchronous<Messages::NPObjectMessageReceiver::Deallocate>(connection, decoder, replyEncoder, this, &NPObjectMessageReceiver::deallocate); |
| 118 | return; |
| 119 | } |
| 120 | if (decoder.messageName() == Messages::NPObjectMessageReceiver::HasMethod::name()) { |
| 121 | IPC::handleMessageSynchronous<Messages::NPObjectMessageReceiver::HasMethod>(connection, decoder, replyEncoder, this, &NPObjectMessageReceiver::hasMethod); |
| 122 | return; |
| 123 | } |
| 124 | if (decoder.messageName() == Messages::NPObjectMessageReceiver::Invoke::name()) { |
| 125 | IPC::handleMessageSynchronous<Messages::NPObjectMessageReceiver::Invoke>(connection, decoder, replyEncoder, this, &NPObjectMessageReceiver::invoke); |
| 126 | return; |
| 127 | } |
| 128 | if (decoder.messageName() == Messages::NPObjectMessageReceiver::InvokeDefault::name()) { |
| 129 | IPC::handleMessageSynchronous<Messages::NPObjectMessageReceiver::InvokeDefault>(connection, decoder, replyEncoder, this, &NPObjectMessageReceiver::invokeDefault); |
| 130 | return; |
| 131 | } |
| 132 | if (decoder.messageName() == Messages::NPObjectMessageReceiver::HasProperty::name()) { |
| 133 | IPC::handleMessageSynchronous<Messages::NPObjectMessageReceiver::HasProperty>(connection, decoder, replyEncoder, this, &NPObjectMessageReceiver::hasProperty); |
| 134 | return; |
| 135 | } |
| 136 | if (decoder.messageName() == Messages::NPObjectMessageReceiver::GetProperty::name()) { |
| 137 | IPC::handleMessageSynchronous<Messages::NPObjectMessageReceiver::GetProperty>(connection, decoder, replyEncoder, this, &NPObjectMessageReceiver::getProperty); |
| 138 | return; |
| 139 | } |
| 140 | if (decoder.messageName() == Messages::NPObjectMessageReceiver::SetProperty::name()) { |
| 141 | IPC::handleMessageSynchronous<Messages::NPObjectMessageReceiver::SetProperty>(connection, decoder, replyEncoder, this, &NPObjectMessageReceiver::setProperty); |
| 142 | return; |
| 143 | } |
| 144 | if (decoder.messageName() == Messages::NPObjectMessageReceiver::RemoveProperty::name()) { |
| 145 | IPC::handleMessageSynchronous<Messages::NPObjectMessageReceiver::RemoveProperty>(connection, decoder, replyEncoder, this, &NPObjectMessageReceiver::removeProperty); |
| 146 | return; |
| 147 | } |
| 148 | if (decoder.messageName() == Messages::NPObjectMessageReceiver::Enumerate::name()) { |
| 149 | IPC::handleMessageSynchronous<Messages::NPObjectMessageReceiver::Enumerate>(connection, decoder, replyEncoder, this, &NPObjectMessageReceiver::enumerate); |
| 150 | return; |
| 151 | } |
| 152 | if (decoder.messageName() == Messages::NPObjectMessageReceiver::Construct::name()) { |
| 153 | IPC::handleMessageSynchronous<Messages::NPObjectMessageReceiver::Construct>(connection, decoder, replyEncoder, this, &NPObjectMessageReceiver::construct); |
| 154 | return; |
| 155 | } |
| 156 | UNUSED_PARAM(connection); |
| 157 | UNUSED_PARAM(decoder); |
| 158 | UNUSED_PARAM(replyEncoder); |
| 159 | ASSERT_NOT_REACHED(); |
| 160 | } |
| 161 | |
| 162 | } // namespace WebKit |
| 163 | |
| 164 | |
| 165 | #endif // ENABLE(NETSCAPE_PLUGIN_API) |
| 166 | |