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