d26406bc80acc3c5dbd023b8d070e6ba730aec08
[WebKit-https.git] / Source / WebKit / UIProcess / Cocoa / WebProcessPoolCocoa.mm
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 #import "config.h"
27 #import "WebProcessPool.h"
28
29 #import "CookieStorageUtilsCF.h"
30 #import "LegacyCustomProtocolManagerClient.h"
31 #import "NetworkProcessCreationParameters.h"
32 #import "NetworkProcessMessages.h"
33 #import "NetworkProcessProxy.h"
34 #import "PluginProcessManager.h"
35 #import "SandboxUtilities.h"
36 #import "TextChecker.h"
37 #import "VersionChecks.h"
38 #import "WKBrowsingContextControllerInternal.h"
39 #import "WebMemoryPressureHandlerCocoa.h"
40 #import "WebPageGroup.h"
41 #import "WebPreferencesKeys.h"
42 #import "WebProcessCreationParameters.h"
43 #import "WebProcessMessages.h"
44 #import "WindowServerConnection.h"
45 #import <WebCore/Color.h>
46 #import <WebCore/FileSystem.h>
47 #import <WebCore/NetworkStorageSession.h>
48 #import <WebCore/NotImplemented.h>
49 #import <WebCore/PlatformPasteboard.h>
50 #import <WebCore/RuntimeApplicationChecks.h>
51 #import <WebCore/SharedBuffer.h>
52 #import <pal/spi/cf/CFNetworkSPI.h>
53 #import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
54 #import <sys/param.h>
55 #import <wtf/ProcessPrivilege.h>
56 #import <wtf/cocoa/Entitlements.h>
57 #import <wtf/spi/darwin/dyldSPI.h>
58
59 #if PLATFORM(MAC)
60 #import <QuartzCore/CARemoteLayerServer.h>
61 #endif
62
63 NSString *WebServiceWorkerRegistrationDirectoryDefaultsKey = @"WebServiceWorkerRegistrationDirectory";
64 NSString *WebKitLocalCacheDefaultsKey = @"WebKitLocalCache";
65 NSString *WebKitJSCJITEnabledDefaultsKey = @"WebKitJSCJITEnabledDefaultsKey";
66 NSString *WebKitJSCFTLJITEnabledDefaultsKey = @"WebKitJSCFTLJITEnabledDefaultsKey";
67
68 #if !PLATFORM(IOS_FAMILY)
69 static NSString *WebKitApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification = @"NSApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification";
70 #endif
71
72 static NSString * const WebKit2HTTPProxyDefaultsKey = @"WebKit2HTTPProxy";
73 static NSString * const WebKit2HTTPSProxyDefaultsKey = @"WebKit2HTTPSProxy";
74
75 static NSString * const WebKitNetworkCacheEfficacyLoggingEnabledDefaultsKey = @"WebKitNetworkCacheEfficacyLoggingEnabled";
76
77 static NSString * const WebKitSuppressMemoryPressureHandlerDefaultsKey = @"WebKitSuppressMemoryPressureHandler";
78
79 #if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED
80 static NSString * const WebKitLogCookieInformationDefaultsKey = @"WebKitLogCookieInformation";
81 #endif
82
83 namespace WebKit {
84 using namespace WebCore;
85
86 static void registerUserDefaultsIfNeeded()
87 {
88     static bool didRegister;
89     if (didRegister)
90         return;
91
92     didRegister = true;
93     NSMutableDictionary *registrationDictionary = [NSMutableDictionary dictionary];
94     
95     [registrationDictionary setObject:@YES forKey:WebKitJSCJITEnabledDefaultsKey];
96     [registrationDictionary setObject:@YES forKey:WebKitJSCFTLJITEnabledDefaultsKey];
97
98     [registrationDictionary setObject:@NO forKey:WebKitNetworkCacheEfficacyLoggingEnabledDefaultsKey];
99
100     [[NSUserDefaults standardUserDefaults] registerDefaults:registrationDictionary];
101 }
102
103 void WebProcessPool::updateProcessSuppressionState()
104 {
105     if (m_networkProcess)
106         m_networkProcess->setProcessSuppressionEnabled(processSuppressionEnabled());
107
108 #if ENABLE(NETSCAPE_PLUGIN_API)
109     if (!m_processSuppressionDisabledForPageCounter.value())
110         m_pluginProcessManagerProcessSuppressionDisabledToken = nullptr;
111     else if (!m_pluginProcessManagerProcessSuppressionDisabledToken)
112         m_pluginProcessManagerProcessSuppressionDisabledToken = PluginProcessManager::singleton().processSuppressionDisabledToken();
113 #endif
114 }
115
116 NSMutableDictionary *WebProcessPool::ensureBundleParameters()
117 {
118     if (!m_bundleParameters)
119         m_bundleParameters = adoptNS([[NSMutableDictionary alloc] init]);
120
121     return m_bundleParameters.get();
122 }
123
124 void WebProcessPool::platformInitialize()
125 {
126     registerUserDefaultsIfNeeded();
127     registerNotificationObservers();
128
129     installMemoryPressureHandler();
130
131     setLegacyCustomProtocolManagerClient(std::make_unique<LegacyCustomProtocolManagerClient>());
132 }
133
134 #if PLATFORM(IOS_FAMILY)
135 String WebProcessPool::cookieStorageDirectory() const
136 {
137     String path = pathForProcessContainer();
138     if (path.isEmpty())
139         path = NSHomeDirectory();
140
141     path = path + "/Library/Cookies";
142     path = stringByResolvingSymlinksInPath(path);
143     return path;
144 }
145 #endif
146
147 void WebProcessPool::platformResolvePathsForSandboxExtensions()
148 {
149     m_resolvedPaths.uiProcessBundleResourcePath = resolvePathForSandboxExtension([[NSBundle mainBundle] resourcePath]);
150
151 #if PLATFORM(IOS_FAMILY)
152     m_resolvedPaths.cookieStorageDirectory = resolveAndCreateReadWriteDirectoryForSandboxExtension(cookieStorageDirectory());
153     m_resolvedPaths.containerCachesDirectory = resolveAndCreateReadWriteDirectoryForSandboxExtension(webContentCachesDirectory());
154     m_resolvedPaths.containerTemporaryDirectory = resolveAndCreateReadWriteDirectoryForSandboxExtension(containerTemporaryDirectory());
155 #endif
156 }
157
158 void WebProcessPool::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
159 {
160 #if PLATFORM(MAC)
161     ALLOW_DEPRECATED_DECLARATIONS_BEGIN
162     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
163     parameters.accessibilityEnhancedUserInterfaceEnabled = [[NSApp accessibilityAttributeValue:@"AXEnhancedUserInterface"] boolValue];
164     ALLOW_DEPRECATED_DECLARATIONS_END
165 #else
166     parameters.accessibilityEnhancedUserInterfaceEnabled = false;
167 #endif
168
169     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
170
171     parameters.shouldEnableJIT = [defaults boolForKey:WebKitJSCJITEnabledDefaultsKey];
172     parameters.shouldEnableFTLJIT = [defaults boolForKey:WebKitJSCFTLJITEnabledDefaultsKey];
173     parameters.shouldEnableMemoryPressureReliefLogging = [defaults boolForKey:@"LogMemoryJetsamDetails"];
174     parameters.shouldSuppressMemoryPressureHandler = [defaults boolForKey:WebKitSuppressMemoryPressureHandlerDefaultsKey];
175
176 #if HAVE(HOSTED_CORE_ANIMATION)
177 #if !PLATFORM(IOS_FAMILY)
178     parameters.acceleratedCompositingPort = MachSendRight::create([CARemoteLayerServer sharedServer].serverPort);
179 #endif
180 #endif
181
182     // FIXME: This should really be configurable; we shouldn't just blindly allow read access to the UI process bundle.
183     parameters.uiProcessBundleResourcePath = m_resolvedPaths.uiProcessBundleResourcePath;
184     SandboxExtension::createHandleWithoutResolvingPath(parameters.uiProcessBundleResourcePath, SandboxExtension::Type::ReadOnly, parameters.uiProcessBundleResourcePathExtensionHandle);
185
186     parameters.uiProcessBundleIdentifier = String([[NSBundle mainBundle] bundleIdentifier]);
187     parameters.uiProcessSDKVersion = dyld_get_program_sdk_version();
188
189 #if PLATFORM(IOS_FAMILY)
190     if (!m_resolvedPaths.cookieStorageDirectory.isEmpty())
191         SandboxExtension::createHandleWithoutResolvingPath(m_resolvedPaths.cookieStorageDirectory, SandboxExtension::Type::ReadWrite, parameters.cookieStorageDirectoryExtensionHandle);
192
193     if (!m_resolvedPaths.containerCachesDirectory.isEmpty())
194         SandboxExtension::createHandleWithoutResolvingPath(m_resolvedPaths.containerCachesDirectory, SandboxExtension::Type::ReadWrite, parameters.containerCachesDirectoryExtensionHandle);
195
196     if (!m_resolvedPaths.containerTemporaryDirectory.isEmpty())
197         SandboxExtension::createHandleWithoutResolvingPath(m_resolvedPaths.containerTemporaryDirectory, SandboxExtension::Type::ReadWrite, parameters.containerTemporaryDirectoryExtensionHandle);
198 #endif
199
200     parameters.fontWhitelist = m_fontWhitelist;
201
202     if (m_bundleParameters) {
203         auto keyedArchiver = secureArchiver();
204
205         @try {
206             [keyedArchiver encodeObject:m_bundleParameters.get() forKey:@"parameters"];
207             [keyedArchiver finishEncoding];
208         } @catch (NSException *exception) {
209             LOG_ERROR("Failed to encode bundle parameters: %@", exception);
210         }
211
212         auto data = keyedArchiver.get().encodedData;
213
214         parameters.bundleParameterData = API::Data::createWithoutCopying(WTFMove(data));
215     }
216     parameters.networkATSContext = adoptCF(_CFNetworkCopyATSContext());
217
218 #if ENABLE(MEDIA_STREAM)
219     // Allow microphone access if either preference is set because WebRTC requires microphone access.
220     bool mediaDevicesEnabled = m_defaultPageGroup->preferences().mediaDevicesEnabled();
221     bool webRTCEnabled = m_defaultPageGroup->preferences().peerConnectionEnabled();
222     if ([defaults objectForKey:@"ExperimentalPeerConnectionEnabled"])
223         webRTCEnabled = [defaults boolForKey:@"ExperimentalPeerConnectionEnabled"];
224
225     bool isSafari = false;
226 #if PLATFORM(IOS_FAMILY)
227     if (WebCore::IOSApplication::isMobileSafari())
228         isSafari = true;
229 #elif PLATFORM(MAC)
230     if (WebCore::MacApplication::isSafari())
231         isSafari = true;
232 #endif
233
234 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED
235     parameters.webCoreLoggingChannels = [[NSUserDefaults standardUserDefaults] stringForKey:@"WebCoreLogging"];
236     parameters.webKitLoggingChannels = [[NSUserDefaults standardUserDefaults] stringForKey:@"WebKit2Logging"];
237 #endif
238
239     // FIXME: Remove this and related parameter when <rdar://problem/29448368> is fixed.
240     if (isSafari && !parameters.shouldCaptureAudioInUIProcess && mediaDevicesEnabled)
241         SandboxExtension::createHandleForGenericExtension("com.apple.webkit.microphone", parameters.audioCaptureExtensionHandle);
242 #endif
243
244 #if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED
245     parameters.shouldLogUserInteraction = [defaults boolForKey:WebKitLogCookieInformationDefaultsKey];
246 #endif
247     
248 #if PLATFORM(MAC)
249     auto screenProperties = WebCore::collectScreenProperties();
250     parameters.screenProperties = WTFMove(screenProperties);
251     parameters.useOverlayScrollbars = ([NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay);
252 #endif
253 }
254
255 void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationParameters& parameters)
256 {
257     parameters.uiProcessBundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
258     parameters.uiProcessSDKVersion = dyld_get_program_sdk_version();
259
260     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
261
262     parameters.httpProxy = [defaults stringForKey:WebKit2HTTPProxyDefaultsKey];
263     parameters.httpsProxy = [defaults stringForKey:WebKit2HTTPSProxyDefaultsKey];
264     parameters.networkATSContext = adoptCF(_CFNetworkCopyATSContext());
265
266     parameters.shouldEnableNetworkCacheEfficacyLogging = [defaults boolForKey:WebKitNetworkCacheEfficacyLoggingEnabledDefaultsKey];
267
268 #if PLATFORM(IOS_FAMILY)
269     parameters.ctDataConnectionServiceType = m_configuration->ctDataConnectionServiceType();
270 #endif
271
272     parameters.shouldSuppressMemoryPressureHandler = [defaults boolForKey:WebKitSuppressMemoryPressureHandlerDefaultsKey];
273
274 #if PLATFORM(MAC)
275     ASSERT(parameters.uiProcessCookieStorageIdentifier.isEmpty());
276     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies));
277     parameters.uiProcessCookieStorageIdentifier = identifyingDataFromCookieStorage([[NSHTTPCookieStorage sharedHTTPCookieStorage] _cookieStorage]);
278 #endif
279
280     parameters.storageAccessAPIEnabled = storageAccessAPIEnabled();
281     parameters.suppressesConnectionTerminationOnSystemChange = m_configuration->suppressesConnectionTerminationOnSystemChange();
282
283 #if ENABLE(PROXIMITY_NETWORKING)
284     parameters.wirelessContextIdentifier = m_configuration->wirelessContextIdentifier();
285 #endif
286 }
287
288 void WebProcessPool::platformInvalidateContext()
289 {
290     unregisterNotificationObservers();
291 }
292
293 #if PLATFORM(IOS_FAMILY)
294 String WebProcessPool::parentBundleDirectory() const
295 {
296     return [[[NSBundle mainBundle] bundlePath] stringByStandardizingPath];
297 }
298
299 String WebProcessPool::networkingCachesDirectory() const
300 {
301     String path = pathForProcessContainer();
302     if (path.isEmpty())
303         path = NSHomeDirectory();
304
305     path = path + "/Library/Caches/com.apple.WebKit.Networking/";
306     path = stringByResolvingSymlinksInPath(path);
307
308     NSError *error = nil;
309     NSString* nsPath = path;
310     if (![[NSFileManager defaultManager] createDirectoryAtPath:nsPath withIntermediateDirectories:YES attributes:nil error:&error]) {
311         NSLog(@"could not create networking caches directory \"%@\", error %@", nsPath, error);
312         return String();
313     }
314
315     return path;
316 }
317
318 String WebProcessPool::webContentCachesDirectory() const
319 {
320     String path = pathForProcessContainer();
321     if (path.isEmpty())
322         path = NSHomeDirectory();
323
324     path = path + "/Library/Caches/com.apple.WebKit.WebContent/";
325     path = stringByResolvingSymlinksInPath(path);
326
327     NSError *error = nil;
328     NSString* nsPath = path;
329     if (![[NSFileManager defaultManager] createDirectoryAtPath:nsPath withIntermediateDirectories:YES attributes:nil error:&error]) {
330         NSLog(@"could not create web content caches directory \"%@\", error %@", nsPath, error);
331         return String();
332     }
333
334     return path;
335 }
336
337 String WebProcessPool::containerTemporaryDirectory() const
338 {
339     String path = NSTemporaryDirectory();
340     return stringByResolvingSymlinksInPath(path);
341 }
342 #endif
343
344 #if PLATFORM(IOS_FAMILY)
345 void WebProcessPool::setJavaScriptConfigurationFileEnabledFromDefaults()
346 {
347     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
348
349     setJavaScriptConfigurationFileEnabled([defaults boolForKey:@"WebKitJavaScriptCoreUseConfigFile"]);
350 }
351 #endif
352
353 bool WebProcessPool::omitPDFSupport()
354 {
355     // Since this is a "secret default" we don't bother registering it.
356     return [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitOmitPDFSupport"];
357 }
358
359 bool WebProcessPool::processSuppressionEnabled() const
360 {
361     return !m_userObservablePageCounter.value() && !m_processSuppressionDisabledForPageCounter.value();
362 }
363
364 bool WebProcessPool::networkProcessHasEntitlementForTesting(const String& entitlement)
365 {
366     return WTF::hasEntitlement(ensureNetworkProcess().connection()->xpcConnection(), entitlement.utf8().data());
367 }
368
369 void WebProcessPool::registerNotificationObservers()
370 {
371 #if !PLATFORM(IOS_FAMILY)
372     // Listen for enhanced accessibility changes and propagate them to the WebProcess.
373     m_enhancedAccessibilityObserver = [[NSNotificationCenter defaultCenter] addObserverForName:WebKitApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *note) {
374         setEnhancedAccessibility([[[note userInfo] objectForKey:@"AXEnhancedUserInterface"] boolValue]);
375     }];
376
377     m_automaticTextReplacementNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSSpellCheckerDidChangeAutomaticTextReplacementNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
378         TextChecker::didChangeAutomaticTextReplacementEnabled();
379         textCheckerStateChanged();
380     }];
381     
382     m_automaticSpellingCorrectionNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSSpellCheckerDidChangeAutomaticSpellingCorrectionNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
383         TextChecker::didChangeAutomaticSpellingCorrectionEnabled();
384         textCheckerStateChanged();
385     }];
386
387     m_automaticQuoteSubstitutionNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSSpellCheckerDidChangeAutomaticQuoteSubstitutionNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
388         TextChecker::didChangeAutomaticQuoteSubstitutionEnabled();
389         textCheckerStateChanged();
390     }];
391
392     m_automaticDashSubstitutionNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSSpellCheckerDidChangeAutomaticDashSubstitutionNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
393         TextChecker::didChangeAutomaticDashSubstitutionEnabled();
394         textCheckerStateChanged();
395     }];
396
397     m_accessibilityDisplayOptionsNotificationObserver = [[NSWorkspace.sharedWorkspace notificationCenter] addObserverForName:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
398         screenPropertiesStateChanged();
399     }];
400
401 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
402     m_scrollerStyleNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSPreferredScrollerStyleDidChangeNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
403         auto scrollbarStyle = [NSScroller preferredScrollerStyle];
404         sendToAllProcesses(Messages::WebProcess::ScrollerStylePreferenceChanged(scrollbarStyle));
405     }];
406 #endif
407
408 #endif // !PLATFORM(IOS_FAMILY)
409 }
410
411 void WebProcessPool::unregisterNotificationObservers()
412 {
413 #if !PLATFORM(IOS_FAMILY)
414     [[NSNotificationCenter defaultCenter] removeObserver:m_enhancedAccessibilityObserver.get()];    
415     [[NSNotificationCenter defaultCenter] removeObserver:m_automaticTextReplacementNotificationObserver.get()];
416     [[NSNotificationCenter defaultCenter] removeObserver:m_automaticSpellingCorrectionNotificationObserver.get()];
417     [[NSNotificationCenter defaultCenter] removeObserver:m_automaticQuoteSubstitutionNotificationObserver.get()];
418     [[NSNotificationCenter defaultCenter] removeObserver:m_automaticDashSubstitutionNotificationObserver.get()];
419     [[NSWorkspace.sharedWorkspace notificationCenter] removeObserver:m_accessibilityDisplayOptionsNotificationObserver.get()];
420 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
421     [[NSNotificationCenter defaultCenter] removeObserver:m_scrollerStyleNotificationObserver.get()];
422 #endif
423 #endif // !PLATFORM(IOS_FAMILY)
424 }
425
426 static CFURLStorageSessionRef privateBrowsingSession()
427 {
428     static CFURLStorageSessionRef session;
429     static dispatch_once_t once;
430     dispatch_once(&once, ^{
431         NSString *identifier = [NSString stringWithFormat:@"%@.PrivateBrowsing", [[NSBundle mainBundle] bundleIdentifier]];
432         session = createPrivateStorageSession((__bridge CFStringRef)identifier);
433     });
434
435     return session;
436 }
437
438 bool WebProcessPool::isURLKnownHSTSHost(const String& urlString, bool privateBrowsingEnabled) const
439 {
440     RetainPtr<CFURLRef> url = URL(URL(), urlString).createCFURL();
441
442     return _CFNetworkIsKnownHSTSHostWithSession(url.get(), privateBrowsingEnabled ? privateBrowsingSession() : nullptr);
443 }
444
445 void WebProcessPool::resetHSTSHosts()
446 {
447     _CFNetworkResetHSTSHostsWithSession(nullptr);
448     _CFNetworkResetHSTSHostsWithSession(privateBrowsingSession());
449 }
450
451 void WebProcessPool::resetHSTSHostsAddedAfterDate(double startDateIntervalSince1970)
452 {
453     NSDate *startDate = [NSDate dateWithTimeIntervalSince1970:startDateIntervalSince1970];
454     _CFNetworkResetHSTSHostsSinceDate(nullptr, (__bridge CFDateRef)startDate);
455     _CFNetworkResetHSTSHostsSinceDate(privateBrowsingSession(), (__bridge CFDateRef)startDate);
456 }
457
458 // FIXME: Deprecated. Left here until a final decision is made.
459 void WebProcessPool::setCookieStoragePartitioningEnabled(bool enabled)
460 {
461     m_cookieStoragePartitioningEnabled = enabled;
462 }
463
464 void WebProcessPool::setStorageAccessAPIEnabled(bool enabled)
465 {
466     m_storageAccessAPIEnabled = enabled;
467     sendToNetworkingProcess(Messages::NetworkProcess::SetStorageAccessAPIEnabled(enabled));
468 }
469
470 int networkProcessLatencyQOS()
471 {
472     static const int qos = [[NSUserDefaults standardUserDefaults] integerForKey:@"WebKitNetworkProcessLatencyQOS"];
473     return qos;
474 }
475
476 int networkProcessThroughputQOS()
477 {
478     static const int qos = [[NSUserDefaults standardUserDefaults] integerForKey:@"WebKitNetworkProcessThroughputQOS"];
479     return qos;
480 }
481
482 int webProcessLatencyQOS()
483 {
484     static const int qos = [[NSUserDefaults standardUserDefaults] integerForKey:@"WebKitWebProcessLatencyQOS"];
485     return qos;
486 }
487
488 int webProcessThroughputQOS()
489 {
490     static const int qos = [[NSUserDefaults standardUserDefaults] integerForKey:@"WebKitWebProcessThroughputQOS"];
491     return qos;
492 }
493
494 } // namespace WebKit