WebProcess class methods should not need to take a sessionID
[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(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 << plugInAutoStartOrigins;
115     encoder << memoryCacheDisabled;
116     encoder << attrStyleEnabled;
117
118 #if ENABLE(SERVICE_CONTROLS)
119     encoder << hasImageServices;
120     encoder << hasSelectionServices;
121     encoder << hasRichContentServices;
122 #endif
123
124 #if ENABLE(NETSCAPE_PLUGIN_API)
125     encoder << pluginLoadClientPolicies;
126 #endif
127
128 #if PLATFORM(COCOA)
129     IPC::encode(encoder, networkATSContext.get());
130 #endif
131
132 #if PLATFORM(WAYLAND)
133     encoder << waylandCompositorDisplayName;
134 #endif
135
136 #if USE(SOUP)
137     encoder << proxySettings;
138 #endif
139
140 #if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED
141     encoder << shouldLogUserInteraction;
142 #endif
143
144 #if PLATFORM(COCOA)
145     encoder << mediaMIMETypes;
146 #endif
147
148 #if PLATFORM(MAC)
149     encoder << screenProperties;
150     encoder << useOverlayScrollbars;
151 #endif
152
153 #if USE(WPE_RENDERER)
154     encoder << isServiceWorkerProcess;
155     encoder << hostClientFileDescriptor;
156     encoder << implementationLibraryName;
157 #endif
158
159     encoder << websiteDataStoreParameters;
160 }
161
162 bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreationParameters& parameters)
163 {
164     if (!decoder.decode(parameters.injectedBundlePath))
165         return false;
166     
167     Optional<SandboxExtension::Handle> injectedBundlePathExtensionHandle;
168     decoder >> injectedBundlePathExtensionHandle;
169     if (!injectedBundlePathExtensionHandle)
170         return false;
171     parameters.injectedBundlePathExtensionHandle = WTFMove(*injectedBundlePathExtensionHandle);
172
173     Optional<SandboxExtension::HandleArray> additionalSandboxExtensionHandles;
174     decoder >> additionalSandboxExtensionHandles;
175     if (!additionalSandboxExtensionHandles)
176         return false;
177     parameters.additionalSandboxExtensionHandles = WTFMove(*additionalSandboxExtensionHandles);
178     if (!decoder.decode(parameters.initializationUserData))
179         return false;
180
181 #if PLATFORM(IOS_FAMILY)
182     
183     Optional<SandboxExtension::Handle> cookieStorageDirectoryExtensionHandle;
184     decoder >> cookieStorageDirectoryExtensionHandle;
185     if (!cookieStorageDirectoryExtensionHandle)
186         return false;
187     parameters.cookieStorageDirectoryExtensionHandle = WTFMove(*cookieStorageDirectoryExtensionHandle);
188
189     Optional<SandboxExtension::Handle> containerCachesDirectoryExtensionHandle;
190     decoder >> containerCachesDirectoryExtensionHandle;
191     if (!containerCachesDirectoryExtensionHandle)
192         return false;
193     parameters.containerCachesDirectoryExtensionHandle = WTFMove(*containerCachesDirectoryExtensionHandle);
194
195     Optional<SandboxExtension::Handle> containerTemporaryDirectoryExtensionHandle;
196     decoder >> containerTemporaryDirectoryExtensionHandle;
197     if (!containerTemporaryDirectoryExtensionHandle)
198         return false;
199     parameters.containerTemporaryDirectoryExtensionHandle = WTFMove(*containerTemporaryDirectoryExtensionHandle);
200
201 #endif
202     if (!decoder.decode(parameters.webCoreLoggingChannels))
203         return false;
204     if (!decoder.decode(parameters.webKitLoggingChannels))
205         return false;
206
207 #if ENABLE(MEDIA_STREAM)
208
209     Optional<SandboxExtension::Handle> audioCaptureExtensionHandle;
210     decoder >> audioCaptureExtensionHandle;
211     if (!audioCaptureExtensionHandle)
212         return false;
213     parameters.audioCaptureExtensionHandle = WTFMove(*audioCaptureExtensionHandle);
214
215     if (!decoder.decode(parameters.shouldCaptureAudioInUIProcess))
216         return false;
217     if (!decoder.decode(parameters.shouldCaptureVideoInUIProcess))
218         return false;
219     if (!decoder.decode(parameters.shouldCaptureDisplayInUIProcess))
220         return false;
221 #endif
222     if (!decoder.decode(parameters.urlSchemesRegisteredAsEmptyDocument))
223         return false;
224     if (!decoder.decode(parameters.urlSchemesRegisteredAsSecure))
225         return false;
226     if (!decoder.decode(parameters.urlSchemesRegisteredAsBypassingContentSecurityPolicy))
227         return false;
228     if (!decoder.decode(parameters.urlSchemesForWhichDomainRelaxationIsForbidden))
229         return false;
230     if (!decoder.decode(parameters.urlSchemesRegisteredAsLocal))
231         return false;
232     if (!decoder.decode(parameters.urlSchemesRegisteredAsNoAccess))
233         return false;
234     if (!decoder.decode(parameters.urlSchemesRegisteredAsDisplayIsolated))
235         return false;
236     if (!decoder.decode(parameters.urlSchemesRegisteredAsCORSEnabled))
237         return false;
238     if (!decoder.decode(parameters.urlSchemesRegisteredAsAlwaysRevalidated))
239         return false;
240     if (!decoder.decode(parameters.urlSchemesRegisteredAsCachePartitioned))
241         return false;
242     if (!decoder.decode(parameters.urlSchemesServiceWorkersCanHandle))
243         return false;
244     if (!decoder.decode(parameters.urlSchemesRegisteredAsCanDisplayOnlyIfCanRequest))
245         return false;
246     if (!decoder.decodeEnum(parameters.cacheModel))
247         return false;
248     if (!decoder.decode(parameters.shouldAlwaysUseComplexTextCodePath))
249         return false;
250     if (!decoder.decode(parameters.shouldEnableMemoryPressureReliefLogging))
251         return false;
252     if (!decoder.decode(parameters.shouldSuppressMemoryPressureHandler))
253         return false;
254     if (!decoder.decode(parameters.shouldUseFontSmoothing))
255         return false;
256     if (!decoder.decode(parameters.fontWhitelist))
257         return false;
258     if (!decoder.decode(parameters.terminationTimeout))
259         return false;
260     if (!decoder.decode(parameters.languages))
261         return false;
262 #if USE(GSTREAMER)
263     if (!decoder.decode(parameters.gstreamerOptions))
264         return false;
265 #endif
266     if (!decoder.decode(parameters.textCheckerState))
267         return false;
268     if (!decoder.decode(parameters.fullKeyboardAccessEnabled))
269         return false;
270     if (!decoder.decode(parameters.defaultRequestTimeoutInterval))
271         return false;
272 #if PLATFORM(COCOA)
273     if (!decoder.decode(parameters.uiProcessBundleIdentifier))
274         return false;
275     if (!decoder.decode(parameters.uiProcessSDKVersion))
276         return false;
277 #endif
278     if (!decoder.decode(parameters.presentingApplicationPID))
279         return false;
280 #if PLATFORM(COCOA)
281     if (!decoder.decode(parameters.accessibilityEnhancedUserInterfaceEnabled))
282         return false;
283     if (!decoder.decode(parameters.acceleratedCompositingPort))
284         return false;
285     if (!decoder.decode(parameters.uiProcessBundleResourcePath))
286         return false;
287     
288     Optional<SandboxExtension::Handle> uiProcessBundleResourcePathExtensionHandle;
289     decoder >> uiProcessBundleResourcePathExtensionHandle;
290     if (!uiProcessBundleResourcePathExtensionHandle)
291         return false;
292     parameters.uiProcessBundleResourcePathExtensionHandle = WTFMove(*uiProcessBundleResourcePathExtensionHandle);
293
294     if (!decoder.decode(parameters.shouldEnableJIT))
295         return false;
296     if (!decoder.decode(parameters.shouldEnableFTLJIT))
297         return false;
298
299     bool hasBundleParameterData;
300     if (!decoder.decode(hasBundleParameterData))
301         return false;
302
303     if (hasBundleParameterData) {
304         IPC::DataReference dataReference;
305         if (!decoder.decode(dataReference))
306             return false;
307
308         parameters.bundleParameterData = API::Data::create(dataReference.data(), dataReference.size());
309     }
310 #endif
311
312 #if ENABLE(NOTIFICATIONS)
313     if (!decoder.decode(parameters.notificationPermissions))
314         return false;
315 #endif
316
317     if (!decoder.decode(parameters.plugInAutoStartOrigins))
318         return false;
319     if (!decoder.decode(parameters.memoryCacheDisabled))
320         return false;
321     if (!decoder.decode(parameters.attrStyleEnabled))
322         return false;
323
324 #if ENABLE(SERVICE_CONTROLS)
325     if (!decoder.decode(parameters.hasImageServices))
326         return false;
327     if (!decoder.decode(parameters.hasSelectionServices))
328         return false;
329     if (!decoder.decode(parameters.hasRichContentServices))
330         return false;
331 #endif
332
333 #if ENABLE(NETSCAPE_PLUGIN_API)
334     if (!decoder.decode(parameters.pluginLoadClientPolicies))
335         return false;
336 #endif
337
338 #if PLATFORM(COCOA)
339     if (!IPC::decode(decoder, parameters.networkATSContext))
340         return false;
341 #endif
342
343 #if PLATFORM(WAYLAND)
344     if (!decoder.decode(parameters.waylandCompositorDisplayName))
345         return false;
346 #endif
347
348 #if USE(SOUP)
349     if (!decoder.decode(parameters.proxySettings))
350         return false;
351 #endif
352
353 #if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED
354     if (!decoder.decode(parameters.shouldLogUserInteraction))
355         return false;
356 #endif
357
358 #if PLATFORM(COCOA)
359     if (!decoder.decode(parameters.mediaMIMETypes))
360         return false;
361 #endif
362
363 #if PLATFORM(MAC)
364     Optional<WebCore::ScreenProperties> screenProperties;
365     decoder >> screenProperties;
366     if (!screenProperties)
367         return false;
368     parameters.screenProperties = WTFMove(*screenProperties);
369     if (!decoder.decode(parameters.useOverlayScrollbars))
370         return false;
371 #endif
372
373 #if USE(WPE_RENDERER)
374     if (!decoder.decode(parameters.isServiceWorkerProcess))
375         return false;
376     if (!decoder.decode(parameters.hostClientFileDescriptor))
377         return false;
378     if (!decoder.decode(parameters.implementationLibraryName))
379         return false;
380 #endif
381
382     Optional<Optional<WebProcessDataStoreParameters>> websiteDataStoreParameters;
383     decoder >> websiteDataStoreParameters;
384     if (!websiteDataStoreParameters)
385         return false;
386     parameters.websiteDataStoreParameters = WTFMove(*websiteDataStoreParameters);
387
388     return true;
389 }
390
391 } // namespace WebKit