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
39G_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 */
62typedef 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 */
89typedef 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 */
104typedef 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 */
119typedef 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 */
133typedef void (* WebKitURISchemeRequestCallback) (WebKitURISchemeRequest *request,
134 gpointer user_data);
135
136typedef struct _WebKitWebContext WebKitWebContext;
137typedef struct _WebKitWebContextClass WebKitWebContextClass;
138typedef struct _WebKitWebContextPrivate WebKitWebContextPrivate;
139
140struct _WebKitWebContext {
141 GObject parent;
142
143 /*< private >*/
144 WebKitWebContextPrivate *priv;
145};
146
147struct _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
163WEBKIT_API GType
164webkit_web_context_get_type (void);
165
166WEBKIT_API WebKitWebContext *
167webkit_web_context_get_default (void);
168
169WEBKIT_API WebKitWebContext *
170webkit_web_context_new (void);
171
172WEBKIT_API WebKitWebContext *
173webkit_web_context_new_ephemeral (void);
174
175WEBKIT_API WebKitWebContext *
176webkit_web_context_new_with_website_data_manager (WebKitWebsiteDataManager *manager);
177
178WEBKIT_API WebKitWebsiteDataManager *
179webkit_web_context_get_website_data_manager (WebKitWebContext *context);
180
181WEBKIT_API gboolean
182webkit_web_context_is_ephemeral (WebKitWebContext *context);
183
184WEBKIT_API gboolean
185webkit_web_context_is_automation_allowed (WebKitWebContext *context);
186
187WEBKIT_API void
188webkit_web_context_set_automation_allowed (WebKitWebContext *context,
189 gboolean allowed);
190WEBKIT_API void
191webkit_web_context_set_cache_model (WebKitWebContext *context,
192 WebKitCacheModel cache_model);
193WEBKIT_API WebKitCacheModel
194webkit_web_context_get_cache_model (WebKitWebContext *context);
195
196WEBKIT_API void
197webkit_web_context_set_web_process_count_limit (WebKitWebContext *context,
198 guint limit);
199
200WEBKIT_API guint
201webkit_web_context_get_web_process_count_limit (WebKitWebContext *context);
202
203WEBKIT_API void
204webkit_web_context_clear_cache (WebKitWebContext *context);
205
206WEBKIT_API void
207webkit_web_context_set_network_proxy_settings (WebKitWebContext *context,
208 WebKitNetworkProxyMode proxy_mode,
209 WebKitNetworkProxySettings *proxy_settings);
210
211WEBKIT_API WebKitDownload *
212webkit_web_context_download_uri (WebKitWebContext *context,
213 const gchar *uri);
214
215WEBKIT_API WebKitCookieManager *
216webkit_web_context_get_cookie_manager (WebKitWebContext *context);
217
218WEBKIT_API WebKitGeolocationManager *
219webkit_web_context_get_geolocation_manager (WebKitWebContext *context);
220
221WEBKIT_API WebKitFaviconDatabase *
222webkit_web_context_get_favicon_database (WebKitWebContext *context);
223
224WEBKIT_API void
225webkit_web_context_set_favicon_database_directory (WebKitWebContext *context,
226 const gchar *path);
227WEBKIT_API const gchar *
228webkit_web_context_get_favicon_database_directory (WebKitWebContext *context);
229
230WEBKIT_API WebKitSecurityManager *
231webkit_web_context_get_security_manager (WebKitWebContext *context);
232
233WEBKIT_API void
234webkit_web_context_set_additional_plugins_directory (WebKitWebContext *context,
235 const gchar *directory);
236
237WEBKIT_API void
238webkit_web_context_get_plugins (WebKitWebContext *context,
239 GCancellable *cancellable,
240 GAsyncReadyCallback callback,
241 gpointer user_data);
242
243WEBKIT_API GList *
244webkit_web_context_get_plugins_finish (WebKitWebContext *context,
245 GAsyncResult *result,
246 GError **error);
247WEBKIT_API void
248webkit_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
254WEBKIT_API void
255webkit_web_context_set_sandbox_enabled (WebKitWebContext *context,
256 gboolean enabled);
257
258WEBKIT_API gboolean
259webkit_web_context_get_sandbox_enabled (WebKitWebContext *context);
260
261WEBKIT_API void
262webkit_web_context_add_path_to_sandbox (WebKitWebContext *context,
263 const char *path,
264 gboolean read_only);
265
266WEBKIT_API gboolean
267webkit_web_context_get_spell_checking_enabled (WebKitWebContext *context);
268
269WEBKIT_API void
270webkit_web_context_set_spell_checking_enabled (WebKitWebContext *context,
271 gboolean enabled);
272WEBKIT_API const gchar * const *
273webkit_web_context_get_spell_checking_languages (WebKitWebContext *context);
274
275WEBKIT_API void
276webkit_web_context_set_spell_checking_languages (WebKitWebContext *context,
277 const gchar * const *languages);
278
279WEBKIT_API void
280webkit_web_context_set_preferred_languages (WebKitWebContext *context,
281 const gchar * const *languages);
282
283WEBKIT_API void
284webkit_web_context_set_tls_errors_policy (WebKitWebContext *context,
285 WebKitTLSErrorsPolicy policy);
286
287WEBKIT_API WebKitTLSErrorsPolicy
288webkit_web_context_get_tls_errors_policy (WebKitWebContext *context);
289
290WEBKIT_API void
291webkit_web_context_set_web_extensions_directory (WebKitWebContext *context,
292 const gchar *directory);
293
294WEBKIT_API void
295webkit_web_context_set_web_extensions_initialization_user_data
296 (WebKitWebContext *context,
297 GVariant *user_data);
298
299WEBKIT_API void
300webkit_web_context_prefetch_dns (WebKitWebContext *context,
301 const gchar *hostname);
302
303WEBKIT_DEPRECATED_FOR(webkit_web_context_new_with_website_data_manager) void
304webkit_web_context_set_disk_cache_directory (WebKitWebContext *context,
305 const gchar *directory);
306
307WEBKIT_API void
308webkit_web_context_allow_tls_certificate_for_host (WebKitWebContext *context,
309 GTlsCertificate *certificate,
310 const gchar *host);
311
312WEBKIT_API void
313webkit_web_context_set_process_model (WebKitWebContext *context,
314 WebKitProcessModel process_model);
315
316WEBKIT_API WebKitProcessModel
317webkit_web_context_get_process_model (WebKitWebContext *context);
318
319WEBKIT_API void
320webkit_web_context_initialize_notification_permissions
321 (WebKitWebContext *context,
322 GList *allowed_origins,
323 GList *disallowed_origins);
324
325G_END_DECLS
326
327#endif
328