summaryrefslogtreecommitdiff
path: root/embed
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2014-02-21 10:03:35 +0100
committerCarlos Garcia Campos <carlosgc@gnome.org>2014-02-21 13:10:49 +0100
commitbfdafa8240deb9307078bf09ebbcc9290b1e6528 (patch)
treeb601fafc966f3eeaa33be2f23a067ebc6ef0e5a0 /embed
parent7393c9a4db71319967b554ea1fdd94c644a573c6 (diff)
downloadepiphany-bfdafa8240deb9307078bf09ebbcc9290b1e6528.tar.gz
Add ephy-resource:// custom URI scheme implementation
Ideally we could use resource:// URIs since they are supported by both WebKit and libsoup, but the web process doesn't have access to the resources compiled in the UI process. And in multiprocess mode, the network process doesn't have access to the resources either. ephy-resource:// URIs are like a proxy to load gresources compiled in the UI process, the data is sent directly to the web process in single process mode or to the network process in multiprocess mode. https://bugzilla.gnome.org/show_bug.cgi?id=724862
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-embed-shell.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 0efa01260..48fd2bbfc 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -450,6 +450,31 @@ about_request_cb (WebKitURISchemeRequest *request,
}
static void
+ephy_resource_request_cb (WebKitURISchemeRequest *request)
+{
+ const char *path;
+ GInputStream *stream;
+ gsize size;
+ GError *error = NULL;
+
+ path = webkit_uri_scheme_request_get_path (request);
+ if (!g_resources_get_info (path, 0, &size, NULL, &error)) {
+ webkit_uri_scheme_request_finish_error (request, error);
+ g_error_free (error);
+ return;
+ }
+
+ stream = g_resources_open_stream (path, 0, &error);
+ if (stream) {
+ webkit_uri_scheme_request_finish (request, stream, size, NULL);
+ g_object_unref (stream);
+ } else {
+ webkit_uri_scheme_request_finish_error (request, error);
+ g_error_free (error);
+ }
+}
+
+static void
initialize_web_extensions (WebKitWebContext* web_context,
EphyEmbedShell *shell)
{
@@ -574,6 +599,11 @@ ephy_embed_shell_startup (GApplication* application)
webkit_security_manager_register_uri_scheme_as_local (webkit_web_context_get_security_manager (web_context),
EPHY_ABOUT_SCHEME);
+ /* ephy-resource handler */
+ webkit_web_context_register_uri_scheme (web_context, "ephy-resource",
+ (WebKitURISchemeRequestCallback)ephy_resource_request_cb,
+ NULL, NULL);
+
/* Store cookies in moz-compatible SQLite format */
cookie_manager = webkit_web_context_get_cookie_manager (web_context);
filename = g_build_filename (ephy_dot_dir (), "cookies.sqlite", NULL);