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 "PluginProxy.h"
30
31#include "ArgumentCoders.h"
32#include "Decoder.h"
33#include "HandleMessage.h"
34#include "NPVariantData.h"
35#include "PluginProxyMessages.h"
36#include "WebCoreArgumentCoders.h"
37#include <WebCore/HTTPHeaderMap.h>
38#include <WebCore/IntRect.h>
39#include <WebCore/ProtectionSpace.h>
40#include <wtf/Vector.h>
41#include <wtf/text/WTFString.h>
42
43namespace Messages {
44
45namespace PluginProxy {
46
47void ProxiesForURL::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, const String& proxiesString)
48{
49 *encoder << proxiesString;
50 connection.sendSyncReply(WTFMove(encoder));
51}
52
53void CookiesForURL::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, const String& cookieString)
54{
55 *encoder << cookieString;
56 connection.sendSyncReply(WTFMove(encoder));
57}
58
59void GetAuthenticationInfo::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool returnValue, const String& username, const String& password)
60{
61 *encoder << returnValue;
62 *encoder << username;
63 *encoder << password;
64 connection.sendSyncReply(WTFMove(encoder));
65}
66
67void GetPluginElementNPObject::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, uint64_t pluginElementNPObjectID)
68{
69 *encoder << pluginElementNPObjectID;
70 connection.sendSyncReply(WTFMove(encoder));
71}
72
73void Evaluate::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool returnValue, const WebKit::NPVariantData& resultData)
74{
75 *encoder << returnValue;
76 *encoder << resultData;
77 connection.sendSyncReply(WTFMove(encoder));
78}
79
80#if PLATFORM(X11)
81
82void CreatePluginContainer::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, uint64_t windowID)
83{
84 *encoder << windowID;
85 connection.sendSyncReply(WTFMove(encoder));
86}
87
88#endif
89
90void DidCreatePlugin::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection)
91{
92 connection.sendSyncReply(WTFMove(encoder));
93}
94
95void DidFailToCreatePlugin::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection)
96{
97 connection.sendSyncReply(WTFMove(encoder));
98}
99
100} // namespace PluginProxy
101
102} // namespace Messages
103
104namespace WebKit {
105
106void PluginProxy::didReceivePluginProxyMessage(IPC::Connection& connection, IPC::Decoder& decoder)
107{
108 if (decoder.messageName() == Messages::PluginProxy::LoadURL::name()) {
109 IPC::handleMessage<Messages::PluginProxy::LoadURL>(decoder, this, &PluginProxy::loadURL);
110 return;
111 }
112 if (decoder.messageName() == Messages::PluginProxy::Update::name()) {
113 IPC::handleMessage<Messages::PluginProxy::Update>(decoder, this, &PluginProxy::update);
114 return;
115 }
116 if (decoder.messageName() == Messages::PluginProxy::SetCookiesForURL::name()) {
117 IPC::handleMessage<Messages::PluginProxy::SetCookiesForURL>(decoder, this, &PluginProxy::setCookiesForURL);
118 return;
119 }
120 if (decoder.messageName() == Messages::PluginProxy::CancelStreamLoad::name()) {
121 IPC::handleMessage<Messages::PluginProxy::CancelStreamLoad>(decoder, this, &PluginProxy::cancelStreamLoad);
122 return;
123 }
124 if (decoder.messageName() == Messages::PluginProxy::ContinueStreamLoad::name()) {
125 IPC::handleMessage<Messages::PluginProxy::ContinueStreamLoad>(decoder, this, &PluginProxy::continueStreamLoad);
126 return;
127 }
128 if (decoder.messageName() == Messages::PluginProxy::CancelManualStreamLoad::name()) {
129 IPC::handleMessage<Messages::PluginProxy::CancelManualStreamLoad>(decoder, this, &PluginProxy::cancelManualStreamLoad);
130 return;
131 }
132 if (decoder.messageName() == Messages::PluginProxy::SetStatusbarText::name()) {
133 IPC::handleMessage<Messages::PluginProxy::SetStatusbarText>(decoder, this, &PluginProxy::setStatusbarText);
134 return;
135 }
136#if PLATFORM(COCOA)
137 if (decoder.messageName() == Messages::PluginProxy::PluginFocusOrWindowFocusChanged::name()) {
138 IPC::handleMessage<Messages::PluginProxy::PluginFocusOrWindowFocusChanged>(decoder, this, &PluginProxy::pluginFocusOrWindowFocusChanged);
139 return;
140 }
141#endif
142#if PLATFORM(COCOA)
143 if (decoder.messageName() == Messages::PluginProxy::SetComplexTextInputState::name()) {
144 IPC::handleMessage<Messages::PluginProxy::SetComplexTextInputState>(decoder, this, &PluginProxy::setComplexTextInputState);
145 return;
146 }
147#endif
148#if PLATFORM(COCOA)
149 if (decoder.messageName() == Messages::PluginProxy::SetLayerHostingContextID::name()) {
150 IPC::handleMessage<Messages::PluginProxy::SetLayerHostingContextID>(decoder, this, &PluginProxy::setLayerHostingContextID);
151 return;
152 }
153#endif
154#if PLATFORM(X11)
155 if (decoder.messageName() == Messages::PluginProxy::WindowedPluginGeometryDidChange::name()) {
156 IPC::handleMessage<Messages::PluginProxy::WindowedPluginGeometryDidChange>(decoder, this, &PluginProxy::windowedPluginGeometryDidChange);
157 return;
158 }
159#endif
160#if PLATFORM(X11)
161 if (decoder.messageName() == Messages::PluginProxy::WindowedPluginVisibilityDidChange::name()) {
162 IPC::handleMessage<Messages::PluginProxy::WindowedPluginVisibilityDidChange>(decoder, this, &PluginProxy::windowedPluginVisibilityDidChange);
163 return;
164 }
165#endif
166 if (decoder.messageName() == Messages::PluginProxy::SetPluginIsPlayingAudio::name()) {
167 IPC::handleMessage<Messages::PluginProxy::SetPluginIsPlayingAudio>(decoder, this, &PluginProxy::setPluginIsPlayingAudio);
168 return;
169 }
170 UNUSED_PARAM(connection);
171 UNUSED_PARAM(decoder);
172 ASSERT_NOT_REACHED();
173}
174
175void PluginProxy::didReceiveSyncPluginProxyMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder)
176{
177 if (decoder.messageName() == Messages::PluginProxy::ProxiesForURL::name()) {
178 IPC::handleMessageSynchronous<Messages::PluginProxy::ProxiesForURL>(connection, decoder, replyEncoder, this, &PluginProxy::proxiesForURL);
179 return;
180 }
181 if (decoder.messageName() == Messages::PluginProxy::CookiesForURL::name()) {
182 IPC::handleMessageSynchronous<Messages::PluginProxy::CookiesForURL>(connection, decoder, replyEncoder, this, &PluginProxy::cookiesForURL);
183 return;
184 }
185 if (decoder.messageName() == Messages::PluginProxy::GetAuthenticationInfo::name()) {
186 IPC::handleMessageSynchronous<Messages::PluginProxy::GetAuthenticationInfo>(connection, decoder, replyEncoder, this, &PluginProxy::getAuthenticationInfo);
187 return;
188 }
189 if (decoder.messageName() == Messages::PluginProxy::GetPluginElementNPObject::name()) {
190 IPC::handleMessageSynchronous<Messages::PluginProxy::GetPluginElementNPObject>(connection, decoder, replyEncoder, this, &PluginProxy::getPluginElementNPObject);
191 return;
192 }
193 if (decoder.messageName() == Messages::PluginProxy::Evaluate::name()) {
194 IPC::handleMessageSynchronous<Messages::PluginProxy::Evaluate>(connection, decoder, replyEncoder, this, &PluginProxy::evaluate);
195 return;
196 }
197#if PLATFORM(X11)
198 if (decoder.messageName() == Messages::PluginProxy::CreatePluginContainer::name()) {
199 IPC::handleMessageSynchronous<Messages::PluginProxy::CreatePluginContainer>(connection, decoder, replyEncoder, this, &PluginProxy::createPluginContainer);
200 return;
201 }
202#endif
203 if (decoder.messageName() == Messages::PluginProxy::DidCreatePlugin::name()) {
204 IPC::handleMessageSynchronous<Messages::PluginProxy::DidCreatePlugin>(connection, decoder, replyEncoder, this, &PluginProxy::didCreatePlugin);
205 return;
206 }
207 if (decoder.messageName() == Messages::PluginProxy::DidFailToCreatePlugin::name()) {
208 IPC::handleMessageSynchronous<Messages::PluginProxy::DidFailToCreatePlugin>(connection, decoder, replyEncoder, this, &PluginProxy::didFailToCreatePlugin);
209 return;
210 }
211 UNUSED_PARAM(connection);
212 UNUSED_PARAM(decoder);
213 UNUSED_PARAM(replyEncoder);
214 ASSERT_NOT_REACHED();
215}
216
217} // namespace WebKit
218
219
220#endif // ENABLE(NETSCAPE_PLUGIN_API)
221