[Win] WTF: Add alias for process id to use in place of direct uses of pid_t
[WebKit-https.git] / Source / WebKit / UIProcess / API / C / WKContext.cpp
1 /*
2  * Copyright (C) 2010, 2011, 2012 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 "WKContextPrivate.h"
28
29 #include "APIArray.h"
30 #include "APIClient.h"
31 #include "APIDownloadClient.h"
32 #include "APILegacyContextHistoryClient.h"
33 #include "APINavigationData.h"
34 #include "APIProcessPoolConfiguration.h"
35 #include "APIURLRequest.h"
36 #include "AuthenticationChallengeProxy.h"
37 #include "DownloadProxy.h"
38 #include "WKAPICast.h"
39 #include "WKContextConfigurationRef.h"
40 #include "WKRetainPtr.h"
41 #include "WebCertificateInfo.h"
42 #include "WebContextInjectedBundleClient.h"
43 #include "WebProcessPool.h"
44 #include <wtf/RefPtr.h>
45 #include <wtf/text/WTFString.h>
46
47 // Supplements
48 #include "WebCookieManagerProxy.h"
49 #include "WebGeolocationManagerProxy.h"
50 #include "WebNotificationManagerProxy.h"
51
52 namespace API {
53 template<> struct ClientTraits<WKContextDownloadClientBase> {
54     typedef std::tuple<WKContextDownloadClientV0, WKContextDownloadClientV1> Versions;
55 };
56 template<> struct ClientTraits<WKContextHistoryClientBase> {
57     typedef std::tuple<WKContextHistoryClientV0> Versions;
58 };
59 }
60
61 using namespace WebCore;
62 using namespace WebKit;
63
64 WKTypeID WKContextGetTypeID()
65 {
66     return toAPI(WebProcessPool::APIType);
67 }
68
69 WKContextRef WKContextCreate()
70 {
71     auto configuration = API::ProcessPoolConfiguration::createWithLegacyOptions();
72     return toAPI(&WebProcessPool::create(configuration).leakRef());
73 }
74
75 WKContextRef WKContextCreateWithInjectedBundlePath(WKStringRef pathRef)
76 {
77     auto configuration = API::ProcessPoolConfiguration::createWithLegacyOptions();
78     configuration->setInjectedBundlePath(toWTFString(pathRef));
79
80     return toAPI(&WebProcessPool::create(configuration).leakRef());
81 }
82
83 WKContextRef WKContextCreateWithConfiguration(WKContextConfigurationRef configuration)
84 {
85     return toAPI(&WebProcessPool::create(*toImpl(configuration)).leakRef());
86 }
87
88 void WKContextSetClient(WKContextRef contextRef, const WKContextClientBase* wkClient)
89 {
90     toImpl(contextRef)->initializeClient(wkClient);
91 }
92
93 void WKContextSetInjectedBundleClient(WKContextRef contextRef, const WKContextInjectedBundleClientBase* wkClient)
94 {
95     toImpl(contextRef)->setInjectedBundleClient(std::make_unique<WebContextInjectedBundleClient>(wkClient));
96 }
97
98 void WKContextSetHistoryClient(WKContextRef contextRef, const WKContextHistoryClientBase* wkClient)
99 {
100     class HistoryClient final : public API::Client<WKContextHistoryClientBase>, public API::LegacyContextHistoryClient {
101     public:
102         explicit HistoryClient(const WKContextHistoryClientBase* client)
103         {
104             initialize(client);
105         }
106
107     private:
108         void didNavigateWithNavigationData(WebProcessPool& processPool, WebPageProxy& page, const WebNavigationDataStore& navigationDataStore, WebFrameProxy& frame) override
109         {
110             if (!m_client.didNavigateWithNavigationData)
111                 return;
112
113             RefPtr<API::NavigationData> navigationData = API::NavigationData::create(navigationDataStore);
114             m_client.didNavigateWithNavigationData(toAPI(&processPool), toAPI(&page), toAPI(navigationData.get()), toAPI(&frame), m_client.base.clientInfo);
115         }
116
117         void didPerformClientRedirect(WebProcessPool& processPool, WebPageProxy& page, const String& sourceURL, const String& destinationURL, WebFrameProxy& frame) override
118         {
119             if (!m_client.didPerformClientRedirect)
120                 return;
121
122             m_client.didPerformClientRedirect(toAPI(&processPool), toAPI(&page), toURLRef(sourceURL.impl()), toURLRef(destinationURL.impl()), toAPI(&frame), m_client.base.clientInfo);
123         }
124
125         void didPerformServerRedirect(WebProcessPool& processPool, WebPageProxy& page, const String& sourceURL, const String& destinationURL, WebFrameProxy& frame) override
126         {
127             if (!m_client.didPerformServerRedirect)
128                 return;
129
130             m_client.didPerformServerRedirect(toAPI(&processPool), toAPI(&page), toURLRef(sourceURL.impl()), toURLRef(destinationURL.impl()), toAPI(&frame), m_client.base.clientInfo);
131         }
132
133         void didUpdateHistoryTitle(WebProcessPool& processPool, WebPageProxy& page, const String& title, const String& url, WebFrameProxy& frame) override
134         {
135             if (!m_client.didUpdateHistoryTitle)
136                 return;
137
138             m_client.didUpdateHistoryTitle(toAPI(&processPool), toAPI(&page), toAPI(title.impl()), toURLRef(url.impl()), toAPI(&frame), m_client.base.clientInfo);
139         }
140
141         void populateVisitedLinks(WebProcessPool& processPool) override
142         {
143             if (!m_client.populateVisitedLinks)
144                 return;
145
146             m_client.populateVisitedLinks(toAPI(&processPool), m_client.base.clientInfo);
147         }
148
149         bool addsVisitedLinks() const override
150         {
151             return m_client.populateVisitedLinks;
152         }
153     };
154
155     WebProcessPool& processPool = *toImpl(contextRef);
156     processPool.setHistoryClient(std::make_unique<HistoryClient>(wkClient));
157
158     bool addsVisitedLinks = processPool.historyClient().addsVisitedLinks();
159
160     for (auto& process : processPool.processes()) {
161         for (auto& page : process->pages())
162             page->setAddsVisitedLinks(addsVisitedLinks);
163     }
164 }
165
166 void WKContextSetDownloadClient(WKContextRef contextRef, const WKContextDownloadClientBase* wkClient)
167 {
168     class DownloadClient final : public API::Client<WKContextDownloadClientBase>, public API::DownloadClient {
169     public:
170         explicit DownloadClient(const WKContextDownloadClientBase* client)
171         {
172             initialize(client);
173         }
174     private:
175         void didStart(WebProcessPool* processPool, DownloadProxy* downloadProxy) override
176         {
177             if (!m_client.didStart)
178                 return;
179
180             m_client.didStart(toAPI(processPool), toAPI(downloadProxy), m_client.base.clientInfo);
181         }
182
183         void didReceiveAuthenticationChallenge(WebProcessPool* processPool, DownloadProxy* downloadProxy, AuthenticationChallengeProxy* authenticationChallengeProxy) override
184         {
185             if (!m_client.didReceiveAuthenticationChallenge)
186                 return;
187
188             m_client.didReceiveAuthenticationChallenge(toAPI(processPool), toAPI(downloadProxy), toAPI(authenticationChallengeProxy), m_client.base.clientInfo);
189         }
190
191         void didReceiveResponse(WebProcessPool* processPool, DownloadProxy* downloadProxy, const ResourceResponse& response) override
192         {
193             if (!m_client.didReceiveResponse)
194                 return;
195
196             m_client.didReceiveResponse(toAPI(processPool), toAPI(downloadProxy), toAPI(API::URLResponse::create(response).ptr()), m_client.base.clientInfo);
197         }
198
199         void didReceiveData(WebProcessPool* processPool, DownloadProxy* downloadProxy, uint64_t length) override
200         {
201             if (!m_client.didReceiveData)
202                 return;
203
204             m_client.didReceiveData(toAPI(processPool), toAPI(downloadProxy), length, m_client.base.clientInfo);
205         }
206
207         bool shouldDecodeSourceDataOfMIMEType(WebProcessPool* processPool, DownloadProxy* downloadProxy, const String& mimeType) override
208         {
209             if (!m_client.shouldDecodeSourceDataOfMIMEType)
210                 return true;
211
212             return m_client.shouldDecodeSourceDataOfMIMEType(toAPI(processPool), toAPI(downloadProxy), toAPI(mimeType.impl()), m_client.base.clientInfo);
213         }
214
215         String decideDestinationWithSuggestedFilename(WebProcessPool* processPool, DownloadProxy* downloadProxy, const String& filename, bool& allowOverwrite) override
216         {
217             if (!m_client.decideDestinationWithSuggestedFilename)
218                 return String();
219
220             WKRetainPtr<WKStringRef> destination(AdoptWK, m_client.decideDestinationWithSuggestedFilename(toAPI(processPool), toAPI(downloadProxy), toAPI(filename.impl()), &allowOverwrite, m_client.base.clientInfo));
221             return toWTFString(destination.get());
222         }
223
224         void didCreateDestination(WebProcessPool* processPool, DownloadProxy* downloadProxy, const String& path) override
225         {
226             if (!m_client.didCreateDestination)
227                 return;
228
229             m_client.didCreateDestination(toAPI(processPool), toAPI(downloadProxy), toAPI(path.impl()), m_client.base.clientInfo);
230         }
231
232         void didFinish(WebProcessPool* processPool, DownloadProxy* downloadProxy) override
233         {
234             if (!m_client.didFinish)
235                 return;
236
237             m_client.didFinish(toAPI(processPool), toAPI(downloadProxy), m_client.base.clientInfo);
238         }
239
240         void didFail(WebProcessPool* processPool, DownloadProxy* downloadProxy, const ResourceError& error) override
241         {
242             if (!m_client.didFail)
243                 return;
244
245             m_client.didFail(toAPI(processPool), toAPI(downloadProxy), toAPI(error), m_client.base.clientInfo);
246         }
247         
248         void didCancel(WebProcessPool* processPool, DownloadProxy* downloadProxy) override
249         {
250             if (!m_client.didCancel)
251                 return;
252             
253             m_client.didCancel(toAPI(processPool), toAPI(downloadProxy), m_client.base.clientInfo);
254         }
255         
256         void processDidCrash(WebProcessPool* processPool, DownloadProxy* downloadProxy) override
257         {
258             if (!m_client.processDidCrash)
259                 return;
260             
261             m_client.processDidCrash(toAPI(processPool), toAPI(downloadProxy), m_client.base.clientInfo);
262         }
263
264         void willSendRequest(WebProcessPool* processPool, DownloadProxy* downloadProxy, const ResourceRequest& request, const ResourceResponse&, WTF::Function<void(const ResourceRequest&)>&& callback) override
265         {
266             if (m_client.didReceiveServerRedirect)
267                 m_client.didReceiveServerRedirect(toAPI(processPool), toAPI(downloadProxy), toURLRef(request.url().string().impl()), m_client.base.clientInfo);
268
269             callback(request);
270         }
271
272
273     };
274
275     toImpl(contextRef)->setDownloadClient(std::make_unique<DownloadClient>(wkClient));
276 }
277
278 void WKContextSetConnectionClient(WKContextRef contextRef, const WKContextConnectionClientBase* wkClient)
279 {
280     toImpl(contextRef)->initializeConnectionClient(wkClient);
281 }
282
283 WKDownloadRef WKContextDownloadURLRequest(WKContextRef contextRef, WKURLRequestRef requestRef)
284 {
285     return toAPI(toImpl(contextRef)->download(0, toImpl(requestRef)->resourceRequest()));
286 }
287
288 WKDownloadRef WKContextResumeDownload(WKContextRef contextRef, WKDataRef resumeData, WKStringRef path)
289 {
290     return toAPI(toImpl(contextRef)->resumeDownload(toImpl(resumeData), toWTFString(path)));
291 }
292
293 void WKContextSetInitializationUserDataForInjectedBundle(WKContextRef contextRef,  WKTypeRef userDataRef)
294 {
295     toImpl(contextRef)->setInjectedBundleInitializationUserData(toImpl(userDataRef));
296 }
297
298 void WKContextPostMessageToInjectedBundle(WKContextRef contextRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef)
299 {
300     toImpl(contextRef)->postMessageToInjectedBundle(toImpl(messageNameRef)->string(), toImpl(messageBodyRef));
301 }
302
303 void WKContextGetGlobalStatistics(WKContextStatistics* statistics)
304 {
305     const WebProcessPool::Statistics& webContextStatistics = WebProcessPool::statistics();
306
307     statistics->wkViewCount = webContextStatistics.wkViewCount;
308     statistics->wkPageCount = webContextStatistics.wkPageCount;
309     statistics->wkFrameCount = webContextStatistics.wkFrameCount;
310 }
311
312 void WKContextAddVisitedLink(WKContextRef contextRef, WKStringRef visitedURL)
313 {
314     String visitedURLString = toImpl(visitedURL)->string();
315     if (visitedURLString.isEmpty())
316         return;
317
318     toImpl(contextRef)->visitedLinkStore().addVisitedLinkHash(visitedLinkHash(visitedURLString));
319 }
320
321 void WKContextClearVisitedLinks(WKContextRef contextRef)
322 {
323     toImpl(contextRef)->visitedLinkStore().removeAll();
324 }
325
326 void WKContextSetCacheModel(WKContextRef contextRef, WKCacheModel cacheModel)
327 {
328     toImpl(contextRef)->setCacheModel(toCacheModel(cacheModel));
329 }
330
331 WKCacheModel WKContextGetCacheModel(WKContextRef contextRef)
332 {
333     return toAPI(toImpl(contextRef)->cacheModel());
334 }
335
336 void WKContextSetMaximumNumberOfProcesses(WKContextRef contextRef, unsigned numberOfProcesses)
337 {
338     toImpl(contextRef)->setMaximumNumberOfProcesses(numberOfProcesses);
339 }
340
341 unsigned WKContextGetMaximumNumberOfProcesses(WKContextRef contextRef)
342 {
343     return toImpl(contextRef)->maximumNumberOfProcesses();
344 }
345
346 void WKContextSetAlwaysUsesComplexTextCodePath(WKContextRef contextRef, bool alwaysUseComplexTextCodePath)
347 {
348     toImpl(contextRef)->setAlwaysUsesComplexTextCodePath(alwaysUseComplexTextCodePath);
349 }
350
351 void WKContextSetShouldUseFontSmoothing(WKContextRef contextRef, bool useFontSmoothing)
352 {
353     toImpl(contextRef)->setShouldUseFontSmoothing(useFontSmoothing);
354 }
355
356 void WKContextSetAdditionalPluginsDirectory(WKContextRef contextRef, WKStringRef pluginsDirectory)
357 {
358 #if ENABLE(NETSCAPE_PLUGIN_API)
359     toImpl(contextRef)->setAdditionalPluginsDirectory(toImpl(pluginsDirectory)->string());
360 #else
361     UNUSED_PARAM(contextRef);
362     UNUSED_PARAM(pluginsDirectory);
363 #endif
364 }
365
366 void WKContextRefreshPlugIns(WKContextRef context)
367 {
368 #if ENABLE(NETSCAPE_PLUGIN_API)
369     toImpl(context)->refreshPlugins();
370 #else
371     UNUSED_PARAM(context);
372 #endif
373 }
374
375 void WKContextRegisterURLSchemeAsEmptyDocument(WKContextRef contextRef, WKStringRef urlScheme)
376 {
377     toImpl(contextRef)->registerURLSchemeAsEmptyDocument(toImpl(urlScheme)->string());
378 }
379
380 void WKContextRegisterURLSchemeAsSecure(WKContextRef contextRef, WKStringRef urlScheme)
381 {
382     toImpl(contextRef)->registerURLSchemeAsSecure(toImpl(urlScheme)->string());
383 }
384
385 void WKContextRegisterURLSchemeAsBypassingContentSecurityPolicy(WKContextRef contextRef, WKStringRef urlScheme)
386 {
387     toImpl(contextRef)->registerURLSchemeAsBypassingContentSecurityPolicy(toImpl(urlScheme)->string());
388 }
389
390 void WKContextRegisterURLSchemeAsCachePartitioned(WKContextRef contextRef, WKStringRef urlScheme)
391 {
392     toImpl(contextRef)->registerURLSchemeAsCachePartitioned(toImpl(urlScheme)->string());
393 }
394
395 void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef contextRef, WKStringRef urlScheme)
396 {
397     toImpl(contextRef)->setDomainRelaxationForbiddenForURLScheme(toImpl(urlScheme)->string());
398 }
399
400 void WKContextSetCanHandleHTTPSServerTrustEvaluation(WKContextRef contextRef, bool value)
401 {
402     toImpl(contextRef)->setCanHandleHTTPSServerTrustEvaluation(value);
403 }
404
405 void WKContextSetDiskCacheSpeculativeValidationEnabled(WKContextRef contextRef, bool value)
406 {
407     toImpl(contextRef)->configuration().setDiskCacheSpeculativeValidationEnabled(value);
408 }
409
410 WKCookieManagerRef WKContextGetCookieManager(WKContextRef contextRef)
411 {
412     return toAPI(toImpl(contextRef)->supplement<WebCookieManagerProxy>());
413 }
414
415 WKWebsiteDataStoreRef WKContextGetWebsiteDataStore(WKContextRef context)
416 {
417     auto* dataStore = toImpl(context)->websiteDataStore();
418     if (!dataStore) {
419         auto defaultDataStore = API::WebsiteDataStore::defaultDataStore();
420         toImpl(context)->setPrimaryDataStore(defaultDataStore.get());
421         dataStore = defaultDataStore.ptr();
422     }
423
424     return toAPI(dataStore);
425 }
426
427 WKApplicationCacheManagerRef WKContextGetApplicationCacheManager(WKContextRef context)
428 {
429     return reinterpret_cast<WKApplicationCacheManagerRef>(WKContextGetWebsiteDataStore(context));
430 }
431
432 WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef contextRef)
433 {
434     return toAPI(toImpl(contextRef)->supplement<WebGeolocationManagerProxy>());
435 }
436
437 WKIconDatabaseRef WKContextGetIconDatabase(WKContextRef)
438 {
439     return nullptr;
440 }
441
442 WKKeyValueStorageManagerRef WKContextGetKeyValueStorageManager(WKContextRef context)
443 {
444     return reinterpret_cast<WKKeyValueStorageManagerRef>(WKContextGetWebsiteDataStore(context));
445 }
446
447 WKMediaSessionFocusManagerRef WKContextGetMediaSessionFocusManager(WKContextRef context)
448 {
449 #if ENABLE(MEDIA_SESSION)
450     return toAPI(toImpl(context)->supplement<WebMediaSessionFocusManager>());
451 #else
452     UNUSED_PARAM(context);
453     return nullptr;
454 #endif
455 }
456
457 WKNotificationManagerRef WKContextGetNotificationManager(WKContextRef contextRef)
458 {
459     return toAPI(toImpl(contextRef)->supplement<WebNotificationManagerProxy>());
460 }
461
462 WKResourceCacheManagerRef WKContextGetResourceCacheManager(WKContextRef context)
463 {
464     return reinterpret_cast<WKResourceCacheManagerRef>(WKContextGetWebsiteDataStore(context));
465 }
466
467 void WKContextStartMemorySampler(WKContextRef contextRef, WKDoubleRef interval)
468 {
469     toImpl(contextRef)->startMemorySampler(toImpl(interval)->value());
470 }
471
472 void WKContextStopMemorySampler(WKContextRef contextRef)
473 {
474     toImpl(contextRef)->stopMemorySampler();
475 }
476
477 void WKContextSetIconDatabasePath(WKContextRef, WKStringRef)
478 {
479 }
480
481 void WKContextAllowSpecificHTTPSCertificateForHost(WKContextRef contextRef, WKCertificateInfoRef certificateRef, WKStringRef hostRef)
482 {
483     toImpl(contextRef)->allowSpecificHTTPSCertificateForHost(toImpl(certificateRef), toImpl(hostRef)->string());
484 }
485
486 WK_EXPORT void WKContextSetCookieStorageDirectory(WKContextRef contextRef, WKStringRef cookieStorageDirectory)
487 {
488     toImpl(contextRef)->setCookieStorageDirectory(toImpl(cookieStorageDirectory)->string());
489 }
490
491 void WKContextDisableProcessTermination(WKContextRef contextRef)
492 {
493     toImpl(contextRef)->disableProcessTermination();
494 }
495
496 void WKContextEnableProcessTermination(WKContextRef contextRef)
497 {
498     toImpl(contextRef)->enableProcessTermination();
499 }
500
501 void WKContextSetHTTPPipeliningEnabled(WKContextRef contextRef, bool enabled)
502 {
503     toImpl(contextRef)->setHTTPPipeliningEnabled(enabled);
504 }
505
506 void WKContextWarmInitialProcess(WKContextRef contextRef)
507 {
508     toImpl(contextRef)->warmInitialProcess();
509 }
510
511 void WKContextGetStatistics(WKContextRef contextRef, void* context, WKContextGetStatisticsFunction callback)
512 {
513     toImpl(contextRef)->getStatistics(0xFFFFFFFF, toGenericCallbackFunction(context, callback));
514 }
515
516 void WKContextGetStatisticsWithOptions(WKContextRef contextRef, WKStatisticsOptions optionsMask, void* context, WKContextGetStatisticsFunction callback)
517 {
518     toImpl(contextRef)->getStatistics(optionsMask, toGenericCallbackFunction(context, callback));
519 }
520
521 bool WKContextJavaScriptConfigurationFileEnabled(WKContextRef contextRef)
522 {
523     return toImpl(contextRef)->javaScriptConfigurationFileEnabled();
524 }
525
526 void WKContextSetJavaScriptConfigurationFileEnabled(WKContextRef contextRef, bool enable)
527 {
528     toImpl(contextRef)->setJavaScriptConfigurationFileEnabled(enable);
529 }
530
531 void WKContextGarbageCollectJavaScriptObjects(WKContextRef contextRef)
532 {
533     toImpl(contextRef)->garbageCollectJavaScriptObjects();
534 }
535
536 void WKContextSetJavaScriptGarbageCollectorTimerEnabled(WKContextRef contextRef, bool enable)
537 {
538     toImpl(contextRef)->setJavaScriptGarbageCollectorTimerEnabled(enable);
539 }
540
541 void WKContextUseTestingNetworkSession(WKContextRef context)
542 {
543     toImpl(context)->useTestingNetworkSession();
544 }
545
546 void WKContextSetAllowsAnySSLCertificateForWebSocketTesting(WKContextRef context, bool allows)
547 {
548     toImpl(context)->setAllowsAnySSLCertificateForWebSocket(allows);
549 }
550
551 void WKContextClearCachedCredentials(WKContextRef context)
552 {
553     toImpl(context)->clearCachedCredentials();
554 }
555
556 WKDictionaryRef WKContextCopyPlugInAutoStartOriginHashes(WKContextRef contextRef)
557 {
558     return toAPI(&toImpl(contextRef)->plugInAutoStartOriginHashes().leakRef());
559 }
560
561 void WKContextSetPlugInAutoStartOriginHashes(WKContextRef contextRef, WKDictionaryRef dictionaryRef)
562 {
563     if (!dictionaryRef)
564         return;
565     toImpl(contextRef)->setPlugInAutoStartOriginHashes(*toImpl(dictionaryRef));
566 }
567
568 void WKContextSetPlugInAutoStartOriginsFilteringOutEntriesAddedAfterTime(WKContextRef contextRef, WKDictionaryRef dictionaryRef, double time)
569 {
570     if (!dictionaryRef)
571         return;
572     toImpl(contextRef)->setPlugInAutoStartOriginsFilteringOutEntriesAddedAfterTime(*toImpl(dictionaryRef), time);
573 }
574
575 void WKContextSetPlugInAutoStartOrigins(WKContextRef contextRef, WKArrayRef arrayRef)
576 {
577     if (!arrayRef)
578         return;
579     toImpl(contextRef)->setPlugInAutoStartOrigins(*toImpl(arrayRef));
580 }
581
582 void WKContextSetInvalidMessageFunction(WKContextInvalidMessageFunction invalidMessageFunction)
583 {
584     WebProcessPool::setInvalidMessageCallback(invalidMessageFunction);
585 }
586
587 void WKContextSetMemoryCacheDisabled(WKContextRef contextRef, bool disabled)
588 {
589     toImpl(contextRef)->setMemoryCacheDisabled(disabled);
590 }
591
592 void WKContextSetFontWhitelist(WKContextRef contextRef, WKArrayRef arrayRef)
593 {
594     toImpl(contextRef)->setFontWhitelist(toImpl(arrayRef));
595 }
596
597 void WKContextTerminateNetworkProcess(WKContextRef context)
598 {
599     toImpl(context)->terminateNetworkProcess();
600 }
601
602 ProcessID WKContextGetNetworkProcessIdentifier(WKContextRef contextRef)
603 {
604     return toImpl(contextRef)->networkProcessIdentifier();
605 }
606
607 ProcessID WKContextGetDatabaseProcessIdentifier(WKContextRef contextRef)
608 {
609     return toImpl(contextRef)->storageProcessIdentifier();
610 }