WebContext

The #WebKitWebContext manages all aspects common to all #WebKitWebView<!-- -->s.

You can define the #WebKitCacheModel and #WebKitProcessModel with webkit_web_context_set_cache_model() and webkit_web_context_set_process_model(), depending on the needs of your application. You can access the #WebKitSecurityManager to specify the behaviour of your application regarding security using webkit_web_context_get_security_manager().

It is also possible to change your preferred language or enable spell checking, using webkit_web_context_set_preferred_languages(), webkit_web_context_set_spell_checking_languages() and webkit_web_context_set_spell_checking_enabled().

You can use webkit_web_context_register_uri_scheme() to register custom URI schemes, and manage several other settings.

TLS certificate validation failure is now treated as a transport error by default. To handle TLS failures differently, you can connect to #WebKitWebView::load-failed-with-tls-errors. Alternatively, you can use webkit_web_context_set_tls_errors_policy() to set the policy %WEBKIT_TLS_ERRORS_POLICY_IGNORE; however, this is not appropriate for Internet applications.

class WebContext : ObjectG {}

Constructors

this
this(WebKitWebContext* webKitWebContext, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this()

Create a new #WebKitWebContext

this
this(WebsiteDataManager manager)

Create a new #WebKitWebContext with a #WebKitWebsiteDataManager.

Members

Functions

addOnAutomationStarted
gulong addOnAutomationStarted(void delegate(AutomationSession, WebContext) dlg, ConnectFlags connectFlags)

This signal is emitted when a new automation request is made. Note that it will never be emitted if automation is not enabled in @context, see webkit_web_context_set_automation_allowed() for more details.

addOnDownloadStarted
gulong addOnDownloadStarted(void delegate(Download, WebContext) dlg, ConnectFlags connectFlags)

This signal is emitted when a new download request is made.

addOnInitializeNotificationPermissions
gulong addOnInitializeNotificationPermissions(void delegate(WebContext) dlg, ConnectFlags connectFlags)

This signal is emitted when a #WebKitWebContext needs to set initial notification permissions for a web process. It is emitted when a new web process is about to be launched, and signals the most appropriate moment to use webkit_web_context_initialize_notification_permissions(). If no notification permissions have changed since the last time this signal was emitted, then there is no need to call webkit_web_context_initialize_notification_permissions() again.

addOnInitializeWebExtensions
gulong addOnInitializeWebExtensions(void delegate(WebContext) dlg, ConnectFlags connectFlags)

This signal is emitted when a new web process is about to be launched. It signals the most appropriate moment to use webkit_web_context_set_web_extensions_initialization_user_data() and webkit_web_context_set_web_extensions_directory().

addOnUserMessageReceived
gulong addOnUserMessageReceived(bool delegate(UserMessage, WebContext) dlg, ConnectFlags connectFlags)

This signal is emitted when a #WebKitUserMessage is received from a #WebKitWebExtension. You can reply to the message using webkit_user_message_send_reply().

addPathToSandbox
void addPathToSandbox(string path, bool readOnly)

Adds a path to be mounted in the sandbox. @path must exist before any web process has been created otherwise it will be silently ignored. It is a fatal error to add paths after a web process has been spawned.

allowTlsCertificateForHost
void allowTlsCertificateForHost(TlsCertificate certificate, string host)

Ignore further TLS errors on the @host for the certificate present in @info.

clearCache
void clearCache()

Clears all resources currently cached. See also webkit_web_context_set_cache_model().

downloadUri
Download downloadUri(string uri)

Requests downloading of the specified URI string. The download operation will not be associated to any #WebKitWebView, if you are interested in starting a download from a particular #WebKitWebView use webkit_web_view_download_uri() instead.

getCacheModel
WebKitCacheModel getCacheModel()

Returns the current cache model. For more information about this value check the documentation of the function webkit_web_context_set_cache_model().

getCookieManager
CookieManager getCookieManager()

Get the #WebKitCookieManager of the @context's #WebKitWebsiteDataManager.

getFaviconDatabase
FaviconDatabase getFaviconDatabase()

Get the #WebKitFaviconDatabase associated with @context.

getFaviconDatabaseDirectory
string getFaviconDatabaseDirectory()

Get the directory path being used to store the favicons database for @context, or %NULL if webkit_web_context_set_favicon_database_directory() hasn't been called yet.

getGeolocationManager
GeolocationManager getGeolocationManager()

Get the #WebKitGeolocationManager of @context.

getPlugins
void getPlugins(Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Asynchronously get the list of installed plugins.

getPluginsFinish
ListG getPluginsFinish(AsyncResultIF result)

Finish an asynchronous operation started with webkit_web_context_get_plugins.

getProcessModel
WebKitProcessModel getProcessModel()

Returns the current process model. For more information about this value see webkit_web_context_set_process_model().

getSandboxEnabled
bool getSandboxEnabled()

Get whether sandboxing is currently enabled.

getSecurityManager
SecurityManager getSecurityManager()

Get the #WebKitSecurityManager of @context.

getSpellCheckingEnabled
bool getSpellCheckingEnabled()

Get whether spell checking feature is currently enabled.

getSpellCheckingLanguages
string[] getSpellCheckingLanguages()

Get the the list of spell checking languages associated with @context, or %NULL if no languages have been previously set.

getStruct
void* getStruct()

the main Gtk struct as a void*

getTlsErrorsPolicy
WebKitTLSErrorsPolicy getTlsErrorsPolicy()

Get the TLS errors policy of @context

getUseSystemAppearanceForScrollbars
bool getUseSystemAppearanceForScrollbars()

Get the #WebKitWebContext:use-system-appearance-for-scrollbars property.

getWebContextStruct
WebKitWebContext* getWebContextStruct(bool transferOwnership)

Get the main Gtk struct

getWebProcessCountLimit
uint getWebProcessCountLimit()

Gets the maximum number of web processes that can be created at the same time for the @context.

getWebsiteDataManager
WebsiteDataManager getWebsiteDataManager()

Get the #WebKitWebsiteDataManager of @context.

initializeNotificationPermissions
void initializeNotificationPermissions(ListG allowedOrigins, ListG disallowedOrigins)

Sets initial desktop notification permissions for the @context. @allowed_origins and @disallowed_origins must each be #GList of #WebKitSecurityOrigin objects representing origins that will, respectively, either always or never have permission to show desktop notifications. No #WebKitNotificationPermissionRequest will ever be generated for any of the security origins represented in @allowed_origins or @disallowed_origins. This function is necessary because some webpages proactively check whether they have permission to display notifications without ever creating a permission request.

isAutomationAllowed
bool isAutomationAllowed()

Get whether automation is allowed in @context. See also webkit_web_context_set_automation_allowed().

isEphemeral
bool isEphemeral()

Get whether a #WebKitWebContext is ephemeral.

prefetchDns
void prefetchDns(string hostname)

Resolve the domain name of the given @hostname in advance, so that if a URI of @hostname is requested the load will be performed more quickly.

registerUriScheme
void registerUriScheme(string scheme, WebKitURISchemeRequestCallback callback, void* userData, GDestroyNotify userDataDestroyFunc)

Register @scheme in @context, so that when an URI request with @scheme is made in the #WebKitWebContext, the #WebKitURISchemeRequestCallback registered will be called with a #WebKitURISchemeRequest. It is possible to handle URI scheme requests asynchronously, by calling g_object_ref() on the #WebKitURISchemeRequest and calling webkit_uri_scheme_request_finish() later when the data of the request is available or webkit_uri_scheme_request_finish_error() in case of error.

sendMessageToAllExtensions
void sendMessageToAllExtensions(UserMessage message)

Send @message to all #WebKitWebExtension<!-- -->s associated to @context. If @message is floating, it's consumed.

setAdditionalPluginsDirectory
void setAdditionalPluginsDirectory(string directory)

Set an additional directory where WebKit will look for plugins.

setAutomationAllowed
void setAutomationAllowed(bool allowed)

Set whether automation is allowed in @context. When automation is enabled the browser could be controlled by another process by requesting an automation session. When a new automation session is requested the signal #WebKitWebContext::automation-started is emitted. Automation is disabled by default, so you need to explicitly call this method passing %TRUE to enable it.

setCacheModel
void setCacheModel(WebKitCacheModel cacheModel)

Specifies a usage model for WebViews, which WebKit will use to determine its caching behavior. All web views follow the cache model. This cache model determines the RAM and disk space to use for caching previously viewed content .

setDiskCacheDirectory
void setDiskCacheDirectory(string directory)

Set the directory where disk cache files will be stored This method must be called before loading anything in this context, otherwise it will not have any effect.

setFaviconDatabaseDirectory
void setFaviconDatabaseDirectory(string path)

Set the directory path to be used to store the favicons database for @context on disk. Passing %NULL as @path means using the default directory for the platform (see g_get_user_cache_dir()).

setNetworkProxySettings
void setNetworkProxySettings(WebKitNetworkProxyMode proxyMode, NetworkProxySettings proxySettings)

Set the network proxy settings to be used by connections started in @context. By default %WEBKIT_NETWORK_PROXY_MODE_DEFAULT is used, which means that the system settings will be used (g_proxy_resolver_get_default()). If you want to override the system default settings, you can either use %WEBKIT_NETWORK_PROXY_MODE_NO_PROXY to make sure no proxies are used at all, or %WEBKIT_NETWORK_PROXY_MODE_CUSTOM to provide your own proxy settings. When @proxy_mode is %WEBKIT_NETWORK_PROXY_MODE_CUSTOM @proxy_settings must be a valid #WebKitNetworkProxySettings; otherwise, @proxy_settings must be %NULL.

setPreferredLanguages
void setPreferredLanguages(string[] languages)

Set the list of preferred languages, sorted from most desirable to least desirable. The list will be used to build the "Accept-Language" header that will be included in the network requests started by the #WebKitWebContext.

setProcessModel
void setProcessModel(WebKitProcessModel processModel)

Specifies a process model for WebViews, which WebKit will use to determine how auxiliary processes are handled.

setSandboxEnabled
void setSandboxEnabled(bool enabled)

Set whether WebKit subprocesses will be sandboxed, limiting access to the system.

setSpellCheckingEnabled
void setSpellCheckingEnabled(bool enabled)

Enable or disable the spell checking feature.

setSpellCheckingLanguages
void setSpellCheckingLanguages(string[] languages)

Set the list of spell checking languages to be used for spell checking.

setTlsErrorsPolicy
void setTlsErrorsPolicy(WebKitTLSErrorsPolicy policy)

Set the TLS errors policy of @context as @policy

setUseSystemAppearanceForScrollbars
void setUseSystemAppearanceForScrollbars(bool enabled)

Set the #WebKitWebContext:use-system-appearance-for-scrollbars property.

setWebExtensionsDirectory
void setWebExtensionsDirectory(string directory)

Set the directory where WebKit will look for Web Extensions. This method must be called before loading anything in this context, otherwise it will not have any effect. You can connect to #WebKitWebContext::initialize-web-extensions to call this method before anything is loaded.

setWebExtensionsInitializationUserData
void setWebExtensionsInitializationUserData(Variant userData)

Set user data to be passed to Web Extensions on initialization. The data will be passed to the #WebKitWebExtensionInitializeWithUserDataFunction. This method must be called before loading anything in this context, otherwise it will not have any effect. You can connect to #WebKitWebContext::initialize-web-extensions to call this method before anything is loaded.

setWebProcessCountLimit
void setWebProcessCountLimit(uint limit)

Sets the maximum number of web processes that can be created at the same time for the @context. The default value is 0 and means no limit.

Static functions

getDefault
WebContext getDefault()

Gets the default web context

getType
GType getType()
newEphemeral
WebContext newEphemeral()

Create a new ephemeral #WebKitWebContext. An ephemeral #WebKitWebContext is a context created with an ephemeral #WebKitWebsiteDataManager. This is just a convenient method to create ephemeral contexts without having to create your own #WebKitWebsiteDataManager. All #WebKitWebView<!-- -->s associated with this context will also be ephemeral. Websites will not store any data in the client storage. This is normally used to implement private instances.

Variables

webKitWebContext
WebKitWebContext* webKitWebContext;

the main Gtk struct

Meta