Remove source application identifiers from NetworkProcessCreationParameters
[WebKit-https.git] / Source / WebKit / NetworkProcess / NetworkProcessCreationParameters.cpp
1 /*
2  * Copyright (C) 2012-2017 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 "NetworkProcessCreationParameters.h"
28
29 #include "ArgumentCoders.h"
30 #include "WebCoreArgumentCoders.h"
31
32 #if PLATFORM(COCOA)
33 #include "ArgumentCodersCF.h"
34 #endif
35
36 namespace WebKit {
37
38 NetworkProcessCreationParameters::NetworkProcessCreationParameters()
39 {
40 }
41
42 void NetworkProcessCreationParameters::encode(IPC::Encoder& encoder) const
43 {
44     encoder.encodeEnum(cacheModel);
45     encoder << canHandleHTTPSServerTrustEvaluation;
46     encoder << diskCacheDirectory;
47     encoder << diskCacheDirectoryExtensionHandle;
48     encoder << shouldEnableNetworkCacheEfficacyLogging;
49 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION)
50     encoder << shouldEnableNetworkCacheSpeculativeRevalidation;
51 #endif
52 #if PLATFORM(MAC)
53     encoder << uiProcessCookieStorageIdentifier;
54 #endif
55     encoder << defaultSessionPendingCookies;
56 #if PLATFORM(IOS_FAMILY)
57     encoder << cookieStorageDirectoryExtensionHandle;
58     encoder << containerCachesDirectoryExtensionHandle;
59     encoder << parentBundleDirectoryExtensionHandle;
60 #if ENABLE(INDEXED_DATABASE)
61     encoder << indexedDatabaseTempBlobDirectoryExtensionHandle;
62 #endif
63 #endif
64     encoder << shouldSuppressMemoryPressureHandler;
65     encoder << shouldUseTestingNetworkSession;
66     encoder << urlSchemesRegisteredForCustomProtocols;
67     encoder << presentingApplicationPID;
68 #if PLATFORM(COCOA)
69     encoder << uiProcessBundleIdentifier;
70     encoder << uiProcessSDKVersion;
71 #if PLATFORM(IOS_FAMILY)
72     encoder << ctDataConnectionServiceType;
73 #endif
74     encoder << httpProxy;
75     encoder << httpsProxy;
76     IPC::encode(encoder, networkATSContext.get());
77     encoder << storageAccessAPIEnabled;
78     encoder << suppressesConnectionTerminationOnSystemChange;
79 #endif
80 #if USE(SOUP)
81     encoder << cookiePersistentStoragePath;
82     encoder << cookiePersistentStorageType;
83     encoder.encodeEnum(cookieAcceptPolicy);
84     encoder << ignoreTLSErrors;
85     encoder << languages;
86     encoder << proxySettings;
87 #elif USE(CURL)
88     encoder << cookiePersistentStorageFile;
89 #endif
90
91     encoder << urlSchemesRegisteredAsSecure;
92     encoder << urlSchemesRegisteredAsBypassingContentSecurityPolicy;
93     encoder << urlSchemesRegisteredAsLocal;
94     encoder << urlSchemesRegisteredAsNoAccess;
95     encoder << urlSchemesRegisteredAsDisplayIsolated;
96     encoder << urlSchemesRegisteredAsCORSEnabled;
97     encoder << urlSchemesRegisteredAsCanDisplayOnlyIfCanRequest;
98
99 #if ENABLE(PROXIMITY_NETWORKING)
100     encoder << wirelessContextIdentifier;
101 #endif
102
103 #if ENABLE(INDEXED_DATABASE)
104     encoder << indexedDatabaseDirectory << indexedDatabaseDirectoryExtensionHandle;
105 #endif
106
107 #if ENABLE(SERVICE_WORKER)
108     encoder << serviceWorkerRegistrationDirectory << serviceWorkerRegistrationDirectoryExtensionHandle << urlSchemesServiceWorkersCanHandle << shouldDisableServiceWorkerProcessTerminationDelay;
109 #endif
110 }
111
112 bool NetworkProcessCreationParameters::decode(IPC::Decoder& decoder, NetworkProcessCreationParameters& result)
113 {
114     if (!decoder.decodeEnum(result.cacheModel))
115         return false;
116     if (!decoder.decode(result.canHandleHTTPSServerTrustEvaluation))
117         return false;
118
119     if (!decoder.decode(result.diskCacheDirectory))
120         return false;
121     
122     std::optional<SandboxExtension::Handle> diskCacheDirectoryExtensionHandle;
123     decoder >> diskCacheDirectoryExtensionHandle;
124     if (!diskCacheDirectoryExtensionHandle)
125         return false;
126     result.diskCacheDirectoryExtensionHandle = WTFMove(*diskCacheDirectoryExtensionHandle);
127
128     if (!decoder.decode(result.shouldEnableNetworkCacheEfficacyLogging))
129         return false;
130 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION)
131     if (!decoder.decode(result.shouldEnableNetworkCacheSpeculativeRevalidation))
132         return false;
133 #endif
134 #if PLATFORM(MAC)
135     if (!decoder.decode(result.uiProcessCookieStorageIdentifier))
136         return false;
137 #endif
138     if (!decoder.decode(result.defaultSessionPendingCookies))
139         return false;
140 #if PLATFORM(IOS_FAMILY)
141     std::optional<SandboxExtension::Handle> cookieStorageDirectoryExtensionHandle;
142     decoder >> cookieStorageDirectoryExtensionHandle;
143     if (!cookieStorageDirectoryExtensionHandle)
144         return false;
145     result.cookieStorageDirectoryExtensionHandle = WTFMove(*cookieStorageDirectoryExtensionHandle);
146
147     std::optional<SandboxExtension::Handle> containerCachesDirectoryExtensionHandle;
148     decoder >> containerCachesDirectoryExtensionHandle;
149     if (!containerCachesDirectoryExtensionHandle)
150         return false;
151     result.containerCachesDirectoryExtensionHandle = WTFMove(*containerCachesDirectoryExtensionHandle);
152
153     std::optional<SandboxExtension::Handle> parentBundleDirectoryExtensionHandle;
154     decoder >> parentBundleDirectoryExtensionHandle;
155     if (!parentBundleDirectoryExtensionHandle)
156         return false;
157     result.parentBundleDirectoryExtensionHandle = WTFMove(*parentBundleDirectoryExtensionHandle);
158
159 #if ENABLE(INDEXED_DATABASE)
160     std::optional<SandboxExtension::Handle> indexedDatabaseTempBlobDirectoryExtensionHandle;
161     decoder >> indexedDatabaseTempBlobDirectoryExtensionHandle;
162     if (!indexedDatabaseTempBlobDirectoryExtensionHandle)
163         return false;
164     result.indexedDatabaseTempBlobDirectoryExtensionHandle = WTFMove(*indexedDatabaseTempBlobDirectoryExtensionHandle);
165 #endif
166 #endif
167     if (!decoder.decode(result.shouldSuppressMemoryPressureHandler))
168         return false;
169     if (!decoder.decode(result.shouldUseTestingNetworkSession))
170         return false;
171     if (!decoder.decode(result.urlSchemesRegisteredForCustomProtocols))
172         return false;
173     if (!decoder.decode(result.presentingApplicationPID))
174         return false;
175 #if PLATFORM(COCOA)
176     if (!decoder.decode(result.uiProcessBundleIdentifier))
177         return false;
178     if (!decoder.decode(result.uiProcessSDKVersion))
179         return false;
180 #if PLATFORM(IOS_FAMILY)
181     if (!decoder.decode(result.ctDataConnectionServiceType))
182         return false;
183 #endif
184     if (!decoder.decode(result.httpProxy))
185         return false;
186     if (!decoder.decode(result.httpsProxy))
187         return false;
188     if (!IPC::decode(decoder, result.networkATSContext))
189         return false;
190     if (!decoder.decode(result.storageAccessAPIEnabled))
191         return false;
192     if (!decoder.decode(result.suppressesConnectionTerminationOnSystemChange))
193         return false;
194 #endif
195
196 #if USE(SOUP)
197     if (!decoder.decode(result.cookiePersistentStoragePath))
198         return false;
199     if (!decoder.decode(result.cookiePersistentStorageType))
200         return false;
201     if (!decoder.decodeEnum(result.cookieAcceptPolicy))
202         return false;
203     if (!decoder.decode(result.ignoreTLSErrors))
204         return false;
205     if (!decoder.decode(result.languages))
206         return false;
207     if (!decoder.decode(result.proxySettings))
208         return false;
209 #elif USE(CURL)
210     if (!decoder.decode(result.cookiePersistentStorageFile))
211         return false;
212 #endif
213
214     if (!decoder.decode(result.urlSchemesRegisteredAsSecure))
215         return false;
216     if (!decoder.decode(result.urlSchemesRegisteredAsBypassingContentSecurityPolicy))
217         return false;
218     if (!decoder.decode(result.urlSchemesRegisteredAsLocal))
219         return false;
220     if (!decoder.decode(result.urlSchemesRegisteredAsNoAccess))
221         return false;
222     if (!decoder.decode(result.urlSchemesRegisteredAsDisplayIsolated))
223         return false;
224     if (!decoder.decode(result.urlSchemesRegisteredAsCORSEnabled))
225         return false;
226     if (!decoder.decode(result.urlSchemesRegisteredAsCanDisplayOnlyIfCanRequest))
227         return false;
228
229 #if ENABLE(PROXIMITY_NETWORKING)
230     if (!decoder.decode(result.wirelessContextIdentifier))
231         return false;
232 #endif
233
234 #if ENABLE(INDEXED_DATABASE)
235     if (!decoder.decode(result.indexedDatabaseDirectory))
236         return false;
237     
238     std::optional<SandboxExtension::Handle> indexedDatabaseDirectoryExtensionHandle;
239     decoder >> indexedDatabaseDirectoryExtensionHandle;
240     if (!indexedDatabaseDirectoryExtensionHandle)
241         return false;
242     result.indexedDatabaseDirectoryExtensionHandle = WTFMove(*indexedDatabaseDirectoryExtensionHandle);
243 #endif
244
245 #if ENABLE(SERVICE_WORKER)
246     if (!decoder.decode(result.serviceWorkerRegistrationDirectory))
247         return false;
248     
249     std::optional<SandboxExtension::Handle> serviceWorkerRegistrationDirectoryExtensionHandle;
250     decoder >> serviceWorkerRegistrationDirectoryExtensionHandle;
251     if (!serviceWorkerRegistrationDirectoryExtensionHandle)
252         return false;
253     result.serviceWorkerRegistrationDirectoryExtensionHandle = WTFMove(*serviceWorkerRegistrationDirectoryExtensionHandle);
254     
255     if (!decoder.decode(result.urlSchemesServiceWorkersCanHandle))
256         return false;
257     
258     if (!decoder.decode(result.shouldDisableServiceWorkerProcessTerminationDelay))
259         return false;
260 #endif
261
262     return true;
263 }
264
265 } // namespace WebKit