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'' |
14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 | * THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #include "config.h" |
27 | #include "WebProcessCreationParameters.h" |
28 | |
29 | #include "APIData.h" |
30 | #if PLATFORM(COCOA) |
31 | #include "ArgumentCodersCF.h" |
32 | #endif |
33 | #include "WebCoreArgumentCoders.h" |
34 | |
35 | namespace WebKit { |
36 | |
37 | WebProcessCreationParameters::WebProcessCreationParameters(WebProcessCreationParameters&&) = default; |
38 | WebProcessCreationParameters& WebProcessCreationParameters::operator=(WebProcessCreationParameters&&) = default; |
39 | |
40 | WebProcessCreationParameters::WebProcessCreationParameters() |
41 | { |
42 | } |
43 | |
44 | WebProcessCreationParameters::~WebProcessCreationParameters() |
45 | { |
46 | } |
47 | |
48 | void WebProcessCreationParameters::encode(IPC::Encoder& encoder) const |
49 | { |
50 | encoder << injectedBundlePath; |
51 | encoder << injectedBundlePathExtensionHandle; |
52 | encoder << additionalSandboxExtensionHandles; |
53 | encoder << initializationUserData; |
54 | #if PLATFORM(IOS_FAMILY) |
55 | encoder << cookieStorageDirectoryExtensionHandle; |
56 | encoder << containerCachesDirectoryExtensionHandle; |
57 | encoder << containerTemporaryDirectoryExtensionHandle; |
58 | #endif |
59 | encoder << webCoreLoggingChannels; |
60 | encoder << webKitLoggingChannels; |
61 | #if ENABLE(MEDIA_STREAM) |
62 | encoder << audioCaptureExtensionHandle; |
63 | encoder << shouldCaptureAudioInUIProcess; |
64 | encoder << shouldCaptureVideoInUIProcess; |
65 | encoder << shouldCaptureDisplayInUIProcess; |
66 | #endif |
67 | encoder << urlSchemesRegisteredAsEmptyDocument; |
68 | encoder << urlSchemesRegisteredAsSecure; |
69 | encoder << urlSchemesRegisteredAsBypassingContentSecurityPolicy; |
70 | encoder << urlSchemesForWhichDomainRelaxationIsForbidden; |
71 | encoder << urlSchemesRegisteredAsLocal; |
72 | encoder << urlSchemesRegisteredAsNoAccess; |
73 | encoder << urlSchemesRegisteredAsDisplayIsolated; |
74 | encoder << urlSchemesRegisteredAsCORSEnabled; |
75 | encoder << urlSchemesRegisteredAsAlwaysRevalidated; |
76 | encoder << urlSchemesRegisteredAsCachePartitioned; |
77 | encoder << urlSchemesServiceWorkersCanHandle; |
78 | encoder << urlSchemesRegisteredAsCanDisplayOnlyIfCanRequest; |
79 | encoder.encodeEnum(cacheModel); |
80 | encoder << shouldAlwaysUseComplexTextCodePath; |
81 | encoder << shouldEnableMemoryPressureReliefLogging; |
82 | encoder << shouldSuppressMemoryPressureHandler; |
83 | encoder << shouldUseFontSmoothing; |
84 | encoder << fontWhitelist; |
85 | encoder << terminationTimeout; |
86 | encoder << languages; |
87 | #if USE(GSTREAMER) |
88 | encoder << gstreamerOptions; |
89 | #endif |
90 | encoder << textCheckerState; |
91 | encoder << fullKeyboardAccessEnabled; |
92 | encoder << defaultRequestTimeoutInterval; |
93 | #if PLATFORM(COCOA) |
94 | encoder << uiProcessBundleIdentifier; |
95 | encoder << uiProcessSDKVersion; |
96 | #endif |
97 | encoder << presentingApplicationPID; |
98 | #if PLATFORM(COCOA) |
99 | encoder << accessibilityEnhancedUserInterfaceEnabled; |
100 | encoder << acceleratedCompositingPort; |
101 | encoder << uiProcessBundleResourcePath; |
102 | encoder << uiProcessBundleResourcePathExtensionHandle; |
103 | encoder << shouldEnableJIT; |
104 | encoder << shouldEnableFTLJIT; |
105 | encoder << !!bundleParameterData; |
106 | if (bundleParameterData) |
107 | encoder << bundleParameterData->dataReference(); |
108 | #endif |
109 | |
110 | #if ENABLE(NOTIFICATIONS) |
111 | encoder << notificationPermissions; |
112 | #endif |
113 | |
114 | encoder << plugInAutoStartOriginHashes; |
115 | encoder << plugInAutoStartOrigins; |
116 | encoder << memoryCacheDisabled; |
117 | encoder << attrStyleEnabled; |
118 | |
119 | #if ENABLE(SERVICE_CONTROLS) |
120 | encoder << hasImageServices; |
121 | encoder << hasSelectionServices; |
122 | encoder << hasRichContentServices; |
123 | #endif |
124 | |
125 | #if ENABLE(NETSCAPE_PLUGIN_API) |
126 | encoder << pluginLoadClientPolicies; |
127 | #endif |
128 | |
129 | #if PLATFORM(COCOA) |
130 | IPC::encode(encoder, networkATSContext.get()); |
131 | #endif |
132 | |
133 | #if PLATFORM(WAYLAND) |
134 | encoder << waylandCompositorDisplayName; |
135 | #endif |
136 | |
137 | #if USE(SOUP) |
138 | encoder << proxySettings; |
139 | #endif |
140 | |
141 | #if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED |
142 | encoder << shouldLogUserInteraction; |
143 | #endif |
144 | |
145 | #if PLATFORM(COCOA) |
146 | encoder << mediaMIMETypes; |
147 | #endif |
148 | |
149 | #if PLATFORM(MAC) |
150 | encoder << screenProperties; |
151 | encoder << useOverlayScrollbars; |
152 | #endif |
153 | |
154 | #if USE(WPE_RENDERER) |
155 | encoder << isServiceWorkerProcess; |
156 | encoder << hostClientFileDescriptor; |
157 | encoder << implementationLibraryName; |
158 | #endif |
159 | } |
160 | |
161 | bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreationParameters& parameters) |
162 | { |
163 | if (!decoder.decode(parameters.injectedBundlePath)) |
164 | return false; |
165 | |
166 | Optional<SandboxExtension::Handle> injectedBundlePathExtensionHandle; |
167 | decoder >> injectedBundlePathExtensionHandle; |
168 | if (!injectedBundlePathExtensionHandle) |
169 | return false; |
170 | parameters.injectedBundlePathExtensionHandle = WTFMove(*injectedBundlePathExtensionHandle); |
171 | |
172 | Optional<SandboxExtension::HandleArray> additionalSandboxExtensionHandles; |
173 | decoder >> additionalSandboxExtensionHandles; |
174 | if (!additionalSandboxExtensionHandles) |
175 | return false; |
176 | parameters.additionalSandboxExtensionHandles = WTFMove(*additionalSandboxExtensionHandles); |
177 | if (!decoder.decode(parameters.initializationUserData)) |
178 | return false; |
179 | |
180 | #if PLATFORM(IOS_FAMILY) |
181 | |
182 | Optional<SandboxExtension::Handle> cookieStorageDirectoryExtensionHandle; |
183 | decoder >> cookieStorageDirectoryExtensionHandle; |
184 | if (!cookieStorageDirectoryExtensionHandle) |
185 | return false; |
186 | parameters.cookieStorageDirectoryExtensionHandle = WTFMove(*cookieStorageDirectoryExtensionHandle); |
187 | |
188 | Optional<SandboxExtension::Handle> containerCachesDirectoryExtensionHandle; |
189 | decoder >> containerCachesDirectoryExtensionHandle; |
190 | if (!containerCachesDirectoryExtensionHandle) |
191 | return false; |
192 | parameters.containerCachesDirectoryExtensionHandle = WTFMove(*containerCachesDirectoryExtensionHandle); |
193 | |
194 | Optional<SandboxExtension::Handle> containerTemporaryDirectoryExtensionHandle; |
195 | decoder >> containerTemporaryDirectoryExtensionHandle; |
196 | if (!containerTemporaryDirectoryExtensionHandle) |
197 | return false; |
198 | parameters.containerTemporaryDirectoryExtensionHandle = WTFMove(*containerTemporaryDirectoryExtensionHandle); |
199 | |
200 | #endif |
201 | if (!decoder.decode(parameters.webCoreLoggingChannels)) |
202 | return false; |
203 | if (!decoder.decode(parameters.webKitLoggingChannels)) |
204 | return false; |
205 | |
206 | #if ENABLE(MEDIA_STREAM) |
207 | |
208 | Optional<SandboxExtension::Handle> audioCaptureExtensionHandle; |
209 | decoder >> audioCaptureExtensionHandle; |
210 | if (!audioCaptureExtensionHandle) |
211 | return false; |
212 | parameters.audioCaptureExtensionHandle = WTFMove(*audioCaptureExtensionHandle); |
213 | |
214 | if (!decoder.decode(parameters.shouldCaptureAudioInUIProcess)) |
215 | return false; |
216 | if (!decoder.decode(parameters.shouldCaptureVideoInUIProcess)) |
217 | return false; |
218 | if (!decoder.decode(parameters.shouldCaptureDisplayInUIProcess)) |
219 | return false; |
220 | #endif |
221 | if (!decoder.decode(parameters.urlSchemesRegisteredAsEmptyDocument)) |
222 | return false; |
223 | if (!decoder.decode(parameters.urlSchemesRegisteredAsSecure)) |
224 | return false; |
225 | if (!decoder.decode(parameters.urlSchemesRegisteredAsBypassingContentSecurityPolicy)) |
226 | return false; |
227 | if (!decoder.decode(parameters.urlSchemesForWhichDomainRelaxationIsForbidden)) |
228 | return false; |
229 | if (!decoder.decode(parameters.urlSchemesRegisteredAsLocal)) |
230 | return false; |
231 | if (!decoder.decode(parameters.urlSchemesRegisteredAsNoAccess)) |
232 | return false; |
233 | if (!decoder.decode(parameters.urlSchemesRegisteredAsDisplayIsolated)) |
234 | return false; |
235 | if (!decoder.decode(parameters.urlSchemesRegisteredAsCORSEnabled)) |
236 | return false; |
237 | if (!decoder.decode(parameters.urlSchemesRegisteredAsAlwaysRevalidated)) |
238 | return false; |
239 | if (!decoder.decode(parameters.urlSchemesRegisteredAsCachePartitioned)) |
240 | return false; |
241 | if (!decoder.decode(parameters.urlSchemesServiceWorkersCanHandle)) |
242 | return false; |
243 | if (!decoder.decode(parameters.urlSchemesRegisteredAsCanDisplayOnlyIfCanRequest)) |
244 | return false; |
245 | if (!decoder.decodeEnum(parameters.cacheModel)) |
246 | return false; |
247 | if (!decoder.decode(parameters.shouldAlwaysUseComplexTextCodePath)) |
248 | return false; |
249 | if (!decoder.decode(parameters.shouldEnableMemoryPressureReliefLogging)) |
250 | return false; |
251 | if (!decoder.decode(parameters.shouldSuppressMemoryPressureHandler)) |
252 | return false; |
253 | if (!decoder.decode(parameters.shouldUseFontSmoothing)) |
254 | return false; |
255 | if (!decoder.decode(parameters.fontWhitelist)) |
256 | return false; |
257 | if (!decoder.decode(parameters.terminationTimeout)) |
258 | return false; |
259 | if (!decoder.decode(parameters.languages)) |
260 | return false; |
261 | #if USE(GSTREAMER) |
262 | if (!decoder.decode(parameters.gstreamerOptions)) |
263 | return false; |
264 | #endif |
265 | if (!decoder.decode(parameters.textCheckerState)) |
266 | return false; |
267 | if (!decoder.decode(parameters.fullKeyboardAccessEnabled)) |
268 | return false; |
269 | if (!decoder.decode(parameters.defaultRequestTimeoutInterval)) |
270 | return false; |
271 | #if PLATFORM(COCOA) |
272 | if (!decoder.decode(parameters.uiProcessBundleIdentifier)) |
273 | return false; |
274 | if (!decoder.decode(parameters.uiProcessSDKVersion)) |
275 | return false; |
276 | #endif |
277 | if (!decoder.decode(parameters.presentingApplicationPID)) |
278 | return false; |
279 | #if PLATFORM(COCOA) |
280 | if (!decoder.decode(parameters.accessibilityEnhancedUserInterfaceEnabled)) |
281 | return false; |
282 | if (!decoder.decode(parameters.acceleratedCompositingPort)) |
283 | return false; |
284 | if (!decoder.decode(parameters.uiProcessBundleResourcePath)) |
285 | return false; |
286 | |
287 | Optional<SandboxExtension::Handle> uiProcessBundleResourcePathExtensionHandle; |
288 | decoder >> uiProcessBundleResourcePathExtensionHandle; |
289 | if (!uiProcessBundleResourcePathExtensionHandle) |
290 | return false; |
291 | parameters.uiProcessBundleResourcePathExtensionHandle = WTFMove(*uiProcessBundleResourcePathExtensionHandle); |
292 | |
293 | if (!decoder.decode(parameters.shouldEnableJIT)) |
294 | return false; |
295 | if (!decoder.decode(parameters.shouldEnableFTLJIT)) |
296 | return false; |
297 | |
298 | bool hasBundleParameterData; |
299 | if (!decoder.decode(hasBundleParameterData)) |
300 | return false; |
301 | |
302 | if (hasBundleParameterData) { |
303 | IPC::DataReference dataReference; |
304 | if (!decoder.decode(dataReference)) |
305 | return false; |
306 | |
307 | parameters.bundleParameterData = API::Data::create(dataReference.data(), dataReference.size()); |
308 | } |
309 | #endif |
310 | |
311 | #if ENABLE(NOTIFICATIONS) |
312 | if (!decoder.decode(parameters.notificationPermissions)) |
313 | return false; |
314 | #endif |
315 | |
316 | if (!decoder.decode(parameters.plugInAutoStartOriginHashes)) |
317 | return false; |
318 | if (!decoder.decode(parameters.plugInAutoStartOrigins)) |
319 | return false; |
320 | if (!decoder.decode(parameters.memoryCacheDisabled)) |
321 | return false; |
322 | if (!decoder.decode(parameters.attrStyleEnabled)) |
323 | return false; |
324 | |
325 | #if ENABLE(SERVICE_CONTROLS) |
326 | if (!decoder.decode(parameters.hasImageServices)) |
327 | return false; |
328 | if (!decoder.decode(parameters.hasSelectionServices)) |
329 | return false; |
330 | if (!decoder.decode(parameters.hasRichContentServices)) |
331 | return false; |
332 | #endif |
333 | |
334 | #if ENABLE(NETSCAPE_PLUGIN_API) |
335 | if (!decoder.decode(parameters.pluginLoadClientPolicies)) |
336 | return false; |
337 | #endif |
338 | |
339 | #if PLATFORM(COCOA) |
340 | if (!IPC::decode(decoder, parameters.networkATSContext)) |
341 | return false; |
342 | #endif |
343 | |
344 | #if PLATFORM(WAYLAND) |
345 | if (!decoder.decode(parameters.waylandCompositorDisplayName)) |
346 | return false; |
347 | #endif |
348 | |
349 | #if USE(SOUP) |
350 | if (!decoder.decode(parameters.proxySettings)) |
351 | return false; |
352 | #endif |
353 | |
354 | #if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED |
355 | if (!decoder.decode(parameters.shouldLogUserInteraction)) |
356 | return false; |
357 | #endif |
358 | |
359 | #if PLATFORM(COCOA) |
360 | if (!decoder.decode(parameters.mediaMIMETypes)) |
361 | return false; |
362 | #endif |
363 | |
364 | #if PLATFORM(MAC) |
365 | Optional<WebCore::ScreenProperties> screenProperties; |
366 | decoder >> screenProperties; |
367 | if (!screenProperties) |
368 | return false; |
369 | parameters.screenProperties = WTFMove(*screenProperties); |
370 | if (!decoder.decode(parameters.useOverlayScrollbars)) |
371 | return false; |
372 | #endif |
373 | |
374 | #if USE(WPE_RENDERER) |
375 | if (!decoder.decode(parameters.isServiceWorkerProcess)) |
376 | return false; |
377 | if (!decoder.decode(parameters.hostClientFileDescriptor)) |
378 | return false; |
379 | if (!decoder.decode(parameters.implementationLibraryName)) |
380 | return false; |
381 | #endif |
382 | |
383 | return true; |
384 | } |
385 | |
386 | } // namespace WebKit |
387 | |