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 "PluginControllerProxy.h" |
30 | |
31 | #include "ArgumentCoders.h" |
32 | #include "DataReference.h" |
33 | #include "Decoder.h" |
34 | #include "HandleMessage.h" |
35 | #include "PluginControllerProxyMessages.h" |
36 | #include "ShareableBitmap.h" |
37 | #include "WebCoreArgumentCoders.h" |
38 | #include "WebEvent.h" |
39 | #include <WebCore/AffineTransform.h> |
40 | #include <WebCore/IntRect.h> |
41 | #include <WebCore/IntSize.h> |
42 | #include <wtf/text/WTFString.h> |
43 | |
44 | namespace Messages { |
45 | |
46 | namespace PluginControllerProxy { |
47 | |
48 | void HandleWheelEvent::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool handled) |
49 | { |
50 | *encoder << handled; |
51 | connection.sendSyncReply(WTFMove(encoder)); |
52 | } |
53 | |
54 | void HandleMouseEnterEvent::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool handled) |
55 | { |
56 | *encoder << handled; |
57 | connection.sendSyncReply(WTFMove(encoder)); |
58 | } |
59 | |
60 | void HandleMouseLeaveEvent::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool handled) |
61 | { |
62 | *encoder << handled; |
63 | connection.sendSyncReply(WTFMove(encoder)); |
64 | } |
65 | |
66 | void HandleKeyboardEvent::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool handled) |
67 | { |
68 | *encoder << handled; |
69 | connection.sendSyncReply(WTFMove(encoder)); |
70 | } |
71 | |
72 | void HandleEditingCommand::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool handled) |
73 | { |
74 | *encoder << handled; |
75 | connection.sendSyncReply(WTFMove(encoder)); |
76 | } |
77 | |
78 | void IsEditingCommandEnabled::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool enabled) |
79 | { |
80 | *encoder << enabled; |
81 | connection.sendSyncReply(WTFMove(encoder)); |
82 | } |
83 | |
84 | void HandlesPageScaleFactor::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool enabled) |
85 | { |
86 | *encoder << enabled; |
87 | connection.sendSyncReply(WTFMove(encoder)); |
88 | } |
89 | |
90 | void RequiresUnifiedScaleFactor::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool required) |
91 | { |
92 | *encoder << required; |
93 | connection.sendSyncReply(WTFMove(encoder)); |
94 | } |
95 | |
96 | void PaintEntirePlugin::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection) |
97 | { |
98 | connection.sendSyncReply(WTFMove(encoder)); |
99 | } |
100 | |
101 | void GetPluginScriptableNPObject::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, uint64_t pluginScriptableNPObjectID) |
102 | { |
103 | *encoder << pluginScriptableNPObjectID; |
104 | connection.sendSyncReply(WTFMove(encoder)); |
105 | } |
106 | |
107 | void SupportsSnapshotting::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool isSupported) |
108 | { |
109 | *encoder << isSupported; |
110 | connection.sendSyncReply(WTFMove(encoder)); |
111 | } |
112 | |
113 | void Snapshot::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, const WebKit::ShareableBitmap::Handle& backingStoreHandle) |
114 | { |
115 | *encoder << backingStoreHandle; |
116 | connection.sendSyncReply(WTFMove(encoder)); |
117 | } |
118 | |
119 | void GetFormValue::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool returnValue, const String& formValue) |
120 | { |
121 | *encoder << returnValue; |
122 | *encoder << formValue; |
123 | connection.sendSyncReply(WTFMove(encoder)); |
124 | } |
125 | |
126 | } // namespace PluginControllerProxy |
127 | |
128 | } // namespace Messages |
129 | |
130 | namespace WebKit { |
131 | |
132 | void PluginControllerProxy::didReceivePluginControllerProxyMessage(IPC::Connection& connection, IPC::Decoder& decoder) |
133 | { |
134 | if (decoder.messageName() == Messages::PluginControllerProxy::GeometryDidChange::name()) { |
135 | IPC::handleMessage<Messages::PluginControllerProxy::GeometryDidChange>(decoder, this, &PluginControllerProxy::geometryDidChange); |
136 | return; |
137 | } |
138 | if (decoder.messageName() == Messages::PluginControllerProxy::VisibilityDidChange::name()) { |
139 | IPC::handleMessage<Messages::PluginControllerProxy::VisibilityDidChange>(decoder, this, &PluginControllerProxy::visibilityDidChange); |
140 | return; |
141 | } |
142 | if (decoder.messageName() == Messages::PluginControllerProxy::FrameDidFinishLoading::name()) { |
143 | IPC::handleMessage<Messages::PluginControllerProxy::FrameDidFinishLoading>(decoder, this, &PluginControllerProxy::frameDidFinishLoading); |
144 | return; |
145 | } |
146 | if (decoder.messageName() == Messages::PluginControllerProxy::FrameDidFail::name()) { |
147 | IPC::handleMessage<Messages::PluginControllerProxy::FrameDidFail>(decoder, this, &PluginControllerProxy::frameDidFail); |
148 | return; |
149 | } |
150 | if (decoder.messageName() == Messages::PluginControllerProxy::DidEvaluateJavaScript::name()) { |
151 | IPC::handleMessage<Messages::PluginControllerProxy::DidEvaluateJavaScript>(decoder, this, &PluginControllerProxy::didEvaluateJavaScript); |
152 | return; |
153 | } |
154 | if (decoder.messageName() == Messages::PluginControllerProxy::StreamWillSendRequest::name()) { |
155 | IPC::handleMessage<Messages::PluginControllerProxy::StreamWillSendRequest>(decoder, this, &PluginControllerProxy::streamWillSendRequest); |
156 | return; |
157 | } |
158 | if (decoder.messageName() == Messages::PluginControllerProxy::StreamDidReceiveResponse::name()) { |
159 | IPC::handleMessage<Messages::PluginControllerProxy::StreamDidReceiveResponse>(decoder, this, &PluginControllerProxy::streamDidReceiveResponse); |
160 | return; |
161 | } |
162 | if (decoder.messageName() == Messages::PluginControllerProxy::StreamDidReceiveData::name()) { |
163 | IPC::handleMessage<Messages::PluginControllerProxy::StreamDidReceiveData>(decoder, this, &PluginControllerProxy::streamDidReceiveData); |
164 | return; |
165 | } |
166 | if (decoder.messageName() == Messages::PluginControllerProxy::StreamDidFinishLoading::name()) { |
167 | IPC::handleMessage<Messages::PluginControllerProxy::StreamDidFinishLoading>(decoder, this, &PluginControllerProxy::streamDidFinishLoading); |
168 | return; |
169 | } |
170 | if (decoder.messageName() == Messages::PluginControllerProxy::StreamDidFail::name()) { |
171 | IPC::handleMessage<Messages::PluginControllerProxy::StreamDidFail>(decoder, this, &PluginControllerProxy::streamDidFail); |
172 | return; |
173 | } |
174 | if (decoder.messageName() == Messages::PluginControllerProxy::ManualStreamDidReceiveResponse::name()) { |
175 | IPC::handleMessage<Messages::PluginControllerProxy::ManualStreamDidReceiveResponse>(decoder, this, &PluginControllerProxy::manualStreamDidReceiveResponse); |
176 | return; |
177 | } |
178 | if (decoder.messageName() == Messages::PluginControllerProxy::ManualStreamDidReceiveData::name()) { |
179 | IPC::handleMessage<Messages::PluginControllerProxy::ManualStreamDidReceiveData>(decoder, this, &PluginControllerProxy::manualStreamDidReceiveData); |
180 | return; |
181 | } |
182 | if (decoder.messageName() == Messages::PluginControllerProxy::ManualStreamDidFinishLoading::name()) { |
183 | IPC::handleMessage<Messages::PluginControllerProxy::ManualStreamDidFinishLoading>(decoder, this, &PluginControllerProxy::manualStreamDidFinishLoading); |
184 | return; |
185 | } |
186 | if (decoder.messageName() == Messages::PluginControllerProxy::ManualStreamDidFail::name()) { |
187 | IPC::handleMessage<Messages::PluginControllerProxy::ManualStreamDidFail>(decoder, this, &PluginControllerProxy::manualStreamDidFail); |
188 | return; |
189 | } |
190 | if (decoder.messageName() == Messages::PluginControllerProxy::HandleMouseEvent::name()) { |
191 | IPC::handleMessage<Messages::PluginControllerProxy::HandleMouseEvent>(decoder, this, &PluginControllerProxy::handleMouseEvent); |
192 | return; |
193 | } |
194 | if (decoder.messageName() == Messages::PluginControllerProxy::SetFocus::name()) { |
195 | IPC::handleMessage<Messages::PluginControllerProxy::SetFocus>(decoder, this, &PluginControllerProxy::setFocus); |
196 | return; |
197 | } |
198 | if (decoder.messageName() == Messages::PluginControllerProxy::DidUpdate::name()) { |
199 | IPC::handleMessage<Messages::PluginControllerProxy::DidUpdate>(decoder, this, &PluginControllerProxy::didUpdate); |
200 | return; |
201 | } |
202 | if (decoder.messageName() == Messages::PluginControllerProxy::WindowFocusChanged::name()) { |
203 | IPC::handleMessage<Messages::PluginControllerProxy::WindowFocusChanged>(decoder, this, &PluginControllerProxy::windowFocusChanged); |
204 | return; |
205 | } |
206 | if (decoder.messageName() == Messages::PluginControllerProxy::WindowVisibilityChanged::name()) { |
207 | IPC::handleMessage<Messages::PluginControllerProxy::WindowVisibilityChanged>(decoder, this, &PluginControllerProxy::windowVisibilityChanged); |
208 | return; |
209 | } |
210 | #if PLATFORM(COCOA) |
211 | if (decoder.messageName() == Messages::PluginControllerProxy::SendComplexTextInput::name()) { |
212 | IPC::handleMessage<Messages::PluginControllerProxy::SendComplexTextInput>(decoder, this, &PluginControllerProxy::sendComplexTextInput); |
213 | return; |
214 | } |
215 | #endif |
216 | #if PLATFORM(COCOA) |
217 | if (decoder.messageName() == Messages::PluginControllerProxy::WindowAndViewFramesChanged::name()) { |
218 | IPC::handleMessage<Messages::PluginControllerProxy::WindowAndViewFramesChanged>(decoder, this, &PluginControllerProxy::windowAndViewFramesChanged); |
219 | return; |
220 | } |
221 | #endif |
222 | #if PLATFORM(COCOA) |
223 | if (decoder.messageName() == Messages::PluginControllerProxy::SetLayerHostingMode::name()) { |
224 | IPC::handleMessage<Messages::PluginControllerProxy::SetLayerHostingMode>(decoder, this, &PluginControllerProxy::setLayerHostingMode); |
225 | return; |
226 | } |
227 | #endif |
228 | if (decoder.messageName() == Messages::PluginControllerProxy::StorageBlockingStateChanged::name()) { |
229 | IPC::handleMessage<Messages::PluginControllerProxy::StorageBlockingStateChanged>(decoder, this, &PluginControllerProxy::storageBlockingStateChanged); |
230 | return; |
231 | } |
232 | if (decoder.messageName() == Messages::PluginControllerProxy::PrivateBrowsingStateChanged::name()) { |
233 | IPC::handleMessage<Messages::PluginControllerProxy::PrivateBrowsingStateChanged>(decoder, this, &PluginControllerProxy::privateBrowsingStateChanged); |
234 | return; |
235 | } |
236 | if (decoder.messageName() == Messages::PluginControllerProxy::MutedStateChanged::name()) { |
237 | IPC::handleMessage<Messages::PluginControllerProxy::MutedStateChanged>(decoder, this, &PluginControllerProxy::mutedStateChanged); |
238 | return; |
239 | } |
240 | UNUSED_PARAM(connection); |
241 | UNUSED_PARAM(decoder); |
242 | ASSERT_NOT_REACHED(); |
243 | } |
244 | |
245 | void PluginControllerProxy::didReceiveSyncPluginControllerProxyMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder) |
246 | { |
247 | if (decoder.messageName() == Messages::PluginControllerProxy::HandleWheelEvent::name()) { |
248 | IPC::handleMessageSynchronous<Messages::PluginControllerProxy::HandleWheelEvent>(connection, decoder, replyEncoder, this, &PluginControllerProxy::handleWheelEvent); |
249 | return; |
250 | } |
251 | if (decoder.messageName() == Messages::PluginControllerProxy::HandleMouseEnterEvent::name()) { |
252 | IPC::handleMessageSynchronous<Messages::PluginControllerProxy::HandleMouseEnterEvent>(connection, decoder, replyEncoder, this, &PluginControllerProxy::handleMouseEnterEvent); |
253 | return; |
254 | } |
255 | if (decoder.messageName() == Messages::PluginControllerProxy::HandleMouseLeaveEvent::name()) { |
256 | IPC::handleMessageSynchronous<Messages::PluginControllerProxy::HandleMouseLeaveEvent>(connection, decoder, replyEncoder, this, &PluginControllerProxy::handleMouseLeaveEvent); |
257 | return; |
258 | } |
259 | if (decoder.messageName() == Messages::PluginControllerProxy::HandleKeyboardEvent::name()) { |
260 | IPC::handleMessageSynchronous<Messages::PluginControllerProxy::HandleKeyboardEvent>(connection, decoder, replyEncoder, this, &PluginControllerProxy::handleKeyboardEvent); |
261 | return; |
262 | } |
263 | if (decoder.messageName() == Messages::PluginControllerProxy::HandleEditingCommand::name()) { |
264 | IPC::handleMessageSynchronous<Messages::PluginControllerProxy::HandleEditingCommand>(connection, decoder, replyEncoder, this, &PluginControllerProxy::handleEditingCommand); |
265 | return; |
266 | } |
267 | if (decoder.messageName() == Messages::PluginControllerProxy::IsEditingCommandEnabled::name()) { |
268 | IPC::handleMessageSynchronous<Messages::PluginControllerProxy::IsEditingCommandEnabled>(connection, decoder, replyEncoder, this, &PluginControllerProxy::isEditingCommandEnabled); |
269 | return; |
270 | } |
271 | if (decoder.messageName() == Messages::PluginControllerProxy::HandlesPageScaleFactor::name()) { |
272 | IPC::handleMessageSynchronous<Messages::PluginControllerProxy::HandlesPageScaleFactor>(connection, decoder, replyEncoder, this, &PluginControllerProxy::handlesPageScaleFactor); |
273 | return; |
274 | } |
275 | if (decoder.messageName() == Messages::PluginControllerProxy::RequiresUnifiedScaleFactor::name()) { |
276 | IPC::handleMessageSynchronous<Messages::PluginControllerProxy::RequiresUnifiedScaleFactor>(connection, decoder, replyEncoder, this, &PluginControllerProxy::requiresUnifiedScaleFactor); |
277 | return; |
278 | } |
279 | if (decoder.messageName() == Messages::PluginControllerProxy::PaintEntirePlugin::name()) { |
280 | IPC::handleMessageSynchronous<Messages::PluginControllerProxy::PaintEntirePlugin>(connection, decoder, replyEncoder, this, &PluginControllerProxy::paintEntirePlugin); |
281 | return; |
282 | } |
283 | if (decoder.messageName() == Messages::PluginControllerProxy::GetPluginScriptableNPObject::name()) { |
284 | IPC::handleMessageSynchronous<Messages::PluginControllerProxy::GetPluginScriptableNPObject>(connection, decoder, replyEncoder, this, &PluginControllerProxy::getPluginScriptableNPObject); |
285 | return; |
286 | } |
287 | if (decoder.messageName() == Messages::PluginControllerProxy::SupportsSnapshotting::name()) { |
288 | IPC::handleMessageSynchronous<Messages::PluginControllerProxy::SupportsSnapshotting>(connection, decoder, replyEncoder, this, &PluginControllerProxy::supportsSnapshotting); |
289 | return; |
290 | } |
291 | if (decoder.messageName() == Messages::PluginControllerProxy::Snapshot::name()) { |
292 | IPC::handleMessageSynchronous<Messages::PluginControllerProxy::Snapshot>(connection, decoder, replyEncoder, this, &PluginControllerProxy::snapshot); |
293 | return; |
294 | } |
295 | if (decoder.messageName() == Messages::PluginControllerProxy::GetFormValue::name()) { |
296 | IPC::handleMessageSynchronous<Messages::PluginControllerProxy::GetFormValue>(connection, decoder, replyEncoder, this, &PluginControllerProxy::getFormValue); |
297 | return; |
298 | } |
299 | UNUSED_PARAM(connection); |
300 | UNUSED_PARAM(decoder); |
301 | UNUSED_PARAM(replyEncoder); |
302 | ASSERT_NOT_REACHED(); |
303 | } |
304 | |
305 | } // namespace WebKit |
306 | |
307 | |
308 | #endif // ENABLE(NETSCAPE_PLUGIN_API) |
309 | |