WebKitWebContext

WebKitWebContext

Synopsis

struct              WebKitWebContext;
enum                WebKitCacheModel;
WebKitWebContext *  webkit_web_context_get_default      (void);
WebKitCacheModel    webkit_web_context_get_cache_model  (WebKitWebContext *context);
void                webkit_web_context_set_cache_model  (WebKitWebContext *context,
                                                         WebKitCacheModel cache_model);
void                webkit_web_context_clear_cache      (WebKitWebContext *context);
WebKitDownload *    webkit_web_context_download_uri     (WebKitWebContext *context,
                                                         const gchar *uri);
WebKitCookieManager * webkit_web_context_get_cookie_manager
                                                        (WebKitWebContext *context);
void                webkit_web_context_set_additional_plugins_directory
                                                        (WebKitWebContext *context,
                                                         const gchar *directory);
void                webkit_web_context_get_plugins      (WebKitWebContext *context,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
GList *             webkit_web_context_get_plugins_finish
                                                        (WebKitWebContext *context,
                                                         GAsyncResult *result,
                                                         GError **error);
gboolean            webkit_web_context_get_spell_checking_enabled
                                                        (WebKitWebContext *context);
void                webkit_web_context_set_spell_checking_enabled
                                                        (WebKitWebContext *context,
                                                         gboolean enabled);
const gchar * const * webkit_web_context_get_spell_checking_languages
                                                        (WebKitWebContext *context);
void                webkit_web_context_set_spell_checking_languages
                                                        (WebKitWebContext *context,
                                                         const gchar * const *languages);
void                webkit_web_context_set_preferred_languages
                                                        (WebKitWebContext *context,
                                                         const gchar * const *languages);

void                (*WebKitURISchemeRequestCallback)   (WebKitURISchemeRequest *request,
                                                         gpointer user_data);
void                webkit_web_context_register_uri_scheme
                                                        (WebKitWebContext *context,
                                                         const gchar *scheme,
                                                         WebKitURISchemeRequestCallback callback,
                                                         gpointer user_data,
                                                         GDestroyNotify user_data_destroy_func);

Object Hierarchy

  GObject
   +----WebKitWebContext

Signals

  "download-started"                               : Run Last

Description

Details

struct WebKitWebContext

struct WebKitWebContext;


enum WebKitCacheModel

typedef enum {
    WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER,
    WEBKIT_CACHE_MODEL_WEB_BROWSER,
    WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER
} WebKitCacheModel;

Enum values used for determining the WebKitWebContext cache model.

WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER

Disable the cache completely, which substantially reduces memory usage. Useful for applications that only access a single local file, with no navigation to other pages. No remote resources will be cached.

WEBKIT_CACHE_MODEL_WEB_BROWSER

Improve document load speed substantially by caching a very large number of resources and previously viewed content.

WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER

A cache model optimized for viewing a series of local files -- for example, a documentation viewer or a website designer. WebKit will cache a moderate number of resources.

webkit_web_context_get_default ()

WebKitWebContext *  webkit_web_context_get_default      (void);

Gets the default web context

Returns :

(transfer none) a WebKitWebContext

webkit_web_context_get_cache_model ()

WebKitCacheModel    webkit_web_context_get_cache_model  (WebKitWebContext *context);

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

context :

the WebKitWebContext

Returns :

the current WebKitCacheModel

webkit_web_context_set_cache_model ()

void                webkit_web_context_set_cache_model  (WebKitWebContext *context,
                                                         WebKitCacheModel cache_model);

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 WEBKIT_CACHE_MODEL_WEB_BROWSER. Applications without a browsing interface can reduce memory usage substantially by specifying WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER. The default value is WEBKIT_CACHE_MODEL_WEB_BROWSER.

context :

the WebKitWebContext

cache_model :

a WebKitCacheModel

webkit_web_context_clear_cache ()

void                webkit_web_context_clear_cache      (WebKitWebContext *context);

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

context :

a WebKitWebContext

webkit_web_context_download_uri ()

WebKitDownload *    webkit_web_context_download_uri     (WebKitWebContext *context,
                                                         const gchar *uri);

Requests downloading of the specified URI string.

context :

a WebKitWebContext

uri :

the URI to download

Returns :

a new WebKitDownload representing the the download operation. [transfer full]

webkit_web_context_get_cookie_manager ()

WebKitCookieManager * webkit_web_context_get_cookie_manager
                                                        (WebKitWebContext *context);

Get the WebKitCookieManager of context.

context :

a WebKitWebContext

Returns :

the WebKitCookieManager of context. [transfer none]

webkit_web_context_set_additional_plugins_directory ()

void                webkit_web_context_set_additional_plugins_directory
                                                        (WebKitWebContext *context,
                                                         const gchar *directory);

Set an additional directory where WebKit will look for plugins.

context :

a WebKitWebContext

directory :

the directory to add

webkit_web_context_get_plugins ()

void                webkit_web_context_get_plugins      (WebKitWebContext *context,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

Asynchronously get the list of installed plugins.

When the operation is finished, callback will be called. You can then call webkit_web_context_get_plugins_finish() to get the result of the operation.

context :

a WebKitWebContext

cancellable :

a GCancellable or NULL to ignore. [allow-none]

callback :

a GAsyncReadyCallback to call when the request is satisfied. [scope async]

user_data :

the data to pass to callback function. [closure]

webkit_web_context_get_plugins_finish ()

GList *             webkit_web_context_get_plugins_finish
                                                        (WebKitWebContext *context,
                                                         GAsyncResult *result,
                                                         GError **error);

Finish an asynchronous operation started with webkit_web_context_get_plugins.

context :

a WebKitWebContext

result :

a GAsyncResult

error :

return location for error or NULL to ignore

Returns :

a GList of WebKitPlugin. You must free the GList with g_list_free() and unref the WebKitPlugins with g_object_unref() when you're done with them. [element-type WebKitPlugin][transfer full]

webkit_web_context_get_spell_checking_enabled ()

gboolean            webkit_web_context_get_spell_checking_enabled
                                                        (WebKitWebContext *context);

Get whether spell checking feature is currently enabled.

context :

a WebKitWebContext

Returns :

TRUE If spell checking is enabled, or FALSE otherwise.

webkit_web_context_set_spell_checking_enabled ()

void                webkit_web_context_set_spell_checking_enabled
                                                        (WebKitWebContext *context,
                                                         gboolean enabled);

Enable or disable the spell checking feature.

context :

a WebKitWebContext

enabled :

Value to be set

webkit_web_context_get_spell_checking_languages ()

const gchar * const * webkit_web_context_get_spell_checking_languages
                                                        (WebKitWebContext *context);

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

See webkit_web_context_set_spell_checking_languages() for more details on the format of the languages in the list.

context :

a WebKitWebContext

Returns :

A NULL-terminated array of languages if available, or NULL otherwise. [array zero-terminated=1][element-type utf8][transfer none]

webkit_web_context_set_spell_checking_languages ()

void                webkit_web_context_set_spell_checking_languages
                                                        (WebKitWebContext *context,
                                                         const gchar * const *languages);

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.

context :

a WebKitWebContext

languages :

a NULL-terminated list of spell checking languages. [array zero-terminated=1][transfer none]

webkit_web_context_set_preferred_languages ()

void                webkit_web_context_set_preferred_languages
                                                        (WebKitWebContext *context,
                                                         const gchar * const *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.

context :

a WebKitWebContext

languages :

a NULL-terminated list of language identifiers. [allow-none][array zero-terminated=1][element-type utf8][transfer none]

WebKitURISchemeRequestCallback ()

void                (*WebKitURISchemeRequestCallback)   (WebKitURISchemeRequest *request,
                                                         gpointer user_data);

Type definition for a function that will be called back when an URI request is made for a user registered URI scheme.

request :

the WebKitURISchemeRequest

user_data :

user data passed to the callback

webkit_web_context_register_uri_scheme ()

void                webkit_web_context_register_uri_scheme
                                                        (WebKitWebContext *context,
                                                         const gchar *scheme,
                                                         WebKitURISchemeRequestCallback callback,
                                                         gpointer user_data,
                                                         GDestroyNotify user_data_destroy_func);

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
static void
about_uri_scheme_request_cb (WebKitURISchemeRequest *request,
                             gpointer                user_data)
{
    GInputStream *stream;
    gsize         stream_length;
    const gchar  *path;

    path = webkit_uri_scheme_request_get_path (request);
    if (!g_strcmp0 (path, "plugins")) {
        /* Create a GInputStream with the contents of plugins about page, and set its length to stream_length */
    } else 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 {
        gchar *contents;

        contents = g_strdup_printf ("<html><body><p>Invalid about:%s page</p></body></html>", path);
        stream_length = strlen (contents);
        stream = g_memory_input_stream_new_from_data (contents, stream_length, g_free);
    }
    webkit_uri_scheme_request_finish (request, stream, stream_length, "text/html");
    g_object_unref (stream);
}

context :

a WebKitWebContext

scheme :

the network scheme to register

callback :

a WebKitURISchemeRequestCallback. [scope async]

user_data :

data to pass to callback function

user_data_destroy_func :

destroy notify for user_data

Signal Details

The "download-started" signal

void                user_function                      (WebKitWebContext *context,
                                                        WebKitDownload   *download,
                                                        gpointer          user_data)      : Run Last

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

context :

the WebKitWebContext

download :

the WebKitDownload associated with this event

user_data :

user data set when the signal handler was connected.