[WPE] Do not create a PlatformDisplay in the Service Worker process
[WebKit-https.git] / Source / WebKit / Shared / WebProcessCreationParameters.cpp
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()
38 {
39 }
40
41 WebProcessCreationParameters::~WebProcessCreationParameters()
42 {
43 }
44
45 void WebProcessCreationParameters::encode(IPC::Encoder& encoder) const
46 {
47     encoder << injectedBundlePath;
48     encoder << injectedBundlePathExtensionHandle;
49     encoder << additionalSandboxExtensionHandles;
50     encoder << initializationUserData;
51     encoder << applicationCacheDirectory;
52     encoder << applicationCacheFlatFileSubdirectoryName;
53     encoder << applicationCacheDirectoryExtensionHandle;
54     encoder << webSQLDatabaseDirectory;
55     encoder << webSQLDatabaseDirectoryExtensionHandle;
56     encoder << mediaCacheDirectory;
57     encoder << mediaCacheDirectoryExtensionHandle;
58     encoder << javaScriptConfigurationDirectory;
59     encoder << javaScriptConfigurationDirectoryExtensionHandle;
60 #if PLATFORM(IOS_FAMILY)
61     encoder << cookieStorageDirectoryExtensionHandle;
62     encoder << containerCachesDirectoryExtensionHandle;
63     encoder << containerTemporaryDirectoryExtensionHandle;
64 #endif
65     encoder << mediaKeyStorageDirectory;
66     encoder << webCoreLoggingChannels;
67     encoder << webKitLoggingChannels;
68     encoder << mediaKeyStorageDirectoryExtensionHandle;
69 #if ENABLE(MEDIA_STREAM)
70     encoder << audioCaptureExtensionHandle;
71     encoder << shouldCaptureAudioInUIProcess;
72     encoder << shouldCaptureVideoInUIProcess;
73     encoder << shouldCaptureDisplayInUIProcess;
74 #endif
75     encoder << urlSchemesRegisteredAsEmptyDocument;
76     encoder << urlSchemesRegisteredAsSecure;
77     encoder << urlSchemesRegisteredAsBypassingContentSecurityPolicy;
78     encoder << urlSchemesForWhichDomainRelaxationIsForbidden;
79     encoder << urlSchemesRegisteredAsLocal;
80     encoder << urlSchemesRegisteredAsNoAccess;
81     encoder << urlSchemesRegisteredAsDisplayIsolated;
82     encoder << urlSchemesRegisteredAsCORSEnabled;
83     encoder << urlSchemesRegisteredAsAlwaysRevalidated;
84     encoder << urlSchemesRegisteredAsCachePartitioned;
85     encoder << urlSchemesServiceWorkersCanHandle;
86     encoder << urlSchemesRegisteredAsCanDisplayOnlyIfCanRequest;
87     encoder.encodeEnum(cacheModel);
88     encoder << shouldAlwaysUseComplexTextCodePath;
89     encoder << shouldEnableMemoryPressureReliefLogging;
90     encoder << shouldSuppressMemoryPressureHandler;
91     encoder << shouldUseFontSmoothing;
92     encoder << resourceLoadStatisticsEnabled;
93     encoder << fontWhitelist;
94     encoder << terminationTimeout;
95     encoder << languages;
96 #if USE(GSTREAMER)
97     encoder << gstreamerOptions;
98 #endif
99     encoder << textCheckerState;
100     encoder << fullKeyboardAccessEnabled;
101     encoder << defaultRequestTimeoutInterval;
102 #if PLATFORM(COCOA)
103     encoder << uiProcessBundleIdentifier;
104     encoder << uiProcessSDKVersion;
105 #endif
106     encoder << presentingApplicationPID;
107 #if PLATFORM(COCOA)
108     encoder << accessibilityEnhancedUserInterfaceEnabled;
109     encoder << acceleratedCompositingPort;
110     encoder << uiProcessBundleResourcePath;
111     encoder << uiProcessBundleResourcePathExtensionHandle;
112     encoder << shouldEnableJIT;
113     encoder << shouldEnableFTLJIT;
114     encoder << !!bundleParameterData;
115     if (bundleParameterData)
116         encoder << bundleParameterData->dataReference();
117 #endif
118
119 #if ENABLE(NOTIFICATIONS)
120     encoder << notificationPermissions;
121 #endif
122
123     encoder << plugInAutoStartOriginHashes;
124     encoder << plugInAutoStartOrigins;
125     encoder << memoryCacheDisabled;
126     encoder << attrStyleEnabled;
127
128 #if ENABLE(SERVICE_CONTROLS)
129     encoder << hasImageServices;
130     encoder << hasSelectionServices;
131     encoder << hasRichContentServices;
132 #endif
133
134 #if ENABLE(NETSCAPE_PLUGIN_API)
135     encoder << pluginLoadClientPolicies;
136 #endif
137
138 #if PLATFORM(COCOA)
139     IPC::encode(encoder, networkATSContext.get());
140 #endif
141
142 #if PLATFORM(WAYLAND)
143     encoder << waylandCompositorDisplayName;
144 #endif
145
146 #if USE(SOUP)
147     encoder << proxySettings;
148 #endif
149
150 #if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED
151     encoder << shouldLogUserInteraction;
152 #endif
153
154 #if PLATFORM(COCOA)
155     encoder << mediaMIMETypes;
156 #endif
157
158 #if PLATFORM(MAC)
159     encoder << screenProperties;
160     encoder << useOverlayScrollbars;
161 #endif
162
163 #if PLATFORM(WPE)
164     encoder << isServiceWorkerProcess;
165     encoder << hostClientFileDescriptor;
166     encoder << implementationLibraryName;
167 #endif
168 }
169
170 bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreationParameters& parameters)
171 {
172     if (!decoder.decode(parameters.injectedBundlePath))
173         return false;
174     
175     Optional<SandboxExtension::Handle> injectedBundlePathExtensionHandle;
176     decoder >> injectedBundlePathExtensionHandle;
177     if (!injectedBundlePathExtensionHandle)
178         return false;
179     parameters.injectedBundlePathExtensionHandle = WTFMove(*injectedBundlePathExtensionHandle);
180
181     Optional<SandboxExtension::HandleArray> additionalSandboxExtensionHandles;
182     decoder >> additionalSandboxExtensionHandles;
183     if (!additionalSandboxExtensionHandles)
184         return false;
185     parameters.additionalSandboxExtensionHandles = WTFMove(*additionalSandboxExtensionHandles);
186     if (!decoder.decode(parameters.initializationUserData))
187         return false;
188     if (!decoder.decode(parameters.applicationCacheDirectory))
189         return false;
190     if (!decoder.decode(parameters.applicationCacheFlatFileSubdirectoryName))
191         return false;
192     
193     Optional<SandboxExtension::Handle> applicationCacheDirectoryExtensionHandle;
194     decoder >> applicationCacheDirectoryExtensionHandle;
195     if (!applicationCacheDirectoryExtensionHandle)
196         return false;
197     parameters.applicationCacheDirectoryExtensionHandle = WTFMove(*applicationCacheDirectoryExtensionHandle);
198
199     if (!decoder.decode(parameters.webSQLDatabaseDirectory))
200         return false;
201
202     Optional<SandboxExtension::Handle> webSQLDatabaseDirectoryExtensionHandle;
203     decoder >> webSQLDatabaseDirectoryExtensionHandle;
204     if (!webSQLDatabaseDirectoryExtensionHandle)
205         return false;
206     parameters.webSQLDatabaseDirectoryExtensionHandle = WTFMove(*webSQLDatabaseDirectoryExtensionHandle);
207
208     if (!decoder.decode(parameters.mediaCacheDirectory))
209         return false;
210     
211     Optional<SandboxExtension::Handle> mediaCacheDirectoryExtensionHandle;
212     decoder >> mediaCacheDirectoryExtensionHandle;
213     if (!mediaCacheDirectoryExtensionHandle)
214         return false;
215     parameters.mediaCacheDirectoryExtensionHandle = WTFMove(*mediaCacheDirectoryExtensionHandle);
216
217     if (!decoder.decode(parameters.javaScriptConfigurationDirectory))
218         return false;
219     
220     Optional<SandboxExtension::Handle> javaScriptConfigurationDirectoryExtensionHandle;
221     decoder >> javaScriptConfigurationDirectoryExtensionHandle;
222     if (!javaScriptConfigurationDirectoryExtensionHandle)
223         return false;
224     parameters.javaScriptConfigurationDirectoryExtensionHandle = WTFMove(*javaScriptConfigurationDirectoryExtensionHandle);
225
226 #if PLATFORM(IOS_FAMILY)
227     
228     Optional<SandboxExtension::Handle> cookieStorageDirectoryExtensionHandle;
229     decoder >> cookieStorageDirectoryExtensionHandle;
230     if (!cookieStorageDirectoryExtensionHandle)
231         return false;
232     parameters.cookieStorageDirectoryExtensionHandle = WTFMove(*cookieStorageDirectoryExtensionHandle);
233
234     Optional<SandboxExtension::Handle> containerCachesDirectoryExtensionHandle;
235     decoder >> containerCachesDirectoryExtensionHandle;
236     if (!containerCachesDirectoryExtensionHandle)
237         return false;
238     parameters.containerCachesDirectoryExtensionHandle = WTFMove(*containerCachesDirectoryExtensionHandle);
239
240     Optional<SandboxExtension::Handle> containerTemporaryDirectoryExtensionHandle;
241     decoder >> containerTemporaryDirectoryExtensionHandle;
242     if (!containerTemporaryDirectoryExtensionHandle)
243         return false;
244     parameters.containerTemporaryDirectoryExtensionHandle = WTFMove(*containerTemporaryDirectoryExtensionHandle);
245
246 #endif
247     if (!decoder.decode(parameters.mediaKeyStorageDirectory))
248         return false;
249     if (!decoder.decode(parameters.webCoreLoggingChannels))
250         return false;
251     if (!decoder.decode(parameters.webKitLoggingChannels))
252         return false;
253     
254     Optional<SandboxExtension::Handle> mediaKeyStorageDirectoryExtensionHandle;
255     decoder >> mediaKeyStorageDirectoryExtensionHandle;
256     if (!mediaKeyStorageDirectoryExtensionHandle)
257         return false;
258     parameters.mediaKeyStorageDirectoryExtensionHandle = WTFMove(*mediaKeyStorageDirectoryExtensionHandle);
259
260 #if ENABLE(MEDIA_STREAM)
261
262     Optional<SandboxExtension::Handle> audioCaptureExtensionHandle;
263     decoder >> audioCaptureExtensionHandle;
264     if (!audioCaptureExtensionHandle)
265         return false;
266     parameters.audioCaptureExtensionHandle = WTFMove(*audioCaptureExtensionHandle);
267
268     if (!decoder.decode(parameters.shouldCaptureAudioInUIProcess))
269         return false;
270     if (!decoder.decode(parameters.shouldCaptureVideoInUIProcess))
271         return false;
272     if (!decoder.decode(parameters.shouldCaptureDisplayInUIProcess))
273         return false;
274 #endif
275     if (!decoder.decode(parameters.urlSchemesRegisteredAsEmptyDocument))
276         return false;
277     if (!decoder.decode(parameters.urlSchemesRegisteredAsSecure))
278         return false;
279     if (!decoder.decode(parameters.urlSchemesRegisteredAsBypassingContentSecurityPolicy))
280         return false;
281     if (!decoder.decode(parameters.urlSchemesForWhichDomainRelaxationIsForbidden))
282         return false;
283     if (!decoder.decode(parameters.urlSchemesRegisteredAsLocal))
284         return false;
285     if (!decoder.decode(parameters.urlSchemesRegisteredAsNoAccess))
286         return false;
287     if (!decoder.decode(parameters.urlSchemesRegisteredAsDisplayIsolated))
288         return false;
289     if (!decoder.decode(parameters.urlSchemesRegisteredAsCORSEnabled))
290         return false;
291     if (!decoder.decode(parameters.urlSchemesRegisteredAsAlwaysRevalidated))
292         return false;
293     if (!decoder.decode(parameters.urlSchemesRegisteredAsCachePartitioned))
294         return false;
295     if (!decoder.decode(parameters.urlSchemesServiceWorkersCanHandle))
296         return false;
297     if (!decoder.decode(parameters.urlSchemesRegisteredAsCanDisplayOnlyIfCanRequest))
298         return false;
299     if (!decoder.decodeEnum(parameters.cacheModel))
300         return false;
301     if (!decoder.decode(parameters.shouldAlwaysUseComplexTextCodePath))
302         return false;
303     if (!decoder.decode(parameters.shouldEnableMemoryPressureReliefLogging))
304         return false;
305     if (!decoder.decode(parameters.shouldSuppressMemoryPressureHandler))
306         return false;
307     if (!decoder.decode(parameters.shouldUseFontSmoothing))
308         return false;
309     if (!decoder.decode(parameters.resourceLoadStatisticsEnabled))
310         return false;
311     if (!decoder.decode(parameters.fontWhitelist))
312         return false;
313     if (!decoder.decode(parameters.terminationTimeout))
314         return false;
315     if (!decoder.decode(parameters.languages))
316         return false;
317 #if USE(GSTREAMER)
318     if (!decoder.decode(parameters.gstreamerOptions))
319         return false;
320 #endif
321     if (!decoder.decode(parameters.textCheckerState))
322         return false;
323     if (!decoder.decode(parameters.fullKeyboardAccessEnabled))
324         return false;
325     if (!decoder.decode(parameters.defaultRequestTimeoutInterval))
326         return false;
327 #if PLATFORM(COCOA)
328     if (!decoder.decode(parameters.uiProcessBundleIdentifier))
329         return false;
330     if (!decoder.decode(parameters.uiProcessSDKVersion))
331         return false;
332 #endif
333     if (!decoder.decode(parameters.presentingApplicationPID))
334         return false;
335 #if PLATFORM(COCOA)
336     if (!decoder.decode(parameters.accessibilityEnhancedUserInterfaceEnabled))
337         return false;
338     if (!decoder.decode(parameters.acceleratedCompositingPort))
339         return false;
340     if (!decoder.decode(parameters.uiProcessBundleResourcePath))
341         return false;
342     
343     Optional<SandboxExtension::Handle> uiProcessBundleResourcePathExtensionHandle;
344     decoder >> uiProcessBundleResourcePathExtensionHandle;
345     if (!uiProcessBundleResourcePathExtensionHandle)
346         return false;
347     parameters.uiProcessBundleResourcePathExtensionHandle = WTFMove(*uiProcessBundleResourcePathExtensionHandle);
348
349     if (!decoder.decode(parameters.shouldEnableJIT))
350         return false;
351     if (!decoder.decode(parameters.shouldEnableFTLJIT))
352         return false;
353
354     bool hasBundleParameterData;
355     if (!decoder.decode(hasBundleParameterData))
356         return false;
357
358     if (hasBundleParameterData) {
359         IPC::DataReference dataReference;
360         if (!decoder.decode(dataReference))
361             return false;
362
363         parameters.bundleParameterData = API::Data::create(dataReference.data(), dataReference.size());
364     }
365 #endif
366
367 #if ENABLE(NOTIFICATIONS)
368     if (!decoder.decode(parameters.notificationPermissions))
369         return false;
370 #endif
371
372     if (!decoder.decode(parameters.plugInAutoStartOriginHashes))
373         return false;
374     if (!decoder.decode(parameters.plugInAutoStartOrigins))
375         return false;
376     if (!decoder.decode(parameters.memoryCacheDisabled))
377         return false;
378     if (!decoder.decode(parameters.attrStyleEnabled))
379         return false;
380
381 #if ENABLE(SERVICE_CONTROLS)
382     if (!decoder.decode(parameters.hasImageServices))
383         return false;
384     if (!decoder.decode(parameters.hasSelectionServices))
385         return false;
386     if (!decoder.decode(parameters.hasRichContentServices))
387         return false;
388 #endif
389
390 #if ENABLE(NETSCAPE_PLUGIN_API)
391     if (!decoder.decode(parameters.pluginLoadClientPolicies))
392         return false;
393 #endif
394
395 #if PLATFORM(COCOA)
396     if (!IPC::decode(decoder, parameters.networkATSContext))
397         return false;
398 #endif
399
400 #if PLATFORM(WAYLAND)
401     if (!decoder.decode(parameters.waylandCompositorDisplayName))
402         return false;
403 #endif
404
405 #if USE(SOUP)
406     if (!decoder.decode(parameters.proxySettings))
407         return false;
408 #endif
409
410 #if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED
411     if (!decoder.decode(parameters.shouldLogUserInteraction))
412         return false;
413 #endif
414
415 #if PLATFORM(COCOA)
416     if (!decoder.decode(parameters.mediaMIMETypes))
417         return false;
418 #endif
419
420 #if PLATFORM(MAC)
421     Optional<WebCore::ScreenProperties> screenProperties;
422     decoder >> screenProperties;
423     if (!screenProperties)
424         return false;
425     parameters.screenProperties = WTFMove(*screenProperties);
426     if (!decoder.decode(parameters.useOverlayScrollbars))
427         return false;
428 #endif
429
430 #if PLATFORM(WPE)
431     if (!decoder.decode(parameters.isServiceWorkerProcess))
432         return false;
433     if (!decoder.decode(parameters.hostClientFileDescriptor))
434         return false;
435     if (!decoder.decode(parameters.implementationLibraryName))
436         return false;
437 #endif
438
439     return true;
440 }
441
442 } // namespace WebKit