It derives from <GObject>.
Manages aspects common to all <WebKitWebView><!–
–>s
The <WebKitWebContext> manages all aspects
common to all <WebKitWebView><!– –>s.
You can define the <WebKitCacheModel> with
web-context:set-cache-model,
depending on the needs of your application. You can access the
<WebKitSecurityManager> to specify the
behaviour of your application regarding security using
web-context:get-security-manager.
It is also possible to change your preferred language or enable spell
checking, using web-context:set-preferred-languages,
web-context:set-spell-checking-languages
and web-context:set-spell-checking-enabled.
You can use 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
web-view:load-failed-with-tls-errors.
Alternatively, you can use
webkit_web_context_set_tls_errors_policy() to set the policy
ignore; however, this is not appropriate
for Internet applications.
The <WebKitMemoryPressureSettings>
applied to the web processes created by this context.
Its value is a
<WebKitMemoryPressureSettings>, or
#f.
It can only be set when the object is made, with
#:memory-pressure-settings. It cannot be read.
The timezone override for this web context. Setting this property provides a better alternative to configure the timezone information for all webviews managed by the WebContext. The other, less optimal, approach is to globally set the TZ environment variable in the process before creating the context. However this approach might not be very convenient and can have side-effects in your application.
The expected values for this property are defined in the IANA timezone database. See this wikipedia page for instance, https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
Its value is a string, or #f.
It can only be set when the object is made, with
#:time-zone-override.
Adds a path to be mounted in the sandbox.
path must exist before any web process has been created. It is a fatal error to add paths after a web process has been spawned.
Paths under /sys, /proc, and /dev are invalid.
Attempting to add all of / is not valid. Since 2.40, adding the
user’s entire home directory or /home is also not valid.
See also webkit_web_context_set_sandbox_enabled()
Passed: a <WebKitWebContext>.
Passed: a file name, as a string.
an absolute path to mount in the sandbox
Passed: a boolean.
if #t the path will be read-only
Returns the current cache model.
For more information about this value check the documentation of the
function web-context:set-cache-model.
Passed: a <WebKitWebContext>.
Returned: a <WebKitCacheModel>.
the current <WebKitCacheModel>
Gets the default web context.
Returned: a <WebKitWebContext>.
Get the <WebKitGeolocationManager> of
self.
Passed: a <WebKitWebContext>.
Returned: a <WebKitGeolocationManager>.
the <WebKitGeolocationManager> of
self.
Get the <WebKitNetworkSession> used for
automation sessions started in self.
Passed: a <WebKitWebContext>.
Returned: a <WebKitNetworkSession>, or
#f.
a <WebKitNetworkSession>, or #f if
automation is not enabled
Get the <WebKitSecurityManager> of
self.
Passed: a <WebKitWebContext>.
Returned: a <WebKitSecurityManager>.
the <WebKitSecurityManager> of self.
Get whether spell checking feature is currently enabled.
Passed: a <WebKitWebContext>.
Returned: a boolean.
#t If spell checking is enabled, or #f otherwise.
Get the the list of spell checking languages.
Get the the list of spell checking languages associated with self,
or #f if no languages have been previously set.
See web-context:set-spell-checking-languages
for more details on the format of the languages in the list.
Passed: a <WebKitWebContext>.
Returned: a vector, each a string.
A #f-terminated array of languages if available, or #f
otherwise.
Get the web-context:time-zone-override property.
Passed: a <WebKitWebContext>.
Returned: a string.
Sets initial desktop notification permissions for the self.
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.
This function only affects web processes that have not already been
created. The best time to call it is when handling
web-context:initialize-notification-permissions
so as to ensure that new web processes receive the most recent set of
permissions.
Passed: a <WebKitWebContext>.
Passed: a list, each a
<WebKitSecurityOrigin>.
a GList of security origins
Passed: a list, each a
<WebKitSecurityOrigin>.
a GList of security origins
Get whether automation is allowed in self.
See also web-context:set-automation-allowed.
Passed: a <WebKitWebContext>.
Returned: a boolean.
#t if automation is allowed or #f otherwise.
Create a new <WebKitWebContext>.
Returned: a <WebKitWebContext>.
a newly created <WebKitWebContext>
Register scheme in self.
Register scheme in self, 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
object:ref on the
<WebKitURISchemeRequest> and calling
urischeme-request:finish later
when the data of the request is available or urischeme-request:finish-error in case of error.
static void
about_uri_scheme_request_cb (WebKitURISchemeRequest *request,
gpointer user_data)
{
GInputStream *stream;
gsize stream_length;
const gchar *path = webkit_uri_scheme_request_get_path (request);
if (!g_strcmp0 (path, "memory")) {
// Create a GInputStream with the contents of memory about page, and set its length to stream_length
} else if (!g_strcmp0 (path, "applications")) {
// Create a GInputStream with the contents of applications about page, and set its length to stream_length
} else if (!g_strcmp0 (path, "example")) {
gchar *contents = g_strdup_printf ("<html><body><p>Example about page</p></body></html>");
stream_length = strlen (contents);
stream = g_memory_input_stream_new_from_data (contents, stream_length, g_free);
} else {
GError *error = g_error_new (ABOUT_HANDLER_ERROR, ABOUT_HANDLER_ERROR_INVALID, "Invalid about:%s page.", path);
webkit_uri_scheme_request_finish_error (request, error);
g_error_free (error);
return;
}
webkit_uri_scheme_request_finish (request, stream, stream_length, "text/html");
g_object_unref (stream);
}
Passed: a <WebKitWebContext>.
Passed: a string.
the network scheme to register
Passed: a procedure.
a WebKitURISchemeRequestCallback
See
WebKitURISchemeRequestCallback
for how it is called.
Not passed: guile-gi supplies it.
data to pass to callback function
Not passed: guile-gi supplies it.
destroy notify for user-data
See GDestroyNotify for how it is
called.
Send message to all web process extensions associated to self.
If message is floating, it’s consumed.
Passed: a <WebKitWebContext>.
Passed: a <WebKitUserMessage>.
Set whether automation is allowed in self.
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 web-context:automation-started is emitted.
Automation is disabled by default, so you need to explicitly call this
method passing #t to enable it.
Note that only one <WebKitWebContext> can have
automation enabled, so this will do nothing if there’s another
<WebKitWebContext> with automation already
enabled.
Passed: a <WebKitWebContext>.
Passed: a boolean.
value to set
Specifies a usage model for WebViews.
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 .
Research indicates that users tend to browse within clusters of documents that hold resources in common, and to revisit previously visited documents. WebKit and the frameworks below it include built-in caches that take advantage of these patterns, substantially improving document load speed in browsing situations. The WebKit cache model controls the behaviors of all of these caches, including various WebCore caches.
Browsers can improve document load speed substantially by specifying
web-browser. Applications without a browsing
interface can reduce memory usage substantially by specifying
document-viewer. The default value is
web-browser.
Passed: a <WebKitWebContext>.
Passed: a <WebKitCacheModel>, or one of its
symbols.
Set the list of preferred languages.
Set the list of preferred languages, sorted from most desirable to least desirable. The list will be used in the following ways:
Accept-Language HTTP header that
will be included in the network requests started by the
<WebKitWebContext>.
navigator.language and
navigator.languages.
Intl functions.
Passed: a <WebKitWebContext>.
Passed, or left out: a list or vector, each a string, or #f.
a #f-terminated list of language identifiers
Enable or disable the spell checking feature.
Passed: a <WebKitWebContext>.
Passed: a boolean.
Value to be set
Set the list of spell checking languages to be used for spell checking.
The locale string typically is in the form lang_COUNTRY, where lang is an ISO-639 language code, and COUNTRY is an ISO-3166 country code. For instance, sv_FI for Swedish as written in Finland or pt_BR for Portuguese as written in Brazil.
You need to call this function with a valid list of languages at least once in order to properly enable the spell checking feature in WebKit.
Passed: a <WebKitWebContext>.
Passed: a list or vector, each a string.
a #f-terminated list of spell checking languages
Set the directory where WebKit will look for web process extensions.
This method must be called before loading anything in this context,
otherwise it will not have any effect. You can connect to
web-context:initialize-web-process-extensions
to call this method before anything is loaded.
If your web process extension is installed to an unusual location, then
you may also need to call web-context:add-path-to-sandbox.
Passed: a <WebKitWebContext>.
Passed: a string.
the directory to add
Set user data to be passed to Web Extensions on initialization.
The data will be passed to the
WebKitWebProcessExtensionInitializeWithUserDataFunction. This
method must be called before loading anything in this context, otherwise
it will not have any effect. You can connect to web-context:initialize-web-process-extensions
to call this method before anything is loaded.
Passed: a <WebKitWebContext>.
Passed: a <GVariant>.
Connect a handler with (connect object
web-context:automation-started handler). It is called as
(handler self session).
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 web-context:set-automation-allowed for more
details.
Passed: a <WebKitWebContext>.
Passed: a <WebKitAutomationSession>.
the <WebKitAutomationSession> associated
with this event
Connect a handler with (connect object
web-context:initialize-notification-permissions handler). It is called
as (handler self).
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 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 web-context:initialize-notification-permissions
again.
Passed: a <WebKitWebContext>.
Connect a handler with (connect object
web-context:initialize-web-process-extensions handler). It is called
as (handler self).
This signal is emitted when a new web process is about to be launched.
It signals the most appropriate moment to use web-context:set-web-process-extensions-initialization-user-data
and web-context:set-web-process-extensions-directory.
Passed: a <WebKitWebContext>.
Connect a handler with (connect object
web-context:user-message-received handler). It is called as
(handler self message) ⇒ %return.
This signal is emitted when a
<WebKitUserMessage> is received from a web
process extension. You can reply to the message using
user-message:send-reply.
You can handle the user message asynchronously by calling
object:ref on message and
returning #t.
Passed: a <WebKitWebContext>.
Passed: a <WebKitUserMessage>.
the <WebKitUserMessage> received
Returned: a boolean.
#t if the message was handled, or #f otherwise.