1 module webkit2.WebContext;
2 
3 private import gio.AsyncResultIF;
4 private import gio.Cancellable;
5 private import gio.TlsCertificate;
6 private import glib.ConstructionException;
7 private import glib.ErrorG;
8 private import glib.GException;
9 private import glib.ListG;
10 private import glib.Str;
11 private import glib.Variant;
12 private import gobject.ObjectG;
13 private import gobject.Signals;
14 private import std.algorithm;
15 private import webkit2.AutomationSession;
16 private import webkit2.CookieManager;
17 private import webkit2.Download;
18 private import webkit2.FaviconDatabase;
19 private import webkit2.GeolocationManager;
20 private import webkit2.NetworkProxySettings;
21 private import webkit2.SecurityManager;
22 private import webkit2.SecurityOrigin;
23 private import webkit2.UserMessage;
24 private import webkit2.WebsiteDataManager;
25 private import webkit2.c.functions;
26 public  import webkit2.c.types;
27 
28 
29 /**
30  * The #WebKitWebContext manages all aspects common to all
31  * #WebKitWebView<!-- -->s.
32  * 
33  * You can define the #WebKitCacheModel and #WebKitProcessModel with
34  * webkit_web_context_set_cache_model() and
35  * webkit_web_context_set_process_model(), depending on the needs of
36  * your application. You can access the #WebKitSecurityManager to specify
37  * the behaviour of your application regarding security using
38  * webkit_web_context_get_security_manager().
39  * 
40  * It is also possible to change your preferred language or enable
41  * spell checking, using webkit_web_context_set_preferred_languages(),
42  * webkit_web_context_set_spell_checking_languages() and
43  * webkit_web_context_set_spell_checking_enabled().
44  * 
45  * You can use webkit_web_context_register_uri_scheme() to register
46  * custom URI schemes, and manage several other settings.
47  * 
48  * TLS certificate validation failure is now treated as a transport
49  * error by default. To handle TLS failures differently, you can
50  * connect to #WebKitWebView::load-failed-with-tls-errors.
51  * Alternatively, you can use webkit_web_context_set_tls_errors_policy()
52  * to set the policy %WEBKIT_TLS_ERRORS_POLICY_IGNORE; however, this is
53  * not appropriate for Internet applications.
54  */
55 public class WebContext : ObjectG
56 {
57 	/** the main Gtk struct */
58 	protected WebKitWebContext* webKitWebContext;
59 
60 	/** Get the main Gtk struct */
61 	public WebKitWebContext* getWebContextStruct(bool transferOwnership = false)
62 	{
63 		if (transferOwnership)
64 			ownedRef = false;
65 		return webKitWebContext;
66 	}
67 
68 	/** the main Gtk struct as a void* */
69 	protected override void* getStruct()
70 	{
71 		return cast(void*)webKitWebContext;
72 	}
73 
74 	/**
75 	 * Sets our main struct and passes it to the parent class.
76 	 */
77 	public this (WebKitWebContext* webKitWebContext, bool ownedRef = false)
78 	{
79 		this.webKitWebContext = webKitWebContext;
80 		super(cast(GObject*)webKitWebContext, ownedRef);
81 	}
82 
83 
84 	/** */
85 	public static GType getType()
86 	{
87 		return webkit_web_context_get_type();
88 	}
89 
90 	/**
91 	 * Create a new #WebKitWebContext
92 	 *
93 	 * Returns: a newly created #WebKitWebContext
94 	 *
95 	 * Since: 2.8
96 	 *
97 	 * Throws: ConstructionException GTK+ fails to create the object.
98 	 */
99 	public this()
100 	{
101 		auto __p = webkit_web_context_new();
102 
103 		if(__p is null)
104 		{
105 			throw new ConstructionException("null returned by new");
106 		}
107 
108 		this(cast(WebKitWebContext*) __p, true);
109 	}
110 
111 	/**
112 	 * Create a new ephemeral #WebKitWebContext. An ephemeral #WebKitWebContext is a context
113 	 * created with an ephemeral #WebKitWebsiteDataManager. This is just a convenient method
114 	 * to create ephemeral contexts without having to create your own #WebKitWebsiteDataManager.
115 	 * All #WebKitWebView<!-- -->s associated with this context will also be ephemeral. Websites will
116 	 * not store any data in the client storage.
117 	 * This is normally used to implement private instances.
118 	 *
119 	 * Returns: a new ephemeral #WebKitWebContext.
120 	 *
121 	 * Since: 2.16
122 	 *
123 	 * Throws: ConstructionException GTK+ fails to create the object.
124 	 */
125 	public static WebContext newEphemeral()
126 	{
127 		return new WebContext(webkit_web_context_new_ephemeral(), true);
128 	}
129 
130 	/**
131 	 * Create a new #WebKitWebContext with a #WebKitWebsiteDataManager.
132 	 *
133 	 * Params:
134 	 *     manager = a #WebKitWebsiteDataManager
135 	 *
136 	 * Returns: a newly created #WebKitWebContext
137 	 *
138 	 * Since: 2.10
139 	 *
140 	 * Throws: ConstructionException GTK+ fails to create the object.
141 	 */
142 	public this(WebsiteDataManager manager)
143 	{
144 		auto __p = webkit_web_context_new_with_website_data_manager((manager is null) ? null : manager.getWebsiteDataManagerStruct());
145 
146 		if(__p is null)
147 		{
148 			throw new ConstructionException("null returned by new_with_website_data_manager");
149 		}
150 
151 		this(cast(WebKitWebContext*) __p, true);
152 	}
153 
154 	/**
155 	 * Gets the default web context
156 	 *
157 	 * Returns: a #WebKitWebContext
158 	 */
159 	public static WebContext getDefault()
160 	{
161 		auto __p = webkit_web_context_get_default();
162 
163 		if(__p is null)
164 		{
165 			return null;
166 		}
167 
168 		return ObjectG.getDObject!(WebContext)(cast(WebKitWebContext*) __p);
169 	}
170 
171 	/**
172 	 * Adds a path to be mounted in the sandbox. @path must exist before any web process
173 	 * has been created otherwise it will be silently ignored. It is a fatal error to
174 	 * add paths after a web process has been spawned.
175 	 *
176 	 * Paths in directories such as `/sys`, `/proc`, and `/dev` or all of `/`
177 	 * are not valid.
178 	 *
179 	 * See also webkit_web_context_set_sandbox_enabled()
180 	 *
181 	 * Params:
182 	 *     path = an absolute path to mount in the sandbox
183 	 *     readOnly = if %TRUE the path will be read-only
184 	 *
185 	 * Since: 2.26
186 	 */
187 	public void addPathToSandbox(string path, bool readOnly)
188 	{
189 		webkit_web_context_add_path_to_sandbox(webKitWebContext, Str.toStringz(path), readOnly);
190 	}
191 
192 	/**
193 	 * Ignore further TLS errors on the @host for the certificate present in @info.
194 	 *
195 	 * Params:
196 	 *     certificate = a #GTlsCertificate
197 	 *     host = the host for which a certificate is to be allowed
198 	 *
199 	 * Since: 2.6
200 	 */
201 	public void allowTlsCertificateForHost(TlsCertificate certificate, string host)
202 	{
203 		webkit_web_context_allow_tls_certificate_for_host(webKitWebContext, (certificate is null) ? null : certificate.getTlsCertificateStruct(), Str.toStringz(host));
204 	}
205 
206 	/**
207 	 * Clears all resources currently cached.
208 	 * See also webkit_web_context_set_cache_model().
209 	 */
210 	public void clearCache()
211 	{
212 		webkit_web_context_clear_cache(webKitWebContext);
213 	}
214 
215 	/**
216 	 * Requests downloading of the specified URI string. The download operation
217 	 * will not be associated to any #WebKitWebView, if you are interested in
218 	 * starting a download from a particular #WebKitWebView use
219 	 * webkit_web_view_download_uri() instead.
220 	 *
221 	 * Params:
222 	 *     uri = the URI to download
223 	 *
224 	 * Returns: a new #WebKitDownload representing
225 	 *     the download operation.
226 	 */
227 	public Download downloadUri(string uri)
228 	{
229 		auto __p = webkit_web_context_download_uri(webKitWebContext, Str.toStringz(uri));
230 
231 		if(__p is null)
232 		{
233 			return null;
234 		}
235 
236 		return ObjectG.getDObject!(Download)(cast(WebKitDownload*) __p, true);
237 	}
238 
239 	/**
240 	 * Returns the current cache model. For more information about this
241 	 * value check the documentation of the function
242 	 * webkit_web_context_set_cache_model().
243 	 *
244 	 * Returns: the current #WebKitCacheModel
245 	 */
246 	public WebKitCacheModel getCacheModel()
247 	{
248 		return webkit_web_context_get_cache_model(webKitWebContext);
249 	}
250 
251 	/**
252 	 * Get the #WebKitCookieManager of the @context's #WebKitWebsiteDataManager.
253 	 *
254 	 * Returns: the #WebKitCookieManager of @context.
255 	 */
256 	public CookieManager getCookieManager()
257 	{
258 		auto __p = webkit_web_context_get_cookie_manager(webKitWebContext);
259 
260 		if(__p is null)
261 		{
262 			return null;
263 		}
264 
265 		return ObjectG.getDObject!(CookieManager)(cast(WebKitCookieManager*) __p);
266 	}
267 
268 	/**
269 	 * Get the #WebKitFaviconDatabase associated with @context.
270 	 *
271 	 * To initialize the database you need to call
272 	 * webkit_web_context_set_favicon_database_directory().
273 	 *
274 	 * Returns: the #WebKitFaviconDatabase of @context.
275 	 */
276 	public FaviconDatabase getFaviconDatabase()
277 	{
278 		auto __p = webkit_web_context_get_favicon_database(webKitWebContext);
279 
280 		if(__p is null)
281 		{
282 			return null;
283 		}
284 
285 		return ObjectG.getDObject!(FaviconDatabase)(cast(WebKitFaviconDatabase*) __p);
286 	}
287 
288 	/**
289 	 * Get the directory path being used to store the favicons database
290 	 * for @context, or %NULL if
291 	 * webkit_web_context_set_favicon_database_directory() hasn't been
292 	 * called yet.
293 	 *
294 	 * This function will always return the same path after having called
295 	 * webkit_web_context_set_favicon_database_directory() for the first
296 	 * time.
297 	 *
298 	 * Returns: the path of the directory of the favicons
299 	 *     database associated with @context, or %NULL.
300 	 */
301 	public string getFaviconDatabaseDirectory()
302 	{
303 		return Str.toString(webkit_web_context_get_favicon_database_directory(webKitWebContext));
304 	}
305 
306 	/**
307 	 * Get the #WebKitGeolocationManager of @context.
308 	 *
309 	 * Returns: the #WebKitGeolocationManager of @context.
310 	 *
311 	 * Since: 2.26
312 	 */
313 	public GeolocationManager getGeolocationManager()
314 	{
315 		auto __p = webkit_web_context_get_geolocation_manager(webKitWebContext);
316 
317 		if(__p is null)
318 		{
319 			return null;
320 		}
321 
322 		return ObjectG.getDObject!(GeolocationManager)(cast(WebKitGeolocationManager*) __p);
323 	}
324 
325 	/**
326 	 * Asynchronously get the list of installed plugins.
327 	 *
328 	 * When the operation is finished, @callback will be called. You can then call
329 	 * webkit_web_context_get_plugins_finish() to get the result of the operation.
330 	 *
331 	 * Params:
332 	 *     cancellable = a #GCancellable or %NULL to ignore
333 	 *     callback = a #GAsyncReadyCallback to call when the request is satisfied
334 	 *     userData = the data to pass to callback function
335 	 */
336 	public void getPlugins(Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
337 	{
338 		webkit_web_context_get_plugins(webKitWebContext, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
339 	}
340 
341 	/**
342 	 * Finish an asynchronous operation started with webkit_web_context_get_plugins.
343 	 *
344 	 * Params:
345 	 *     result = a #GAsyncResult
346 	 *
347 	 * Returns: a #GList of #WebKitPlugin. You must free the #GList with
348 	 *     g_list_free() and unref the #WebKitPlugin<!-- -->s with g_object_unref() when you're done with them.
349 	 *
350 	 * Throws: GException on failure.
351 	 */
352 	public ListG getPluginsFinish(AsyncResultIF result)
353 	{
354 		GError* err = null;
355 
356 		auto __p = webkit_web_context_get_plugins_finish(webKitWebContext, (result is null) ? null : result.getAsyncResultStruct(), &err);
357 
358 		if (err !is null)
359 		{
360 			throw new GException( new ErrorG(err) );
361 		}
362 
363 		if(__p is null)
364 		{
365 			return null;
366 		}
367 
368 		return new ListG(cast(GList*) __p, true);
369 	}
370 
371 	/**
372 	 * Returns the current process model. For more information about this value
373 	 * see webkit_web_context_set_process_model().
374 	 *
375 	 * Returns: the current #WebKitProcessModel
376 	 *
377 	 * Since: 2.4
378 	 */
379 	public WebKitProcessModel getProcessModel()
380 	{
381 		return webkit_web_context_get_process_model(webKitWebContext);
382 	}
383 
384 	/**
385 	 * Get whether sandboxing is currently enabled.
386 	 *
387 	 * Returns: %TRUE if sandboxing is enabled, or %FALSE otherwise.
388 	 *
389 	 * Since: 2.26
390 	 */
391 	public bool getSandboxEnabled()
392 	{
393 		return webkit_web_context_get_sandbox_enabled(webKitWebContext) != 0;
394 	}
395 
396 	/**
397 	 * Get the #WebKitSecurityManager of @context.
398 	 *
399 	 * Returns: the #WebKitSecurityManager of @context.
400 	 */
401 	public SecurityManager getSecurityManager()
402 	{
403 		auto __p = webkit_web_context_get_security_manager(webKitWebContext);
404 
405 		if(__p is null)
406 		{
407 			return null;
408 		}
409 
410 		return ObjectG.getDObject!(SecurityManager)(cast(WebKitSecurityManager*) __p);
411 	}
412 
413 	/**
414 	 * Get whether spell checking feature is currently enabled.
415 	 *
416 	 * Returns: %TRUE If spell checking is enabled, or %FALSE otherwise.
417 	 */
418 	public bool getSpellCheckingEnabled()
419 	{
420 		return webkit_web_context_get_spell_checking_enabled(webKitWebContext) != 0;
421 	}
422 
423 	/**
424 	 * Get the the list of spell checking languages associated with
425 	 * @context, or %NULL if no languages have been previously set.
426 	 *
427 	 * See webkit_web_context_set_spell_checking_languages() for more
428 	 * details on the format of the languages in the list.
429 	 *
430 	 * Returns: A %NULL-terminated
431 	 *     array of languages if available, or %NULL otherwise.
432 	 */
433 	public string[] getSpellCheckingLanguages()
434 	{
435 		return Str.toStringArray(webkit_web_context_get_spell_checking_languages(webKitWebContext));
436 	}
437 
438 	/**
439 	 * Get the TLS errors policy of @context
440 	 *
441 	 * Returns: a #WebKitTLSErrorsPolicy
442 	 */
443 	public WebKitTLSErrorsPolicy getTlsErrorsPolicy()
444 	{
445 		return webkit_web_context_get_tls_errors_policy(webKitWebContext);
446 	}
447 
448 	/**
449 	 * Get the #WebKitWebContext:use-system-appearance-for-scrollbars property.
450 	 *
451 	 * Returns: %TRUE if scrollbars are rendering using the system appearance, or %FALSE otherwise
452 	 *
453 	 * Since: 2.30
454 	 */
455 	public bool getUseSystemAppearanceForScrollbars()
456 	{
457 		return webkit_web_context_get_use_system_appearance_for_scrollbars(webKitWebContext) != 0;
458 	}
459 
460 	/**
461 	 * Gets the maximum number of web processes that can be created at the same time for the @context.
462 	 *
463 	 * This function is now deprecated and always returns 0 (no limit). See also webkit_web_context_set_web_process_count_limit().
464 	 *
465 	 * Returns: the maximum limit of web processes, or 0 if there isn't a limit.
466 	 *
467 	 * Since: 2.10
468 	 */
469 	public uint getWebProcessCountLimit()
470 	{
471 		return webkit_web_context_get_web_process_count_limit(webKitWebContext);
472 	}
473 
474 	/**
475 	 * Get the #WebKitWebsiteDataManager of @context.
476 	 *
477 	 * Returns: a #WebKitWebsiteDataManager
478 	 *
479 	 * Since: 2.10
480 	 */
481 	public WebsiteDataManager getWebsiteDataManager()
482 	{
483 		auto __p = webkit_web_context_get_website_data_manager(webKitWebContext);
484 
485 		if(__p is null)
486 		{
487 			return null;
488 		}
489 
490 		return ObjectG.getDObject!(WebsiteDataManager)(cast(WebKitWebsiteDataManager*) __p);
491 	}
492 
493 	/**
494 	 * Sets initial desktop notification permissions for the @context.
495 	 * @allowed_origins and @disallowed_origins must each be #GList of
496 	 * #WebKitSecurityOrigin objects representing origins that will,
497 	 * respectively, either always or never have permission to show desktop
498 	 * notifications. No #WebKitNotificationPermissionRequest will ever be
499 	 * generated for any of the security origins represented in
500 	 * @allowed_origins or @disallowed_origins. This function is necessary
501 	 * because some webpages proactively check whether they have permission
502 	 * to display notifications without ever creating a permission request.
503 	 *
504 	 * This function only affects web processes that have not already been
505 	 * created. The best time to call it is when handling
506 	 * #WebKitWebContext::initialize-notification-permissions so as to
507 	 * ensure that new web processes receive the most recent set of
508 	 * permissions.
509 	 *
510 	 * Params:
511 	 *     allowedOrigins = a #GList of security origins
512 	 *     disallowedOrigins = a #GList of security origins
513 	 *
514 	 * Since: 2.16
515 	 */
516 	public void initializeNotificationPermissions(ListG allowedOrigins, ListG disallowedOrigins)
517 	{
518 		webkit_web_context_initialize_notification_permissions(webKitWebContext, (allowedOrigins is null) ? null : allowedOrigins.getListGStruct(), (disallowedOrigins is null) ? null : disallowedOrigins.getListGStruct());
519 	}
520 
521 	/**
522 	 * Get whether automation is allowed in @context.
523 	 * See also webkit_web_context_set_automation_allowed().
524 	 *
525 	 * Returns: %TRUE if automation is allowed or %FALSE otherwise.
526 	 *
527 	 * Since: 2.18
528 	 */
529 	public bool isAutomationAllowed()
530 	{
531 		return webkit_web_context_is_automation_allowed(webKitWebContext) != 0;
532 	}
533 
534 	/**
535 	 * Get whether a #WebKitWebContext is ephemeral.
536 	 *
537 	 * Returns: %TRUE if @context is ephemeral or %FALSE otherwise.
538 	 *
539 	 * Since: 2.16
540 	 */
541 	public bool isEphemeral()
542 	{
543 		return webkit_web_context_is_ephemeral(webKitWebContext) != 0;
544 	}
545 
546 	/**
547 	 * Resolve the domain name of the given @hostname in advance, so that if a URI
548 	 * of @hostname is requested the load will be performed more quickly.
549 	 *
550 	 * Params:
551 	 *     hostname = a hostname to be resolved
552 	 */
553 	public void prefetchDns(string hostname)
554 	{
555 		webkit_web_context_prefetch_dns(webKitWebContext, Str.toStringz(hostname));
556 	}
557 
558 	/**
559 	 * Register @scheme in @context, so that when an URI request with @scheme is made in the
560 	 * #WebKitWebContext, the #WebKitURISchemeRequestCallback registered will be called with a
561 	 * #WebKitURISchemeRequest.
562 	 * It is possible to handle URI scheme requests asynchronously, by calling g_object_ref() on the
563 	 * #WebKitURISchemeRequest and calling webkit_uri_scheme_request_finish() later
564 	 * when the data of the request is available or
565 	 * webkit_uri_scheme_request_finish_error() in case of error.
566 	 *
567 	 * <informalexample><programlisting>
568 	 * static void
569 	 * about_uri_scheme_request_cb (WebKitURISchemeRequest *request,
570 	 * gpointer                user_data)
571 	 * {
572 	 * GInputStream *stream;
573 	 * gsize         stream_length;
574 	 * const gchar  *path;
575 	 *
576 	 * path = webkit_uri_scheme_request_get_path (request);
577 	 * if (!g_strcmp0 (path, "plugins")) {
578 	 * /<!-- -->* Create a GInputStream with the contents of plugins about page, and set its length to stream_length *<!-- -->/
579 	 * } else if (!g_strcmp0 (path, "memory")) {
580 	 * /<!-- -->* Create a GInputStream with the contents of memory about page, and set its length to stream_length *<!-- -->/
581 	 * } else if (!g_strcmp0 (path, "applications")) {
582 	 * /<!-- -->* Create a GInputStream with the contents of applications about page, and set its length to stream_length *<!-- -->/
583 	 * } else if (!g_strcmp0 (path, "example")) {
584 	 * gchar *contents;
585 	 *
586 	 * contents = g_strdup_printf ("&lt;html&gt;&lt;body&gt;&lt;p&gt;Example about page&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;");
587 	 * stream_length = strlen (contents);
588 	 * stream = g_memory_input_stream_new_from_data (contents, stream_length, g_free);
589 	 * } else {
590 	 * GError *error;
591 	 *
592 	 * error = g_error_new (ABOUT_HANDLER_ERROR, ABOUT_HANDLER_ERROR_INVALID, "Invalid about:%s page.", path);
593 	 * webkit_uri_scheme_request_finish_error (request, error);
594 	 * g_error_free (error);
595 	 * return;
596 	 * }
597 	 * webkit_uri_scheme_request_finish (request, stream, stream_length, "text/html");
598 	 * g_object_unref (stream);
599 	 * }
600 	 * </programlisting></informalexample>
601 	 *
602 	 * Params:
603 	 *     scheme = the network scheme to register
604 	 *     callback = a #WebKitURISchemeRequestCallback
605 	 *     userData = data to pass to callback function
606 	 *     userDataDestroyFunc = destroy notify for @user_data
607 	 */
608 	public void registerUriScheme(string scheme, WebKitURISchemeRequestCallback callback, void* userData, GDestroyNotify userDataDestroyFunc)
609 	{
610 		webkit_web_context_register_uri_scheme(webKitWebContext, Str.toStringz(scheme), callback, userData, userDataDestroyFunc);
611 	}
612 
613 	/**
614 	 * Send @message to all #WebKitWebExtension<!-- -->s associated to @context.
615 	 * If @message is floating, it's consumed.
616 	 *
617 	 * Params:
618 	 *     message = a #WebKitUserMessage
619 	 *
620 	 * Since: 2.28
621 	 */
622 	public void sendMessageToAllExtensions(UserMessage message)
623 	{
624 		webkit_web_context_send_message_to_all_extensions(webKitWebContext, (message is null) ? null : message.getUserMessageStruct());
625 	}
626 
627 	/**
628 	 * Set an additional directory where WebKit will look for plugins.
629 	 *
630 	 * Params:
631 	 *     directory = the directory to add
632 	 */
633 	public void setAdditionalPluginsDirectory(string directory)
634 	{
635 		webkit_web_context_set_additional_plugins_directory(webKitWebContext, Str.toStringz(directory));
636 	}
637 
638 	/**
639 	 * Set whether automation is allowed in @context. When automation is enabled the browser could
640 	 * be controlled by another process by requesting an automation session. When a new automation
641 	 * session is requested the signal #WebKitWebContext::automation-started is emitted.
642 	 * Automation is disabled by default, so you need to explicitly call this method passing %TRUE
643 	 * to enable it.
644 	 *
645 	 * Note that only one #WebKitWebContext can have automation enabled, so this will do nothing
646 	 * if there's another #WebKitWebContext with automation already enabled.
647 	 *
648 	 * Params:
649 	 *     allowed = value to set
650 	 *
651 	 * Since: 2.18
652 	 */
653 	public void setAutomationAllowed(bool allowed)
654 	{
655 		webkit_web_context_set_automation_allowed(webKitWebContext, allowed);
656 	}
657 
658 	/**
659 	 * Specifies a usage model for WebViews, which WebKit will use to
660 	 * determine its caching behavior. All web views follow the cache
661 	 * model. This cache model determines the RAM and disk space to use
662 	 * for caching previously viewed content .
663 	 *
664 	 * Research indicates that users tend to browse within clusters of
665 	 * documents that hold resources in common, and to revisit previously
666 	 * visited documents. WebKit and the frameworks below it include
667 	 * built-in caches that take advantage of these patterns,
668 	 * substantially improving document load speed in browsing
669 	 * situations. The WebKit cache model controls the behaviors of all of
670 	 * these caches, including various WebCore caches.
671 	 *
672 	 * Browsers can improve document load speed substantially by
673 	 * specifying %WEBKIT_CACHE_MODEL_WEB_BROWSER. Applications without a
674 	 * browsing interface can reduce memory usage substantially by
675 	 * specifying %WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER. The default value is
676 	 * %WEBKIT_CACHE_MODEL_WEB_BROWSER.
677 	 *
678 	 * Params:
679 	 *     cacheModel = a #WebKitCacheModel
680 	 */
681 	public void setCacheModel(WebKitCacheModel cacheModel)
682 	{
683 		webkit_web_context_set_cache_model(webKitWebContext, cacheModel);
684 	}
685 
686 	/**
687 	 * Set the directory where disk cache files will be stored
688 	 * This method must be called before loading anything in this context, otherwise
689 	 * it will not have any effect.
690 	 *
691 	 * Note that this method overrides the directory set in the #WebKitWebsiteDataManager,
692 	 * but it doesn't change the value returned by webkit_website_data_manager_get_disk_cache_directory()
693 	 * since the #WebKitWebsiteDataManager is immutable.
694 	 *
695 	 * Deprecated: Use webkit_web_context_new_with_website_data_manager() instead.
696 	 *
697 	 * Params:
698 	 *     directory = the directory to set
699 	 */
700 	public void setDiskCacheDirectory(string directory)
701 	{
702 		webkit_web_context_set_disk_cache_directory(webKitWebContext, Str.toStringz(directory));
703 	}
704 
705 	/**
706 	 * Set the directory path to be used to store the favicons database
707 	 * for @context on disk. Passing %NULL as @path means using the
708 	 * default directory for the platform (see g_get_user_cache_dir()).
709 	 *
710 	 * Calling this method also means enabling the favicons database for
711 	 * its use from the applications, so that's why it's expected to be
712 	 * called only once. Further calls for the same instance of
713 	 * #WebKitWebContext won't cause any effect.
714 	 *
715 	 * Params:
716 	 *     path = an absolute path to the icon database
717 	 *         directory or %NULL to use the defaults
718 	 */
719 	public void setFaviconDatabaseDirectory(string path)
720 	{
721 		webkit_web_context_set_favicon_database_directory(webKitWebContext, Str.toStringz(path));
722 	}
723 
724 	/**
725 	 * Set the network proxy settings to be used by connections started in @context.
726 	 * By default %WEBKIT_NETWORK_PROXY_MODE_DEFAULT is used, which means that the
727 	 * system settings will be used (g_proxy_resolver_get_default()).
728 	 * If you want to override the system default settings, you can either use
729 	 * %WEBKIT_NETWORK_PROXY_MODE_NO_PROXY to make sure no proxies are used at all,
730 	 * or %WEBKIT_NETWORK_PROXY_MODE_CUSTOM to provide your own proxy settings.
731 	 * When @proxy_mode is %WEBKIT_NETWORK_PROXY_MODE_CUSTOM @proxy_settings must be
732 	 * a valid #WebKitNetworkProxySettings; otherwise, @proxy_settings must be %NULL.
733 	 *
734 	 * Params:
735 	 *     proxyMode = a #WebKitNetworkProxyMode
736 	 *     proxySettings = a #WebKitNetworkProxySettings, or %NULL
737 	 *
738 	 * Since: 2.16
739 	 */
740 	public void setNetworkProxySettings(WebKitNetworkProxyMode proxyMode, NetworkProxySettings proxySettings)
741 	{
742 		webkit_web_context_set_network_proxy_settings(webKitWebContext, proxyMode, (proxySettings is null) ? null : proxySettings.getNetworkProxySettingsStruct());
743 	}
744 
745 	/**
746 	 * Set the list of preferred languages, sorted from most desirable
747 	 * to least desirable. The list will be used to build the "Accept-Language"
748 	 * header that will be included in the network requests started by
749 	 * the #WebKitWebContext.
750 	 *
751 	 * Params:
752 	 *     languages = a %NULL-terminated list of language identifiers
753 	 */
754 	public void setPreferredLanguages(string[] languages)
755 	{
756 		webkit_web_context_set_preferred_languages(webKitWebContext, Str.toStringzArray(languages));
757 	}
758 
759 	/**
760 	 * Specifies a process model for WebViews, which WebKit will use to
761 	 * determine how auxiliary processes are handled.
762 	 *
763 	 * %WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES will use
764 	 * one process per view most of the time, while still allowing for web
765 	 * views to share a process when needed (for example when different
766 	 * views interact with each other). Using this model, when a process
767 	 * hangs or crashes, only the WebViews using it stop working, while
768 	 * the rest of the WebViews in the application will still function
769 	 * normally.
770 	 *
771 	 * %WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS is deprecated since 2.26,
772 	 * using it has no effect for security reasons.
773 	 *
774 	 * This method **must be called before any web process has been created**,
775 	 * as early as possible in your application. Calling it later will make
776 	 * your application crash.
777 	 *
778 	 * Params:
779 	 *     processModel = a #WebKitProcessModel
780 	 *
781 	 * Since: 2.4
782 	 */
783 	public void setProcessModel(WebKitProcessModel processModel)
784 	{
785 		webkit_web_context_set_process_model(webKitWebContext, processModel);
786 	}
787 
788 	/**
789 	 * Set whether WebKit subprocesses will be sandboxed, limiting access to the system.
790 	 *
791 	 * This method **must be called before any web process has been created**,
792 	 * as early as possible in your application. Calling it later is a fatal error.
793 	 *
794 	 * This is only implemented on Linux and is a no-op otherwise.
795 	 *
796 	 * Params:
797 	 *     enabled = if %TRUE enable sandboxing
798 	 *
799 	 * Since: 2.26
800 	 */
801 	public void setSandboxEnabled(bool enabled)
802 	{
803 		webkit_web_context_set_sandbox_enabled(webKitWebContext, enabled);
804 	}
805 
806 	/**
807 	 * Enable or disable the spell checking feature.
808 	 *
809 	 * Params:
810 	 *     enabled = Value to be set
811 	 */
812 	public void setSpellCheckingEnabled(bool enabled)
813 	{
814 		webkit_web_context_set_spell_checking_enabled(webKitWebContext, enabled);
815 	}
816 
817 	/**
818 	 * Set the list of spell checking languages to be used for spell
819 	 * checking.
820 	 *
821 	 * The locale string typically is in the form lang_COUNTRY, where lang
822 	 * is an ISO-639 language code, and COUNTRY is an ISO-3166 country code.
823 	 * For instance, sv_FI for Swedish as written in Finland or pt_BR
824 	 * for Portuguese as written in Brazil.
825 	 *
826 	 * You need to call this function with a valid list of languages at
827 	 * least once in order to properly enable the spell checking feature
828 	 * in WebKit.
829 	 *
830 	 * Params:
831 	 *     languages = a %NULL-terminated list of spell checking languages
832 	 */
833 	public void setSpellCheckingLanguages(string[] languages)
834 	{
835 		webkit_web_context_set_spell_checking_languages(webKitWebContext, Str.toStringzArray(languages));
836 	}
837 
838 	/**
839 	 * Set the TLS errors policy of @context as @policy
840 	 *
841 	 * Params:
842 	 *     policy = a #WebKitTLSErrorsPolicy
843 	 */
844 	public void setTlsErrorsPolicy(WebKitTLSErrorsPolicy policy)
845 	{
846 		webkit_web_context_set_tls_errors_policy(webKitWebContext, policy);
847 	}
848 
849 	/**
850 	 * Set the #WebKitWebContext:use-system-appearance-for-scrollbars property.
851 	 *
852 	 * Params:
853 	 *     enabled = value to set
854 	 *
855 	 * Since: 2.30
856 	 */
857 	public void setUseSystemAppearanceForScrollbars(bool enabled)
858 	{
859 		webkit_web_context_set_use_system_appearance_for_scrollbars(webKitWebContext, enabled);
860 	}
861 
862 	/**
863 	 * Set the directory where WebKit will look for Web Extensions.
864 	 * This method must be called before loading anything in this context,
865 	 * otherwise it will not have any effect. You can connect to
866 	 * #WebKitWebContext::initialize-web-extensions to call this method
867 	 * before anything is loaded.
868 	 *
869 	 * Params:
870 	 *     directory = the directory to add
871 	 */
872 	public void setWebExtensionsDirectory(string directory)
873 	{
874 		webkit_web_context_set_web_extensions_directory(webKitWebContext, Str.toStringz(directory));
875 	}
876 
877 	/**
878 	 * Set user data to be passed to Web Extensions on initialization.
879 	 * The data will be passed to the
880 	 * #WebKitWebExtensionInitializeWithUserDataFunction.
881 	 * This method must be called before loading anything in this context,
882 	 * otherwise it will not have any effect. You can connect to
883 	 * #WebKitWebContext::initialize-web-extensions to call this method
884 	 * before anything is loaded.
885 	 *
886 	 * Params:
887 	 *     userData = a #GVariant
888 	 *
889 	 * Since: 2.4
890 	 */
891 	public void setWebExtensionsInitializationUserData(Variant userData)
892 	{
893 		webkit_web_context_set_web_extensions_initialization_user_data(webKitWebContext, (userData is null) ? null : userData.getVariantStruct());
894 	}
895 
896 	/**
897 	 * Sets the maximum number of web processes that can be created at the same time for the @context.
898 	 * The default value is 0 and means no limit.
899 	 *
900 	 * This function is now deprecated and does nothing for security reasons.
901 	 *
902 	 * Params:
903 	 *     limit = the maximum number of web processes
904 	 *
905 	 * Since: 2.10
906 	 */
907 	public void setWebProcessCountLimit(uint limit)
908 	{
909 		webkit_web_context_set_web_process_count_limit(webKitWebContext, limit);
910 	}
911 
912 	/**
913 	 * This signal is emitted when a new automation request is made.
914 	 * Note that it will never be emitted if automation is not enabled in @context,
915 	 * see webkit_web_context_set_automation_allowed() for more details.
916 	 *
917 	 * Params:
918 	 *     session = the #WebKitAutomationSession associated with this event
919 	 *
920 	 * Since: 2.18
921 	 */
922 	gulong addOnAutomationStarted(void delegate(AutomationSession, WebContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
923 	{
924 		return Signals.connect(this, "automation-started", dlg, connectFlags ^ ConnectFlags.SWAPPED);
925 	}
926 
927 	/**
928 	 * This signal is emitted when a new download request is made.
929 	 *
930 	 * Params:
931 	 *     download = the #WebKitDownload associated with this event
932 	 */
933 	gulong addOnDownloadStarted(void delegate(Download, WebContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
934 	{
935 		return Signals.connect(this, "download-started", dlg, connectFlags ^ ConnectFlags.SWAPPED);
936 	}
937 
938 	/**
939 	 * This signal is emitted when a #WebKitWebContext needs to set
940 	 * initial notification permissions for a web process. It is emitted
941 	 * when a new web process is about to be launched, and signals the
942 	 * most appropriate moment to use
943 	 * webkit_web_context_initialize_notification_permissions(). If no
944 	 * notification permissions have changed since the last time this
945 	 * signal was emitted, then there is no need to call
946 	 * webkit_web_context_initialize_notification_permissions() again.
947 	 *
948 	 * Since: 2.16
949 	 */
950 	gulong addOnInitializeNotificationPermissions(void delegate(WebContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
951 	{
952 		return Signals.connect(this, "initialize-notification-permissions", dlg, connectFlags ^ ConnectFlags.SWAPPED);
953 	}
954 
955 	/**
956 	 * This signal is emitted when a new web process is about to be
957 	 * launched. It signals the most appropriate moment to use
958 	 * webkit_web_context_set_web_extensions_initialization_user_data()
959 	 * and webkit_web_context_set_web_extensions_directory().
960 	 *
961 	 * Since: 2.4
962 	 */
963 	gulong addOnInitializeWebExtensions(void delegate(WebContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
964 	{
965 		return Signals.connect(this, "initialize-web-extensions", dlg, connectFlags ^ ConnectFlags.SWAPPED);
966 	}
967 
968 	/**
969 	 * This signal is emitted when a #WebKitUserMessage is received from a
970 	 * #WebKitWebExtension. You can reply to the message using
971 	 * webkit_user_message_send_reply().
972 	 *
973 	 * You can handle the user message asynchronously by calling g_object_ref() on
974 	 * @message and returning %TRUE.
975 	 *
976 	 * Params:
977 	 *     message = the #WebKitUserMessage received
978 	 *
979 	 * Returns: %TRUE if the message was handled, or %FALSE otherwise.
980 	 *
981 	 * Since: 2.28
982 	 */
983 	gulong addOnUserMessageReceived(bool delegate(UserMessage, WebContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
984 	{
985 		return Signals.connect(this, "user-message-received", dlg, connectFlags ^ ConnectFlags.SWAPPED);
986 	}
987 }