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