| 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 | #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) |
| 49 | encoder << shouldEnableNetworkCacheSpeculativeRevalidation; |
| 50 | #endif |
| 51 | #if PLATFORM(MAC) |
| 52 | encoder << uiProcessCookieStorageIdentifier; |
| 53 | #endif |
| 54 | #if PLATFORM(IOS_FAMILY) |
| 55 | encoder << cookieStorageDirectoryExtensionHandle; |
| 56 | encoder << containerCachesDirectoryExtensionHandle; |
| 57 | encoder << parentBundleDirectoryExtensionHandle; |
| 58 | #endif |
| 59 | encoder << shouldSuppressMemoryPressureHandler; |
| 60 | encoder << shouldUseTestingNetworkSession; |
| 61 | encoder << urlSchemesRegisteredForCustomProtocols; |
| 62 | #if PLATFORM(COCOA) |
| 63 | encoder << uiProcessBundleIdentifier; |
| 64 | encoder << uiProcessSDKVersion; |
| 65 | #if PLATFORM(IOS_FAMILY) |
| 66 | encoder << ctDataConnectionServiceType; |
| 67 | #endif |
| 68 | IPC::encode(encoder, networkATSContext.get()); |
| 69 | encoder << storageAccessAPIEnabled; |
| 70 | encoder << suppressesConnectionTerminationOnSystemChange; |
| 71 | #endif |
| 72 | encoder << defaultDataStoreParameters; |
| 73 | #if USE(SOUP) |
| 74 | encoder.encodeEnum(cookieAcceptPolicy); |
| 75 | encoder << ignoreTLSErrors; |
| 76 | encoder << languages; |
| 77 | encoder << proxySettings; |
| 78 | #endif |
| 79 | |
| 80 | encoder << urlSchemesRegisteredAsSecure; |
| 81 | encoder << urlSchemesRegisteredAsBypassingContentSecurityPolicy; |
| 82 | encoder << urlSchemesRegisteredAsLocal; |
| 83 | encoder << urlSchemesRegisteredAsNoAccess; |
| 84 | encoder << urlSchemesRegisteredAsDisplayIsolated; |
| 85 | encoder << urlSchemesRegisteredAsCORSEnabled; |
| 86 | encoder << urlSchemesRegisteredAsCanDisplayOnlyIfCanRequest; |
| 87 | |
| 88 | #if ENABLE(SERVICE_WORKER) |
| 89 | encoder << serviceWorkerRegistrationDirectory << serviceWorkerRegistrationDirectoryExtensionHandle << urlSchemesServiceWorkersCanHandle << shouldDisableServiceWorkerProcessTerminationDelay; |
| 90 | #endif |
| 91 | encoder << shouldEnableITPDatabase; |
| 92 | encoder << downloadMonitorSpeedMultiplier; |
| 93 | encoder << isITPFirstPartyWebsiteDataRemovalEnabled; |
| 94 | encoder << enableAdClickAttributionDebugMode; |
| 95 | encoder << hstsStorageDirectory; |
| 96 | encoder << hstsStorageDirectoryExtensionHandle; |
| 97 | } |
| 98 | |
| 99 | bool NetworkProcessCreationParameters::decode(IPC::Decoder& decoder, NetworkProcessCreationParameters& result) |
| 100 | { |
| 101 | if (!decoder.decodeEnum(result.cacheModel)) |
| 102 | return false; |
| 103 | if (!decoder.decode(result.canHandleHTTPSServerTrustEvaluation)) |
| 104 | return false; |
| 105 | |
| 106 | if (!decoder.decode(result.diskCacheDirectory)) |
| 107 | return false; |
| 108 | |
| 109 | Optional<SandboxExtension::Handle> diskCacheDirectoryExtensionHandle; |
| 110 | decoder >> diskCacheDirectoryExtensionHandle; |
| 111 | if (!diskCacheDirectoryExtensionHandle) |
| 112 | return false; |
| 113 | result.diskCacheDirectoryExtensionHandle = WTFMove(*diskCacheDirectoryExtensionHandle); |
| 114 | |
| 115 | #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) |
| 116 | if (!decoder.decode(result.shouldEnableNetworkCacheSpeculativeRevalidation)) |
| 117 | return false; |
| 118 | #endif |
| 119 | #if PLATFORM(MAC) |
| 120 | if (!decoder.decode(result.uiProcessCookieStorageIdentifier)) |
| 121 | return false; |
| 122 | #endif |
| 123 | #if PLATFORM(IOS_FAMILY) |
| 124 | Optional<SandboxExtension::Handle> cookieStorageDirectoryExtensionHandle; |
| 125 | decoder >> cookieStorageDirectoryExtensionHandle; |
| 126 | if (!cookieStorageDirectoryExtensionHandle) |
| 127 | return false; |
| 128 | result.cookieStorageDirectoryExtensionHandle = WTFMove(*cookieStorageDirectoryExtensionHandle); |
| 129 | |
| 130 | Optional<SandboxExtension::Handle> containerCachesDirectoryExtensionHandle; |
| 131 | decoder >> containerCachesDirectoryExtensionHandle; |
| 132 | if (!containerCachesDirectoryExtensionHandle) |
| 133 | return false; |
| 134 | result.containerCachesDirectoryExtensionHandle = WTFMove(*containerCachesDirectoryExtensionHandle); |
| 135 | |
| 136 | Optional<SandboxExtension::Handle> parentBundleDirectoryExtensionHandle; |
| 137 | decoder >> parentBundleDirectoryExtensionHandle; |
| 138 | if (!parentBundleDirectoryExtensionHandle) |
| 139 | return false; |
| 140 | result.parentBundleDirectoryExtensionHandle = WTFMove(*parentBundleDirectoryExtensionHandle); |
| 141 | #endif |
| 142 | if (!decoder.decode(result.shouldSuppressMemoryPressureHandler)) |
| 143 | return false; |
| 144 | if (!decoder.decode(result.shouldUseTestingNetworkSession)) |
| 145 | return false; |
| 146 | if (!decoder.decode(result.urlSchemesRegisteredForCustomProtocols)) |
| 147 | return false; |
| 148 | #if PLATFORM(COCOA) |
| 149 | if (!decoder.decode(result.uiProcessBundleIdentifier)) |
| 150 | return false; |
| 151 | if (!decoder.decode(result.uiProcessSDKVersion)) |
| 152 | return false; |
| 153 | #if PLATFORM(IOS_FAMILY) |
| 154 | if (!decoder.decode(result.ctDataConnectionServiceType)) |
| 155 | return false; |
| 156 | #endif |
| 157 | if (!IPC::decode(decoder, result.networkATSContext)) |
| 158 | return false; |
| 159 | if (!decoder.decode(result.storageAccessAPIEnabled)) |
| 160 | return false; |
| 161 | if (!decoder.decode(result.suppressesConnectionTerminationOnSystemChange)) |
| 162 | return false; |
| 163 | #endif |
| 164 | |
| 165 | Optional<WebsiteDataStoreParameters> defaultDataStoreParameters; |
| 166 | decoder >> defaultDataStoreParameters; |
| 167 | if (!defaultDataStoreParameters) |
| 168 | return false; |
| 169 | result.defaultDataStoreParameters = WTFMove(*defaultDataStoreParameters); |
| 170 | |
| 171 | #if USE(SOUP) |
| 172 | if (!decoder.decodeEnum(result.cookieAcceptPolicy)) |
| 173 | return false; |
| 174 | if (!decoder.decode(result.ignoreTLSErrors)) |
| 175 | return false; |
| 176 | if (!decoder.decode(result.languages)) |
| 177 | return false; |
| 178 | if (!decoder.decode(result.proxySettings)) |
| 179 | return false; |
| 180 | #endif |
| 181 | |
| 182 | if (!decoder.decode(result.urlSchemesRegisteredAsSecure)) |
| 183 | return false; |
| 184 | if (!decoder.decode(result.urlSchemesRegisteredAsBypassingContentSecurityPolicy)) |
| 185 | return false; |
| 186 | if (!decoder.decode(result.urlSchemesRegisteredAsLocal)) |
| 187 | return false; |
| 188 | if (!decoder.decode(result.urlSchemesRegisteredAsNoAccess)) |
| 189 | return false; |
| 190 | if (!decoder.decode(result.urlSchemesRegisteredAsDisplayIsolated)) |
| 191 | return false; |
| 192 | if (!decoder.decode(result.urlSchemesRegisteredAsCORSEnabled)) |
| 193 | return false; |
| 194 | if (!decoder.decode(result.urlSchemesRegisteredAsCanDisplayOnlyIfCanRequest)) |
| 195 | return false; |
| 196 | |
| 197 | #if ENABLE(SERVICE_WORKER) |
| 198 | if (!decoder.decode(result.serviceWorkerRegistrationDirectory)) |
| 199 | return false; |
| 200 | |
| 201 | Optional<SandboxExtension::Handle> serviceWorkerRegistrationDirectoryExtensionHandle; |
| 202 | decoder >> serviceWorkerRegistrationDirectoryExtensionHandle; |
| 203 | if (!serviceWorkerRegistrationDirectoryExtensionHandle) |
| 204 | return false; |
| 205 | result.serviceWorkerRegistrationDirectoryExtensionHandle = WTFMove(*serviceWorkerRegistrationDirectoryExtensionHandle); |
| 206 | |
| 207 | if (!decoder.decode(result.urlSchemesServiceWorkersCanHandle)) |
| 208 | return false; |
| 209 | |
| 210 | if (!decoder.decode(result.shouldDisableServiceWorkerProcessTerminationDelay)) |
| 211 | return false; |
| 212 | #endif |
| 213 | |
| 214 | if (!decoder.decode(result.shouldEnableITPDatabase)) |
| 215 | return false; |
| 216 | |
| 217 | Optional<uint32_t> downloadMonitorSpeedMultiplier; |
| 218 | decoder >> downloadMonitorSpeedMultiplier; |
| 219 | if (!downloadMonitorSpeedMultiplier) |
| 220 | return false; |
| 221 | result.downloadMonitorSpeedMultiplier = *downloadMonitorSpeedMultiplier; |
| 222 | |
| 223 | if (!decoder.decode(result.isITPFirstPartyWebsiteDataRemovalEnabled)) |
| 224 | return false; |
| 225 | |
| 226 | if (!decoder.decode(result.enableAdClickAttributionDebugMode)) |
| 227 | return false; |
| 228 | |
| 229 | if (!decoder.decode(result.hstsStorageDirectory)) |
| 230 | return false; |
| 231 | |
| 232 | if (!decoder.decode(result.hstsStorageDirectoryExtensionHandle)) |
| 233 | return false; |
| 234 | |
| 235 | return true; |
| 236 | } |
| 237 | |
| 238 | } // namespace WebKit |
| 239 | |