2 * Copyright (C) 2012-2017 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 "NetworkProcessCreationParameters.h"
29 #include "ArgumentCoders.h"
30 #include "WebCoreArgumentCoders.h"
33 #include "ArgumentCodersCF.h"
38 NetworkProcessCreationParameters::NetworkProcessCreationParameters()
42 void NetworkProcessCreationParameters::encode(IPC::Encoder& encoder) const
44 encoder << defaultSessionParameters;
45 encoder << privateBrowsingEnabled;
46 encoder.encodeEnum(cacheModel);
47 encoder << diskCacheSizeOverride;
48 encoder << canHandleHTTPSServerTrustEvaluation;
49 encoder << cacheStorageDirectory;
50 encoder << cacheStoragePerOriginQuota;
51 encoder << cacheStorageDirectoryExtensionHandle;
52 encoder << diskCacheDirectory;
53 encoder << diskCacheDirectoryExtensionHandle;
54 encoder << shouldEnableNetworkCache;
55 encoder << shouldEnableNetworkCacheEfficacyLogging;
56 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION)
57 encoder << shouldEnableNetworkCacheSpeculativeRevalidation;
60 encoder << uiProcessCookieStorageIdentifier;
63 encoder << cookieStorageDirectoryExtensionHandle;
64 encoder << containerCachesDirectoryExtensionHandle;
65 encoder << parentBundleDirectoryExtensionHandle;
67 encoder << shouldSuppressMemoryPressureHandler;
68 encoder << shouldUseTestingNetworkSession;
69 encoder << loadThrottleLatency;
70 encoder << urlSchemesRegisteredForCustomProtocols;
71 encoder << presentingApplicationPID;
73 encoder << parentProcessName;
74 encoder << uiProcessBundleIdentifier;
75 encoder << nsURLCacheMemoryCapacity;
76 encoder << nsURLCacheDiskCapacity;
77 encoder << sourceApplicationBundleIdentifier;
78 encoder << sourceApplicationSecondaryIdentifier;
80 encoder << ctDataConnectionServiceType;
83 encoder << httpsProxy;
85 IPC::encode(encoder, networkATSContext.get());
87 encoder << cookieStoragePartitioningEnabled;
88 encoder << storageAccessAPIEnabled;
91 encoder << cookiePersistentStoragePath;
92 encoder << cookiePersistentStorageType;
93 encoder.encodeEnum(cookieAcceptPolicy);
94 encoder << ignoreTLSErrors;
96 encoder << proxySettings;
98 encoder << cookiePersistentStorageFile;
100 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED
101 encoder << logCookieInformation;
104 encoder << memoryPressureMonitorHandle;
106 #if ENABLE(NETWORK_CAPTURE)
107 encoder << recordReplayMode;
108 encoder << recordReplayCacheLocation;
111 encoder << urlSchemesRegisteredAsSecure;
112 encoder << urlSchemesRegisteredAsBypassingContentSecurityPolicy;
113 encoder << urlSchemesRegisteredAsLocal;
114 encoder << urlSchemesRegisteredAsNoAccess;
115 encoder << urlSchemesRegisteredAsDisplayIsolated;
116 encoder << urlSchemesRegisteredAsCORSEnabled;
117 encoder << urlSchemesRegisteredAsCanDisplayOnlyIfCanRequest;
120 bool NetworkProcessCreationParameters::decode(IPC::Decoder& decoder, NetworkProcessCreationParameters& result)
122 std::optional<NetworkSessionCreationParameters> defaultSessionParameters;
123 decoder >> defaultSessionParameters;
124 if (!defaultSessionParameters)
126 result.defaultSessionParameters = WTFMove(*defaultSessionParameters);
128 if (!decoder.decode(result.privateBrowsingEnabled))
130 if (!decoder.decodeEnum(result.cacheModel))
132 if (!decoder.decode(result.diskCacheSizeOverride))
134 if (!decoder.decode(result.canHandleHTTPSServerTrustEvaluation))
136 if (!decoder.decode(result.cacheStorageDirectory))
138 if (!decoder.decode(result.cacheStoragePerOriginQuota))
141 std::optional<SandboxExtension::Handle> cacheStorageDirectoryExtensionHandle;
142 decoder >> cacheStorageDirectoryExtensionHandle;
143 if (!cacheStorageDirectoryExtensionHandle)
145 result.cacheStorageDirectoryExtensionHandle = WTFMove(*cacheStorageDirectoryExtensionHandle);
147 if (!decoder.decode(result.diskCacheDirectory))
150 std::optional<SandboxExtension::Handle> diskCacheDirectoryExtensionHandle;
151 decoder >> diskCacheDirectoryExtensionHandle;
152 if (!diskCacheDirectoryExtensionHandle)
154 result.diskCacheDirectoryExtensionHandle = WTFMove(*diskCacheDirectoryExtensionHandle);
156 if (!decoder.decode(result.shouldEnableNetworkCache))
158 if (!decoder.decode(result.shouldEnableNetworkCacheEfficacyLogging))
160 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION)
161 if (!decoder.decode(result.shouldEnableNetworkCacheSpeculativeRevalidation))
165 if (!decoder.decode(result.uiProcessCookieStorageIdentifier))
169 std::optional<SandboxExtension::Handle> cookieStorageDirectoryExtensionHandle;
170 decoder >> cookieStorageDirectoryExtensionHandle;
171 if (!cookieStorageDirectoryExtensionHandle)
173 result.cookieStorageDirectoryExtensionHandle = WTFMove(*cookieStorageDirectoryExtensionHandle);
175 std::optional<SandboxExtension::Handle> containerCachesDirectoryExtensionHandle;
176 decoder >> containerCachesDirectoryExtensionHandle;
177 if (!containerCachesDirectoryExtensionHandle)
179 result.containerCachesDirectoryExtensionHandle = WTFMove(*containerCachesDirectoryExtensionHandle);
181 std::optional<SandboxExtension::Handle> parentBundleDirectoryExtensionHandle;
182 decoder >> parentBundleDirectoryExtensionHandle;
183 if (!parentBundleDirectoryExtensionHandle)
185 result.parentBundleDirectoryExtensionHandle = WTFMove(*parentBundleDirectoryExtensionHandle);
187 if (!decoder.decode(result.shouldSuppressMemoryPressureHandler))
189 if (!decoder.decode(result.shouldUseTestingNetworkSession))
191 if (!decoder.decode(result.loadThrottleLatency))
193 if (!decoder.decode(result.urlSchemesRegisteredForCustomProtocols))
195 if (!decoder.decode(result.presentingApplicationPID))
198 if (!decoder.decode(result.parentProcessName))
200 if (!decoder.decode(result.uiProcessBundleIdentifier))
202 if (!decoder.decode(result.nsURLCacheMemoryCapacity))
204 if (!decoder.decode(result.nsURLCacheDiskCapacity))
206 if (!decoder.decode(result.sourceApplicationBundleIdentifier))
208 if (!decoder.decode(result.sourceApplicationSecondaryIdentifier))
211 if (!decoder.decode(result.ctDataConnectionServiceType))
214 if (!decoder.decode(result.httpProxy))
216 if (!decoder.decode(result.httpsProxy))
219 if (!IPC::decode(decoder, result.networkATSContext))
222 if (!decoder.decode(result.cookieStoragePartitioningEnabled))
224 if (!decoder.decode(result.storageAccessAPIEnabled))
229 if (!decoder.decode(result.cookiePersistentStoragePath))
231 if (!decoder.decode(result.cookiePersistentStorageType))
233 if (!decoder.decodeEnum(result.cookieAcceptPolicy))
235 if (!decoder.decode(result.ignoreTLSErrors))
237 if (!decoder.decode(result.languages))
239 if (!decoder.decode(result.proxySettings))
242 if (!decoder.decode(result.cookiePersistentStorageFile))
246 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED
247 if (!decoder.decode(result.logCookieInformation))
252 if (!decoder.decode(result.memoryPressureMonitorHandle))
256 #if ENABLE(NETWORK_CAPTURE)
257 if (!decoder.decode(result.recordReplayMode))
259 if (!decoder.decode(result.recordReplayCacheLocation))
263 if (!decoder.decode(result.urlSchemesRegisteredAsSecure))
265 if (!decoder.decode(result.urlSchemesRegisteredAsBypassingContentSecurityPolicy))
267 if (!decoder.decode(result.urlSchemesRegisteredAsLocal))
269 if (!decoder.decode(result.urlSchemesRegisteredAsNoAccess))
271 if (!decoder.decode(result.urlSchemesRegisteredAsDisplayIsolated))
273 if (!decoder.decode(result.urlSchemesRegisteredAsCORSEnabled))
275 if (!decoder.decode(result.urlSchemesRegisteredAsCanDisplayOnlyIfCanRequest))
281 } // namespace WebKit