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 | #include "WebProcessProxy.h" |
28 | |
29 | #if PLATFORM(COCOA) || ENABLE(NETSCAPE_PLUGIN_API) |
30 | #include "ArgumentCoders.h" |
31 | #endif |
32 | #include "Attachment.h" |
33 | #include "Decoder.h" |
34 | #include "HandleMessage.h" |
35 | #if HAVE(VISIBILITY_PROPAGATION_VIEW) |
36 | #include "LayerHostingContext.h" |
37 | #endif |
38 | #include "SessionState.h" |
39 | #include "WebCoreArgumentCoders.h" |
40 | #include "WebProcessProxyMessages.h" |
41 | #include <WebCore/MessagePortIdentifier.h> |
42 | #include <WebCore/MessageWithMessagePorts.h> |
43 | #if ENABLE(NETSCAPE_PLUGIN_API) |
44 | #include <WebCore/PluginData.h> |
45 | #endif |
46 | #include <WebCore/PrewarmInformation.h> |
47 | #include <WebCore/RegistrableDomain.h> |
48 | #if ENABLE(NETSCAPE_PLUGIN_API) |
49 | #include <wtf/Optional.h> |
50 | #endif |
51 | #if PLATFORM(COCOA) || ENABLE(NETSCAPE_PLUGIN_API) |
52 | #include <wtf/Vector.h> |
53 | #endif |
54 | #if PLATFORM(COCOA) |
55 | #include <wtf/text/WTFString.h> |
56 | #endif |
57 | |
58 | namespace Messages { |
59 | |
60 | namespace WebProcessProxy { |
61 | |
62 | void ShouldTerminate::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool shouldTerminate) |
63 | { |
64 | *encoder << shouldTerminate; |
65 | connection.sendSyncReply(WTFMove(encoder)); |
66 | } |
67 | |
68 | #if ENABLE(NETSCAPE_PLUGIN_API) |
69 | |
70 | void GetPlugins::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, const Vector<WebCore::PluginInfo>& plugins, const Vector<WebCore::PluginInfo>& applicationPlugins, const Optional<Vector<WebCore::SupportedPluginIdentifier>>& supportedPluginIdentifiers) |
71 | { |
72 | *encoder << plugins; |
73 | *encoder << applicationPlugins; |
74 | *encoder << supportedPluginIdentifiers; |
75 | connection.sendSyncReply(WTFMove(encoder)); |
76 | } |
77 | |
78 | #endif |
79 | |
80 | #if ENABLE(NETSCAPE_PLUGIN_API) |
81 | |
82 | void GetPluginProcessConnection::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, const IPC::Attachment& connectionHandle, bool supportsAsynchronousInitialization) |
83 | { |
84 | *encoder << connectionHandle; |
85 | *encoder << supportsAsynchronousInitialization; |
86 | connection.sendSyncReply(WTFMove(encoder)); |
87 | } |
88 | |
89 | #endif |
90 | |
91 | void GetNetworkProcessConnection::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, const IPC::Attachment& connectionHandle) |
92 | { |
93 | *encoder << connectionHandle; |
94 | connection.sendSyncReply(WTFMove(encoder)); |
95 | } |
96 | |
97 | #if PLATFORM(IOS_FAMILY) |
98 | |
99 | void ProcessWasUnexpectedlyUnsuspended::callReply(IPC::Decoder& decoder, CompletionHandler<void()>&& completionHandler) |
100 | { |
101 | completionHandler(); |
102 | } |
103 | |
104 | void ProcessWasUnexpectedlyUnsuspended::cancelReply(CompletionHandler<void()>&& completionHandler) |
105 | { |
106 | completionHandler(); |
107 | } |
108 | |
109 | void ProcessWasUnexpectedlyUnsuspended::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection) |
110 | { |
111 | connection.sendSyncReply(WTFMove(encoder)); |
112 | } |
113 | |
114 | #endif |
115 | |
116 | } // namespace WebProcessProxy |
117 | |
118 | } // namespace Messages |
119 | |
120 | namespace WebKit { |
121 | |
122 | void WebProcessProxy::didReceiveWebProcessProxyMessage(IPC::Connection& connection, IPC::Decoder& decoder) |
123 | { |
124 | if (decoder.messageName() == Messages::WebProcessProxy::UpdateBackForwardItem::name()) { |
125 | IPC::handleMessage<Messages::WebProcessProxy::UpdateBackForwardItem>(decoder, this, &WebProcessProxy::updateBackForwardItem); |
126 | return; |
127 | } |
128 | if (decoder.messageName() == Messages::WebProcessProxy::DidDestroyFrame::name()) { |
129 | IPC::handleMessage<Messages::WebProcessProxy::DidDestroyFrame>(decoder, this, &WebProcessProxy::didDestroyFrame); |
130 | return; |
131 | } |
132 | if (decoder.messageName() == Messages::WebProcessProxy::DidDestroyUserGestureToken::name()) { |
133 | IPC::handleMessage<Messages::WebProcessProxy::DidDestroyUserGestureToken>(decoder, this, &WebProcessProxy::didDestroyUserGestureToken); |
134 | return; |
135 | } |
136 | if (decoder.messageName() == Messages::WebProcessProxy::EnableSuddenTermination::name()) { |
137 | IPC::handleMessage<Messages::WebProcessProxy::EnableSuddenTermination>(decoder, this, &WebProcessProxy::enableSuddenTermination); |
138 | return; |
139 | } |
140 | if (decoder.messageName() == Messages::WebProcessProxy::DisableSuddenTermination::name()) { |
141 | IPC::handleMessage<Messages::WebProcessProxy::DisableSuddenTermination>(decoder, this, &WebProcessProxy::disableSuddenTermination); |
142 | return; |
143 | } |
144 | if (decoder.messageName() == Messages::WebProcessProxy::ProcessReadyToSuspend::name()) { |
145 | IPC::handleMessage<Messages::WebProcessProxy::ProcessReadyToSuspend>(decoder, this, &WebProcessProxy::processReadyToSuspend); |
146 | return; |
147 | } |
148 | if (decoder.messageName() == Messages::WebProcessProxy::DidCancelProcessSuspension::name()) { |
149 | IPC::handleMessage<Messages::WebProcessProxy::DidCancelProcessSuspension>(decoder, this, &WebProcessProxy::didCancelProcessSuspension); |
150 | return; |
151 | } |
152 | if (decoder.messageName() == Messages::WebProcessProxy::SetIsHoldingLockedFiles::name()) { |
153 | IPC::handleMessage<Messages::WebProcessProxy::SetIsHoldingLockedFiles>(decoder, this, &WebProcessProxy::setIsHoldingLockedFiles); |
154 | return; |
155 | } |
156 | if (decoder.messageName() == Messages::WebProcessProxy::DidExceedActiveMemoryLimit::name()) { |
157 | IPC::handleMessage<Messages::WebProcessProxy::DidExceedActiveMemoryLimit>(decoder, this, &WebProcessProxy::didExceedActiveMemoryLimit); |
158 | return; |
159 | } |
160 | if (decoder.messageName() == Messages::WebProcessProxy::DidExceedInactiveMemoryLimit::name()) { |
161 | IPC::handleMessage<Messages::WebProcessProxy::DidExceedInactiveMemoryLimit>(decoder, this, &WebProcessProxy::didExceedInactiveMemoryLimit); |
162 | return; |
163 | } |
164 | if (decoder.messageName() == Messages::WebProcessProxy::DidExceedCPULimit::name()) { |
165 | IPC::handleMessage<Messages::WebProcessProxy::DidExceedCPULimit>(decoder, this, &WebProcessProxy::didExceedCPULimit); |
166 | return; |
167 | } |
168 | if (decoder.messageName() == Messages::WebProcessProxy::StopResponsivenessTimer::name()) { |
169 | IPC::handleMessage<Messages::WebProcessProxy::StopResponsivenessTimer>(decoder, this, &WebProcessProxy::stopResponsivenessTimer); |
170 | return; |
171 | } |
172 | if (decoder.messageName() == Messages::WebProcessProxy::DidReceiveMainThreadPing::name()) { |
173 | IPC::handleMessage<Messages::WebProcessProxy::DidReceiveMainThreadPing>(decoder, this, &WebProcessProxy::didReceiveMainThreadPing); |
174 | return; |
175 | } |
176 | if (decoder.messageName() == Messages::WebProcessProxy::DidReceiveBackgroundResponsivenessPing::name()) { |
177 | IPC::handleMessage<Messages::WebProcessProxy::DidReceiveBackgroundResponsivenessPing>(decoder, this, &WebProcessProxy::didReceiveBackgroundResponsivenessPing); |
178 | return; |
179 | } |
180 | if (decoder.messageName() == Messages::WebProcessProxy::MemoryPressureStatusChanged::name()) { |
181 | IPC::handleMessage<Messages::WebProcessProxy::MemoryPressureStatusChanged>(decoder, this, &WebProcessProxy::memoryPressureStatusChanged); |
182 | return; |
183 | } |
184 | if (decoder.messageName() == Messages::WebProcessProxy::DidExceedInactiveMemoryLimitWhileActive::name()) { |
185 | IPC::handleMessage<Messages::WebProcessProxy::DidExceedInactiveMemoryLimitWhileActive>(decoder, this, &WebProcessProxy::didExceedInactiveMemoryLimitWhileActive); |
186 | return; |
187 | } |
188 | if (decoder.messageName() == Messages::WebProcessProxy::CreateNewMessagePortChannel::name()) { |
189 | IPC::handleMessage<Messages::WebProcessProxy::CreateNewMessagePortChannel>(decoder, this, &WebProcessProxy::createNewMessagePortChannel); |
190 | return; |
191 | } |
192 | if (decoder.messageName() == Messages::WebProcessProxy::EntangleLocalPortInThisProcessToRemote::name()) { |
193 | IPC::handleMessage<Messages::WebProcessProxy::EntangleLocalPortInThisProcessToRemote>(decoder, this, &WebProcessProxy::entangleLocalPortInThisProcessToRemote); |
194 | return; |
195 | } |
196 | if (decoder.messageName() == Messages::WebProcessProxy::MessagePortDisentangled::name()) { |
197 | IPC::handleMessage<Messages::WebProcessProxy::MessagePortDisentangled>(decoder, this, &WebProcessProxy::messagePortDisentangled); |
198 | return; |
199 | } |
200 | if (decoder.messageName() == Messages::WebProcessProxy::MessagePortClosed::name()) { |
201 | IPC::handleMessage<Messages::WebProcessProxy::MessagePortClosed>(decoder, this, &WebProcessProxy::messagePortClosed); |
202 | return; |
203 | } |
204 | if (decoder.messageName() == Messages::WebProcessProxy::TakeAllMessagesForPort::name()) { |
205 | IPC::handleMessage<Messages::WebProcessProxy::TakeAllMessagesForPort>(decoder, this, &WebProcessProxy::takeAllMessagesForPort); |
206 | return; |
207 | } |
208 | if (decoder.messageName() == Messages::WebProcessProxy::PostMessageToRemote::name()) { |
209 | IPC::handleMessage<Messages::WebProcessProxy::PostMessageToRemote>(decoder, this, &WebProcessProxy::postMessageToRemote); |
210 | return; |
211 | } |
212 | if (decoder.messageName() == Messages::WebProcessProxy::CheckRemotePortForActivity::name()) { |
213 | IPC::handleMessage<Messages::WebProcessProxy::CheckRemotePortForActivity>(decoder, this, &WebProcessProxy::checkRemotePortForActivity); |
214 | return; |
215 | } |
216 | if (decoder.messageName() == Messages::WebProcessProxy::DidDeliverMessagePortMessages::name()) { |
217 | IPC::handleMessage<Messages::WebProcessProxy::DidDeliverMessagePortMessages>(decoder, this, &WebProcessProxy::didDeliverMessagePortMessages); |
218 | return; |
219 | } |
220 | if (decoder.messageName() == Messages::WebProcessProxy::DidCheckProcessLocalPortForActivity::name()) { |
221 | IPC::handleMessage<Messages::WebProcessProxy::DidCheckProcessLocalPortForActivity>(decoder, this, &WebProcessProxy::didCheckProcessLocalPortForActivity); |
222 | return; |
223 | } |
224 | if (decoder.messageName() == Messages::WebProcessProxy::DidCollectPrewarmInformation::name()) { |
225 | IPC::handleMessage<Messages::WebProcessProxy::DidCollectPrewarmInformation>(decoder, this, &WebProcessProxy::didCollectPrewarmInformation); |
226 | return; |
227 | } |
228 | #if PLATFORM(COCOA) |
229 | if (decoder.messageName() == Messages::WebProcessProxy::CacheMediaMIMETypes::name()) { |
230 | IPC::handleMessage<Messages::WebProcessProxy::CacheMediaMIMETypes>(decoder, this, &WebProcessProxy::cacheMediaMIMETypes); |
231 | return; |
232 | } |
233 | #endif |
234 | #if PLATFORM(MAC) |
235 | if (decoder.messageName() == Messages::WebProcessProxy::RequestHighPerformanceGPU::name()) { |
236 | IPC::handleMessage<Messages::WebProcessProxy::RequestHighPerformanceGPU>(decoder, this, &WebProcessProxy::requestHighPerformanceGPU); |
237 | return; |
238 | } |
239 | #endif |
240 | #if PLATFORM(MAC) |
241 | if (decoder.messageName() == Messages::WebProcessProxy::ReleaseHighPerformanceGPU::name()) { |
242 | IPC::handleMessage<Messages::WebProcessProxy::ReleaseHighPerformanceGPU>(decoder, this, &WebProcessProxy::releaseHighPerformanceGPU); |
243 | return; |
244 | } |
245 | #endif |
246 | #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) |
247 | if (decoder.messageName() == Messages::WebProcessProxy::StartDisplayLink::name()) { |
248 | IPC::handleMessage<Messages::WebProcessProxy::StartDisplayLink>(decoder, this, &WebProcessProxy::startDisplayLink); |
249 | return; |
250 | } |
251 | #endif |
252 | #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) |
253 | if (decoder.messageName() == Messages::WebProcessProxy::StopDisplayLink::name()) { |
254 | IPC::handleMessage<Messages::WebProcessProxy::StopDisplayLink>(decoder, this, &WebProcessProxy::stopDisplayLink); |
255 | return; |
256 | } |
257 | #endif |
258 | #if HAVE(VISIBILITY_PROPAGATION_VIEW) |
259 | if (decoder.messageName() == Messages::WebProcessProxy::DidCreateContextForVisibilityPropagation::name()) { |
260 | IPC::handleMessage<Messages::WebProcessProxy::DidCreateContextForVisibilityPropagation>(decoder, this, &WebProcessProxy::didCreateContextForVisibilityPropagation); |
261 | return; |
262 | } |
263 | #endif |
264 | #if PLATFORM(IOS_FAMILY) |
265 | if (decoder.messageName() == Messages::WebProcessProxy::ProcessWasUnexpectedlyUnsuspended::name()) { |
266 | IPC::handleMessageAsync<Messages::WebProcessProxy::ProcessWasUnexpectedlyUnsuspended>(connection, decoder, this, &WebProcessProxy::processWasUnexpectedlyUnsuspended); |
267 | return; |
268 | } |
269 | #endif |
270 | UNUSED_PARAM(connection); |
271 | UNUSED_PARAM(decoder); |
272 | ASSERT_NOT_REACHED(); |
273 | } |
274 | |
275 | void WebProcessProxy::didReceiveSyncWebProcessProxyMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder) |
276 | { |
277 | if (decoder.messageName() == Messages::WebProcessProxy::ShouldTerminate::name()) { |
278 | IPC::handleMessageSynchronous<Messages::WebProcessProxy::ShouldTerminate>(connection, decoder, replyEncoder, this, &WebProcessProxy::shouldTerminate); |
279 | return; |
280 | } |
281 | #if ENABLE(NETSCAPE_PLUGIN_API) |
282 | if (decoder.messageName() == Messages::WebProcessProxy::GetPlugins::name()) { |
283 | IPC::handleMessageSynchronous<Messages::WebProcessProxy::GetPlugins>(connection, decoder, replyEncoder, this, &WebProcessProxy::getPlugins); |
284 | return; |
285 | } |
286 | #endif |
287 | #if ENABLE(NETSCAPE_PLUGIN_API) |
288 | if (decoder.messageName() == Messages::WebProcessProxy::GetPluginProcessConnection::name()) { |
289 | IPC::handleMessageSynchronous<Messages::WebProcessProxy::GetPluginProcessConnection>(connection, decoder, replyEncoder, this, &WebProcessProxy::getPluginProcessConnection); |
290 | return; |
291 | } |
292 | #endif |
293 | if (decoder.messageName() == Messages::WebProcessProxy::GetNetworkProcessConnection::name()) { |
294 | IPC::handleMessageSynchronous<Messages::WebProcessProxy::GetNetworkProcessConnection>(connection, decoder, replyEncoder, this, &WebProcessProxy::getNetworkProcessConnection); |
295 | return; |
296 | } |
297 | UNUSED_PARAM(connection); |
298 | UNUSED_PARAM(decoder); |
299 | UNUSED_PARAM(replyEncoder); |
300 | ASSERT_NOT_REACHED(); |
301 | } |
302 | |
303 | } // namespace WebKit |
304 | |
305 | |