register_uri_scheme
Description:
Register scheme
in this.
Register scheme
in this, so that when an URI request with scheme
is made in the
WebContext, the
URISchemeRequestCallback registered will be called with a
URISchemeRequest. It is possible to handle URI scheme requests
asynchronously, by calling @ref on the
URISchemeRequest and calling
finish later when the data of the request is available or
finish_error in case of error.
```c 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); } ```
Parameters:
this | |
scheme |
the network scheme to register |
callback | |
user_data |
data to pass to callback function |
user_data_destroy_func |
destroy notify for |