1/*
2 * Copyright (C) 2010, 2011 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#ifndef WKContext_h
27#define WKContext_h
28
29#include <WebKit/WKBase.h>
30#include <WebKit/WKContextConnectionClient.h>
31#include <WebKit/WKContextDownloadClient.h>
32#include <WebKit/WKContextHistoryClient.h>
33#include <WebKit/WKContextInjectedBundleClient.h>
34#include <WebKit/WKDeprecated.h>
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40enum {
41 kWKCacheModelDocumentViewer = 0,
42 kWKCacheModelDocumentBrowser = 1,
43 kWKCacheModelPrimaryWebBrowser = 2
44};
45typedef uint32_t WKCacheModel;
46
47// Context Client
48typedef void (*WKContextPlugInAutoStartOriginHashesChangedCallback)(WKContextRef context, const void *clientInfo);
49typedef void (*WKContextPlugInInformationBecameAvailableCallback)(WKContextRef context, WKArrayRef plugIn, const void *clientInfo);
50typedef WKDataRef (*WKContextCopyWebCryptoMasterKeyCallback)(WKContextRef context, const void *clientInfo);
51
52typedef void (*WKContextChildProcessDidCrashCallback)(WKContextRef context, const void *clientInfo);
53typedef WKContextChildProcessDidCrashCallback WKContextNetworkProcessDidCrashCallback;
54
55typedef struct WKContextClientBase {
56 int version;
57 const void * clientInfo;
58} WKContextClientBase;
59
60typedef struct WKContextClientV0 {
61 WKContextClientBase base;
62
63 // Version 0.
64 WKContextPlugInAutoStartOriginHashesChangedCallback plugInAutoStartOriginHashesChanged;
65 WKContextNetworkProcessDidCrashCallback networkProcessDidCrash;
66 WKContextPlugInInformationBecameAvailableCallback plugInInformationBecameAvailable;
67} WKContextClientV0;
68
69typedef struct WKContextClientV1 {
70 WKContextClientBase base;
71
72 // Version 0.
73 WKContextPlugInAutoStartOriginHashesChangedCallback plugInAutoStartOriginHashesChanged;
74 WKContextNetworkProcessDidCrashCallback networkProcessDidCrash;
75 WKContextPlugInInformationBecameAvailableCallback plugInInformationBecameAvailable;
76
77 // Version 1.
78 void (*copyWebCryptoMasterKey_unavailable)(void);
79} WKContextClientV1;
80
81typedef struct WKContextClientV2 {
82 WKContextClientBase base;
83
84 // Version 0.
85 WKContextPlugInAutoStartOriginHashesChangedCallback plugInAutoStartOriginHashesChanged;
86 WKContextNetworkProcessDidCrashCallback networkProcessDidCrash;
87 WKContextPlugInInformationBecameAvailableCallback plugInInformationBecameAvailable;
88
89 // Version 1.
90 void (*copyWebCryptoMasterKey_unavailable)(void);
91
92} WKContextClientV2;
93
94// FIXME: Remove these once support for Mavericks has been dropped.
95enum {
96 kWKProcessModelSharedSecondaryProcess = 0,
97 kWKProcessModelMultipleSecondaryProcesses = 1
98};
99typedef uint32_t WKProcessModel;
100
101enum {
102 kWKStatisticsOptionsWebContent = 1 << 0,
103 kWKStatisticsOptionsNetworking = 1 << 1
104};
105typedef uint32_t WKStatisticsOptions;
106
107WK_EXPORT WKTypeID WKContextGetTypeID();
108
109WK_EXPORT WKContextRef WKContextCreate() WK_C_API_DEPRECATED_WITH_REPLACEMENT(WKContextCreateWithConfiguration);
110WK_EXPORT WKContextRef WKContextCreateWithInjectedBundlePath(WKStringRef path) WK_C_API_DEPRECATED_WITH_REPLACEMENT(WKContextCreateWithConfiguration);
111WK_EXPORT WKContextRef WKContextCreateWithConfiguration(WKContextConfigurationRef configuration);
112
113WK_EXPORT void WKContextSetClient(WKContextRef context, const WKContextClientBase* client);
114WK_EXPORT void WKContextSetInjectedBundleClient(WKContextRef context, const WKContextInjectedBundleClientBase* client);
115WK_EXPORT void WKContextSetHistoryClient(WKContextRef context, const WKContextHistoryClientBase* client);
116WK_EXPORT void WKContextSetDownloadClient(WKContextRef context, const WKContextDownloadClientBase* client);
117WK_EXPORT void WKContextSetConnectionClient(WKContextRef context, const WKContextConnectionClientBase* client);
118
119WK_EXPORT WKDownloadRef WKContextDownloadURLRequest(WKContextRef context, WKURLRequestRef request);
120WK_EXPORT WKDownloadRef WKContextResumeDownload(WKContextRef context, WKDataRef resumeData, WKStringRef path);
121
122WK_EXPORT void WKContextSetInitializationUserDataForInjectedBundle(WKContextRef context, WKTypeRef userData);
123WK_EXPORT void WKContextPostMessageToInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody);
124
125WK_EXPORT void WKContextAddVisitedLink(WKContextRef context, WKStringRef visitedURL);
126WK_EXPORT void WKContextClearVisitedLinks(WKContextRef contextRef);
127
128WK_EXPORT void WKContextSetCacheModel(WKContextRef context, WKCacheModel cacheModel);
129WK_EXPORT WKCacheModel WKContextGetCacheModel(WKContextRef context);
130
131// FIXME: Move these to WKDeprecatedFunctions.cpp once support for Mavericks has been dropped.
132WK_EXPORT void WKContextSetProcessModel(WKContextRef, WKProcessModel);
133
134WK_EXPORT void WKContextSetMaximumNumberOfProcesses(WKContextRef context, unsigned numberOfProcesses) WK_C_API_DEPRECATED;
135WK_EXPORT unsigned WKContextGetMaximumNumberOfProcesses(WKContextRef context) WK_C_API_DEPRECATED;
136
137WK_EXPORT void WKContextSetUsesSingleWebProcess(WKContextRef, bool);
138WK_EXPORT bool WKContextGetUsesSingleWebProcess(WKContextRef);
139
140WK_EXPORT void WKContextStartMemorySampler(WKContextRef context, WKDoubleRef interval);
141WK_EXPORT void WKContextStopMemorySampler(WKContextRef context);
142
143WK_EXPORT WKWebsiteDataStoreRef WKContextGetWebsiteDataStore(WKContextRef context);
144
145WK_EXPORT WKApplicationCacheManagerRef WKContextGetApplicationCacheManager(WKContextRef context);
146WK_EXPORT WKCookieManagerRef WKContextGetCookieManager(WKContextRef context);
147WK_EXPORT WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef context);
148WK_EXPORT WKIconDatabaseRef WKContextGetIconDatabase(WKContextRef context);
149WK_EXPORT WKKeyValueStorageManagerRef WKContextGetKeyValueStorageManager(WKContextRef context);
150WK_EXPORT WKMediaSessionFocusManagerRef WKContextGetMediaSessionFocusManager(WKContextRef context);
151WK_EXPORT WKNotificationManagerRef WKContextGetNotificationManager(WKContextRef context);
152WK_EXPORT WKResourceCacheManagerRef WKContextGetResourceCacheManager(WKContextRef context);
153
154typedef void (*WKContextGetStatisticsFunction)(WKDictionaryRef statistics, WKErrorRef error, void* functionContext);
155WK_EXPORT void WKContextGetStatistics(WKContextRef context, void* functionContext, WKContextGetStatisticsFunction function);
156WK_EXPORT void WKContextGetStatisticsWithOptions(WKContextRef context, WKStatisticsOptions statisticsMask, void* functionContext, WKContextGetStatisticsFunction function);
157
158WK_EXPORT bool WKContextJavaScriptConfigurationFileEnabled(WKContextRef context);
159WK_EXPORT void WKContextSetJavaScriptConfigurationFileEnabled(WKContextRef context, bool enable);
160WK_EXPORT void WKContextGarbageCollectJavaScriptObjects(WKContextRef context);
161WK_EXPORT void WKContextSetJavaScriptGarbageCollectorTimerEnabled(WKContextRef context, bool enable);
162
163WK_EXPORT WKDictionaryRef WKContextCopyPlugInAutoStartOriginHashes(WKContextRef context);
164WK_EXPORT void WKContextSetPlugInAutoStartOriginHashes(WKContextRef context, WKDictionaryRef dictionary);
165WK_EXPORT void WKContextSetPlugInAutoStartOrigins(WKContextRef contextRef, WKArrayRef arrayRef);
166WK_EXPORT void WKContextSetPlugInAutoStartOriginsFilteringOutEntriesAddedAfterTime(WKContextRef contextRef, WKDictionaryRef dictionaryRef, double time);
167WK_EXPORT void WKContextRefreshPlugIns(WKContextRef context);
168
169WK_EXPORT void WKContextSetCustomWebContentServiceBundleIdentifier(WKContextRef contextRef, WKStringRef name);
170
171#ifdef __cplusplus
172}
173#endif
174
175#endif /* WKContext_h */
176