2 * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
27 #include "NetworkSessionCreationParameters.h"
29 #include "ArgumentCoders.h"
32 #include "ArgumentCodersCF.h"
35 #if USE(CURL) || USE(SOUP)
36 #include "WebCoreArgumentCoders.h"
41 void NetworkSessionCreationParameters::encode(IPC::Encoder& encoder) const
44 encoder << boundInterfaceIdentifier;
45 encoder << allowsCellularAccess;
47 IPC::encode(encoder, proxyConfiguration.get());
48 encoder << sourceApplicationBundleIdentifier;
49 encoder << sourceApplicationSecondaryIdentifier;
50 encoder << shouldLogCookieInformation;
51 encoder << loadThrottleLatency;
53 encoder << httpsProxy;
55 #if HAVE(CFNETWORK_ALTERNATIVE_SERVICE)
56 encoder << alternativeServiceDirectory;
57 encoder << alternativeServiceDirectoryExtensionHandle;
58 encoder << http3Enabled;
60 encoder << hstsStorageDirectory;
61 encoder << hstsStorageDirectoryExtensionHandle;
63 encoder << cookiePersistentStoragePath;
64 encoder << cookiePersistentStorageType;
65 encoder << persistentCredentialStorageEnabled;
66 encoder << ignoreTLSErrors;
67 encoder << proxySettings;
70 encoder << cookiePersistentStorageFile;
71 encoder << proxySettings;
73 encoder << networkCacheDirectory << networkCacheDirectoryExtensionHandle;
75 encoder << deviceManagementRestrictionsEnabled;
76 encoder << allLoadsBlockedByDeviceManagementRestrictionsForTesting;
77 encoder << dataConnectionServiceType;
78 encoder << fastServerTrustEvaluationEnabled;
79 encoder << networkCacheSpeculativeValidationEnabled;
80 encoder << shouldUseTestingNetworkSession;
81 encoder << staleWhileRevalidateEnabled;
82 encoder << testSpeedMultiplier;
83 encoder << suppressesConnectionTerminationOnSystemChange;
84 encoder << allowsServerPreconnect;
85 encoder << requiresSecureHTTPSProxyConnection;
86 encoder << preventsSystemHTTPProxyAuthentication;
87 encoder << appHasRequestedCrossWebsiteTrackingPermission;
88 encoder << resourceLoadStatisticsParameters;
91 Optional<NetworkSessionCreationParameters> NetworkSessionCreationParameters::decode(IPC::Decoder& decoder)
93 Optional<PAL::SessionID> sessionID;
98 Optional<String> boundInterfaceIdentifier;
99 decoder >> boundInterfaceIdentifier;
100 if (!boundInterfaceIdentifier)
103 Optional<AllowsCellularAccess> allowsCellularAccess;
104 decoder >> allowsCellularAccess;
105 if (!allowsCellularAccess)
109 RetainPtr<CFDictionaryRef> proxyConfiguration;
110 if (!IPC::decode(decoder, proxyConfiguration))
113 Optional<String> sourceApplicationBundleIdentifier;
114 decoder >> sourceApplicationBundleIdentifier;
115 if (!sourceApplicationBundleIdentifier)
118 Optional<String> sourceApplicationSecondaryIdentifier;
119 decoder >> sourceApplicationSecondaryIdentifier;
120 if (!sourceApplicationSecondaryIdentifier)
123 Optional<bool> shouldLogCookieInformation;
124 decoder >> shouldLogCookieInformation;
125 if (!shouldLogCookieInformation)
128 Optional<Seconds> loadThrottleLatency;
129 decoder >> loadThrottleLatency;
130 if (!loadThrottleLatency)
133 Optional<URL> httpProxy;
134 decoder >> httpProxy;
138 Optional<URL> httpsProxy;
139 decoder >> httpsProxy;
144 #if HAVE(CFNETWORK_ALTERNATIVE_SERVICE)
145 Optional<String> alternativeServiceDirectory;
146 decoder >> alternativeServiceDirectory;
147 if (!alternativeServiceDirectory)
150 Optional<SandboxExtension::Handle> alternativeServiceDirectoryExtensionHandle;
151 decoder >> alternativeServiceDirectoryExtensionHandle;
152 if (!alternativeServiceDirectoryExtensionHandle)
155 Optional<bool> http3Enabled;
156 decoder >> http3Enabled;
161 Optional<String> hstsStorageDirectory;
162 decoder >> hstsStorageDirectory;
163 if (!hstsStorageDirectory)
166 Optional<SandboxExtension::Handle> hstsStorageDirectoryExtensionHandle;
167 decoder >> hstsStorageDirectoryExtensionHandle;
168 if (!hstsStorageDirectoryExtensionHandle)
172 Optional<String> cookiePersistentStoragePath;
173 decoder >> cookiePersistentStoragePath;
174 if (!cookiePersistentStoragePath)
177 Optional<SoupCookiePersistentStorageType> cookiePersistentStorageType;
178 decoder >> cookiePersistentStorageType;
179 if (!cookiePersistentStorageType)
182 Optional<bool> persistentCredentialStorageEnabled;
183 decoder >> persistentCredentialStorageEnabled;
184 if (!persistentCredentialStorageEnabled)
187 Optional<bool> ignoreTLSErrors;
188 decoder >> ignoreTLSErrors;
189 if (!ignoreTLSErrors)
192 Optional<WebCore::SoupNetworkProxySettings> proxySettings;
193 decoder >> proxySettings;
199 Optional<String> cookiePersistentStorageFile;
200 decoder >> cookiePersistentStorageFile;
201 if (!cookiePersistentStorageFile)
204 Optional<WebCore::CurlProxySettings> proxySettings;
205 decoder >> proxySettings;
210 Optional<String> networkCacheDirectory;
211 decoder >> networkCacheDirectory;
212 if (!networkCacheDirectory)
215 Optional<SandboxExtension::Handle> networkCacheDirectoryExtensionHandle;
216 decoder >> networkCacheDirectoryExtensionHandle;
217 if (!networkCacheDirectoryExtensionHandle)
220 Optional<bool> deviceManagementRestrictionsEnabled;
221 decoder >> deviceManagementRestrictionsEnabled;
222 if (!deviceManagementRestrictionsEnabled)
225 Optional<bool> allLoadsBlockedByDeviceManagementRestrictionsForTesting;
226 decoder >> allLoadsBlockedByDeviceManagementRestrictionsForTesting;
227 if (!allLoadsBlockedByDeviceManagementRestrictionsForTesting)
230 Optional<String> dataConnectionServiceType;
231 decoder >> dataConnectionServiceType;
232 if (!dataConnectionServiceType)
235 Optional<bool> fastServerTrustEvaluationEnabled;
236 decoder >> fastServerTrustEvaluationEnabled;
237 if (!fastServerTrustEvaluationEnabled)
240 Optional<bool> networkCacheSpeculativeValidationEnabled;
241 decoder >> networkCacheSpeculativeValidationEnabled;
242 if (!networkCacheSpeculativeValidationEnabled)
245 Optional<bool> shouldUseTestingNetworkSession;
246 decoder >> shouldUseTestingNetworkSession;
247 if (!shouldUseTestingNetworkSession)
250 Optional<bool> staleWhileRevalidateEnabled;
251 decoder >> staleWhileRevalidateEnabled;
252 if (!staleWhileRevalidateEnabled)
255 Optional<unsigned> testSpeedMultiplier;
256 decoder >> testSpeedMultiplier;
257 if (!testSpeedMultiplier)
260 Optional<bool> suppressesConnectionTerminationOnSystemChange;
261 decoder >> suppressesConnectionTerminationOnSystemChange;
262 if (!suppressesConnectionTerminationOnSystemChange)
265 Optional<bool> allowsServerPreconnect;
266 decoder >> allowsServerPreconnect;
267 if (!allowsServerPreconnect)
270 Optional<bool> requiresSecureHTTPSProxyConnection;
271 decoder >> requiresSecureHTTPSProxyConnection;
272 if (!requiresSecureHTTPSProxyConnection)
275 Optional<bool> preventsSystemHTTPProxyAuthentication;
276 decoder >> preventsSystemHTTPProxyAuthentication;
277 if (!preventsSystemHTTPProxyAuthentication)
280 Optional<bool> appHasRequestedCrossWebsiteTrackingPermission;
281 decoder >> appHasRequestedCrossWebsiteTrackingPermission;
282 if (!appHasRequestedCrossWebsiteTrackingPermission)
285 Optional<ResourceLoadStatisticsParameters> resourceLoadStatisticsParameters;
286 decoder >> resourceLoadStatisticsParameters;
287 if (!resourceLoadStatisticsParameters)
292 , WTFMove(*boundInterfaceIdentifier)
293 , WTFMove(*allowsCellularAccess)
295 , WTFMove(proxyConfiguration)
296 , WTFMove(*sourceApplicationBundleIdentifier)
297 , WTFMove(*sourceApplicationSecondaryIdentifier)
298 , WTFMove(*shouldLogCookieInformation)
299 , WTFMove(*loadThrottleLatency)
300 , WTFMove(*httpProxy)
301 , WTFMove(*httpsProxy)
303 #if HAVE(CFNETWORK_ALTERNATIVE_SERVICE)
304 , WTFMove(*alternativeServiceDirectory)
305 , WTFMove(*alternativeServiceDirectoryExtensionHandle)
306 , WTFMove(*http3Enabled)
308 , WTFMove(*hstsStorageDirectory)
309 , WTFMove(*hstsStorageDirectoryExtensionHandle)
311 , WTFMove(*cookiePersistentStoragePath)
312 , WTFMove(*cookiePersistentStorageType)
313 , WTFMove(*persistentCredentialStorageEnabled)
314 , WTFMove(*ignoreTLSErrors)
315 , WTFMove(*proxySettings)
318 , WTFMove(*cookiePersistentStorageFile)
319 , WTFMove(*proxySettings)
321 , WTFMove(*deviceManagementRestrictionsEnabled)
322 , WTFMove(*allLoadsBlockedByDeviceManagementRestrictionsForTesting)
323 , WTFMove(*networkCacheDirectory)
324 , WTFMove(*networkCacheDirectoryExtensionHandle)
325 , WTFMove(*dataConnectionServiceType)
326 , WTFMove(*fastServerTrustEvaluationEnabled)
327 , WTFMove(*networkCacheSpeculativeValidationEnabled)
328 , WTFMove(*shouldUseTestingNetworkSession)
329 , WTFMove(*staleWhileRevalidateEnabled)
330 , WTFMove(*testSpeedMultiplier)
331 , WTFMove(*suppressesConnectionTerminationOnSystemChange)
332 , WTFMove(*allowsServerPreconnect)
333 , WTFMove(*requiresSecureHTTPSProxyConnection)
334 , WTFMove(*preventsSystemHTTPProxyAuthentication)
335 , WTFMove(*appHasRequestedCrossWebsiteTrackingPermission)
336 , WTFMove(*resourceLoadStatisticsParameters)
340 } // namespace WebKit