1 | /* |
2 | * Copyright (C) 2011 Igalia S.L. |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Library General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Library General Public License |
15 | * along with this library; see the file COPYING.LIB. If not, write to |
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | * Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) |
21 | #error "Only <webkit2/webkit2.h> can be included directly." |
22 | #endif |
23 | |
24 | #ifndef WebKitWebContext_h |
25 | #define WebKitWebContext_h |
26 | |
27 | #include <glib-object.h> |
28 | #include <webkit2/WebKitAutomationSession.h> |
29 | #include <webkit2/WebKitCookieManager.h> |
30 | #include <webkit2/WebKitDefines.h> |
31 | #include <webkit2/WebKitDownload.h> |
32 | #include <webkit2/WebKitFaviconDatabase.h> |
33 | #include <webkit2/WebKitGeolocationManager.h> |
34 | #include <webkit2/WebKitNetworkProxySettings.h> |
35 | #include <webkit2/WebKitSecurityManager.h> |
36 | #include <webkit2/WebKitURISchemeRequest.h> |
37 | #include <webkit2/WebKitWebsiteDataManager.h> |
38 | |
39 | G_BEGIN_DECLS |
40 | |
41 | #define WEBKIT_TYPE_WEB_CONTEXT (webkit_web_context_get_type()) |
42 | #define WEBKIT_WEB_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_CONTEXT, WebKitWebContext)) |
43 | #define WEBKIT_WEB_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_CONTEXT, WebKitWebContextClass)) |
44 | #define WEBKIT_IS_WEB_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_CONTEXT)) |
45 | #define WEBKIT_IS_WEB_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_CONTEXT)) |
46 | #define WEBKIT_WEB_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_CONTEXT, WebKitWebContextClass)) |
47 | |
48 | /** |
49 | * WebKitCacheModel: |
50 | * @WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER: Disable the cache completely, which |
51 | * substantially reduces memory usage. Useful for applications that only |
52 | * access a single local file, with no navigation to other pages. No remote |
53 | * resources will be cached. |
54 | * @WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER: A cache model optimized for viewing |
55 | * a series of local files -- for example, a documentation viewer or a website |
56 | * designer. WebKit will cache a moderate number of resources. |
57 | * @WEBKIT_CACHE_MODEL_WEB_BROWSER: Improve document load speed substantially |
58 | * by caching a very large number of resources and previously viewed content. |
59 | * |
60 | * Enum values used for determining the #WebKitWebContext cache model. |
61 | */ |
62 | typedef enum { |
63 | WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER, |
64 | WEBKIT_CACHE_MODEL_WEB_BROWSER, |
65 | WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER |
66 | } WebKitCacheModel; |
67 | |
68 | /** |
69 | * WebKitProcessModel: |
70 | * @WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS: Use a single process to |
71 | * perform content rendering. The process is shared among all the |
72 | * #WebKitWebView instances created by the application: if the process |
73 | * hangs or crashes all the web views in the application will be affected. |
74 | * This is the default process model, and it should suffice for most cases. |
75 | * @WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES: Use one process |
76 | * for each #WebKitWebView, while still allowing for some of them to |
77 | * share a process in certain situations. The main advantage |
78 | * of this process model is that the rendering process for a web view |
79 | * can crash while the rest of the views keep working normally. This |
80 | * process model is indicated for applications which may use a number |
81 | * of web views and the content of in each must not interfere with the |
82 | * rest — for example a full-fledged web browser with support for |
83 | * multiple tabs. |
84 | * |
85 | * Enum values used for determining the #WebKitWebContext process model. |
86 | * |
87 | * Since: 2.4 |
88 | */ |
89 | typedef enum { |
90 | WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS, |
91 | WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES, |
92 | } WebKitProcessModel; |
93 | |
94 | /** |
95 | * WebKitTLSErrorsPolicy: |
96 | * @WEBKIT_TLS_ERRORS_POLICY_IGNORE: Ignore TLS errors. |
97 | * @WEBKIT_TLS_ERRORS_POLICY_FAIL: TLS errors will emit |
98 | * #WebKitWebView::load-failed-with-tls-errors and, if the signal is handled, |
99 | * finish the load. In case the signal is not handled, |
100 | * #WebKitWebView::load-failed is emitted before the load finishes. |
101 | * |
102 | * Enum values used to denote the TLS errors policy. |
103 | */ |
104 | typedef enum { |
105 | WEBKIT_TLS_ERRORS_POLICY_IGNORE, |
106 | WEBKIT_TLS_ERRORS_POLICY_FAIL |
107 | } WebKitTLSErrorsPolicy; |
108 | |
109 | /** |
110 | * WebKitNetworkProxyMode: |
111 | * @WEBKIT_NETWORK_PROXY_MODE_DEFAULT: Use the default proxy of the system. |
112 | * @WEBKIT_NETWORK_PROXY_MODE_NO_PROXY: Do not use any proxy. |
113 | * @WEBKIT_NETWORK_PROXY_MODE_CUSTOM: Use custom proxy settings. |
114 | * |
115 | * Enum values used to set the network proxy mode. |
116 | * |
117 | * Since: 2.16 |
118 | */ |
119 | typedef enum { |
120 | WEBKIT_NETWORK_PROXY_MODE_DEFAULT, |
121 | WEBKIT_NETWORK_PROXY_MODE_NO_PROXY, |
122 | WEBKIT_NETWORK_PROXY_MODE_CUSTOM |
123 | } WebKitNetworkProxyMode; |
124 | |
125 | /** |
126 | * WebKitURISchemeRequestCallback: |
127 | * @request: the #WebKitURISchemeRequest |
128 | * @user_data: user data passed to the callback |
129 | * |
130 | * Type definition for a function that will be called back when an URI request is |
131 | * made for a user registered URI scheme. |
132 | */ |
133 | typedef void (* WebKitURISchemeRequestCallback) (WebKitURISchemeRequest *request, |
134 | gpointer user_data); |
135 | |
136 | typedef struct _WebKitWebContext WebKitWebContext; |
137 | typedef struct _WebKitWebContextClass WebKitWebContextClass; |
138 | typedef struct _WebKitWebContextPrivate WebKitWebContextPrivate; |
139 | |
140 | struct _WebKitWebContext { |
141 | GObject parent; |
142 | |
143 | /*< private >*/ |
144 | WebKitWebContextPrivate *priv; |
145 | }; |
146 | |
147 | struct _WebKitWebContextClass { |
148 | GObjectClass parent; |
149 | |
150 | void (* download_started) (WebKitWebContext *context, |
151 | WebKitDownload *download); |
152 | void (* initialize_web_extensions) (WebKitWebContext *context); |
153 | void (* initialize_notification_permissions) (WebKitWebContext *context); |
154 | void (* automation_started) (WebKitWebContext *context, |
155 | WebKitAutomationSession *session); |
156 | |
157 | void (*_webkit_reserved0) (void); |
158 | void (*_webkit_reserved1) (void); |
159 | void (*_webkit_reserved2) (void); |
160 | void (*_webkit_reserved3) (void); |
161 | }; |
162 | |
163 | WEBKIT_API GType |
164 | webkit_web_context_get_type (void); |
165 | |
166 | WEBKIT_API WebKitWebContext * |
167 | webkit_web_context_get_default (void); |
168 | |
169 | WEBKIT_API WebKitWebContext * |
170 | webkit_web_context_new (void); |
171 | |
172 | WEBKIT_API WebKitWebContext * |
173 | webkit_web_context_new_ephemeral (void); |
174 | |
175 | WEBKIT_API WebKitWebContext * |
176 | webkit_web_context_new_with_website_data_manager (WebKitWebsiteDataManager *manager); |
177 | |
178 | WEBKIT_API WebKitWebsiteDataManager * |
179 | webkit_web_context_get_website_data_manager (WebKitWebContext *context); |
180 | |
181 | WEBKIT_API gboolean |
182 | webkit_web_context_is_ephemeral (WebKitWebContext *context); |
183 | |
184 | WEBKIT_API gboolean |
185 | webkit_web_context_is_automation_allowed (WebKitWebContext *context); |
186 | |
187 | WEBKIT_API void |
188 | webkit_web_context_set_automation_allowed (WebKitWebContext *context, |
189 | gboolean allowed); |
190 | WEBKIT_API void |
191 | webkit_web_context_set_cache_model (WebKitWebContext *context, |
192 | WebKitCacheModel cache_model); |
193 | WEBKIT_API WebKitCacheModel |
194 | webkit_web_context_get_cache_model (WebKitWebContext *context); |
195 | |
196 | WEBKIT_API void |
197 | webkit_web_context_set_web_process_count_limit (WebKitWebContext *context, |
198 | guint limit); |
199 | |
200 | WEBKIT_API guint |
201 | webkit_web_context_get_web_process_count_limit (WebKitWebContext *context); |
202 | |
203 | WEBKIT_API void |
204 | webkit_web_context_clear_cache (WebKitWebContext *context); |
205 | |
206 | WEBKIT_API void |
207 | webkit_web_context_set_network_proxy_settings (WebKitWebContext *context, |
208 | WebKitNetworkProxyMode proxy_mode, |
209 | WebKitNetworkProxySettings *proxy_settings); |
210 | |
211 | WEBKIT_API WebKitDownload * |
212 | webkit_web_context_download_uri (WebKitWebContext *context, |
213 | const gchar *uri); |
214 | |
215 | WEBKIT_API WebKitCookieManager * |
216 | webkit_web_context_get_cookie_manager (WebKitWebContext *context); |
217 | |
218 | WEBKIT_API WebKitGeolocationManager * |
219 | webkit_web_context_get_geolocation_manager (WebKitWebContext *context); |
220 | |
221 | WEBKIT_API WebKitFaviconDatabase * |
222 | webkit_web_context_get_favicon_database (WebKitWebContext *context); |
223 | |
224 | WEBKIT_API void |
225 | webkit_web_context_set_favicon_database_directory (WebKitWebContext *context, |
226 | const gchar *path); |
227 | WEBKIT_API const gchar * |
228 | webkit_web_context_get_favicon_database_directory (WebKitWebContext *context); |
229 | |
230 | WEBKIT_API WebKitSecurityManager * |
231 | webkit_web_context_get_security_manager (WebKitWebContext *context); |
232 | |
233 | WEBKIT_API void |
234 | webkit_web_context_set_additional_plugins_directory (WebKitWebContext *context, |
235 | const gchar *directory); |
236 | |
237 | WEBKIT_API void |
238 | webkit_web_context_get_plugins (WebKitWebContext *context, |
239 | GCancellable *cancellable, |
240 | GAsyncReadyCallback callback, |
241 | gpointer user_data); |
242 | |
243 | WEBKIT_API GList * |
244 | webkit_web_context_get_plugins_finish (WebKitWebContext *context, |
245 | GAsyncResult *result, |
246 | GError **error); |
247 | WEBKIT_API void |
248 | webkit_web_context_register_uri_scheme (WebKitWebContext *context, |
249 | const gchar *scheme, |
250 | WebKitURISchemeRequestCallback callback, |
251 | gpointer user_data, |
252 | GDestroyNotify user_data_destroy_func); |
253 | |
254 | WEBKIT_API void |
255 | webkit_web_context_set_sandbox_enabled (WebKitWebContext *context, |
256 | gboolean enabled); |
257 | |
258 | WEBKIT_API gboolean |
259 | webkit_web_context_get_sandbox_enabled (WebKitWebContext *context); |
260 | |
261 | WEBKIT_API void |
262 | webkit_web_context_add_path_to_sandbox (WebKitWebContext *context, |
263 | const char *path, |
264 | gboolean read_only); |
265 | |
266 | WEBKIT_API gboolean |
267 | webkit_web_context_get_spell_checking_enabled (WebKitWebContext *context); |
268 | |
269 | WEBKIT_API void |
270 | webkit_web_context_set_spell_checking_enabled (WebKitWebContext *context, |
271 | gboolean enabled); |
272 | WEBKIT_API const gchar * const * |
273 | webkit_web_context_get_spell_checking_languages (WebKitWebContext *context); |
274 | |
275 | WEBKIT_API void |
276 | webkit_web_context_set_spell_checking_languages (WebKitWebContext *context, |
277 | const gchar * const *languages); |
278 | |
279 | WEBKIT_API void |
280 | webkit_web_context_set_preferred_languages (WebKitWebContext *context, |
281 | const gchar * const *languages); |
282 | |
283 | WEBKIT_API void |
284 | webkit_web_context_set_tls_errors_policy (WebKitWebContext *context, |
285 | WebKitTLSErrorsPolicy policy); |
286 | |
287 | WEBKIT_API WebKitTLSErrorsPolicy |
288 | webkit_web_context_get_tls_errors_policy (WebKitWebContext *context); |
289 | |
290 | WEBKIT_API void |
291 | webkit_web_context_set_web_extensions_directory (WebKitWebContext *context, |
292 | const gchar *directory); |
293 | |
294 | WEBKIT_API void |
295 | webkit_web_context_set_web_extensions_initialization_user_data |
296 | (WebKitWebContext *context, |
297 | GVariant *user_data); |
298 | |
299 | WEBKIT_API void |
300 | webkit_web_context_prefetch_dns (WebKitWebContext *context, |
301 | const gchar *hostname); |
302 | |
303 | WEBKIT_DEPRECATED_FOR(webkit_web_context_new_with_website_data_manager) void |
304 | webkit_web_context_set_disk_cache_directory (WebKitWebContext *context, |
305 | const gchar *directory); |
306 | |
307 | WEBKIT_API void |
308 | webkit_web_context_allow_tls_certificate_for_host (WebKitWebContext *context, |
309 | GTlsCertificate *certificate, |
310 | const gchar *host); |
311 | |
312 | WEBKIT_API void |
313 | webkit_web_context_set_process_model (WebKitWebContext *context, |
314 | WebKitProcessModel process_model); |
315 | |
316 | WEBKIT_API WebKitProcessModel |
317 | webkit_web_context_get_process_model (WebKitWebContext *context); |
318 | |
319 | WEBKIT_API void |
320 | webkit_web_context_initialize_notification_permissions |
321 | (WebKitWebContext *context, |
322 | GList *allowed_origins, |
323 | GList *disallowed_origins); |
324 | |
325 | G_END_DECLS |
326 | |
327 | #endif |
328 | |