Bug 136867 - Should have a way to register GResources in web process
Summary: Should have a way to register GResources in web process
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Enhancement
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-16 13:56 PDT by Philip Chimento
Modified: 2017-03-11 10:54 PST (History)
2 users (show)

See Also:


Attachments
Sample package demonstrating the problem (286.65 KB, application/x-gzip)
2014-09-16 13:56 PDT, Philip Chimento
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Chimento 2014-09-16 13:56:04 PDT
Created attachment 238207 [details]
Sample package demonstrating the problem

Currently, for loading an HTML page from a GResource, such as:

webkit_web_view_load_uri (view, "resource:///com/example/my/resource/index.html");

you need to write a WebKitWebExtension and either compile the GResource into the extension, or call g_resource_load() and g_resources_register() in the extension's init function. It would be convenient to provide some API such as webkit_web_view_register_gresource(view, "/path/to/my.gresource").

See the attached tarball for a little program that demonstrates the problem. If you do not load the extension, then you get this message:

> The resource at '/com/example/WebKitTestGResource/resource.html' does not exist

Of course a workaround would be to load the contents of the GResource URI in the calling program, and feed it to WebKit with webkit_web_view_load_html(), but that disallows the HTML page from referencing other files in the GResource (which is why I included a CSS file in the example GResource as well.)
Comment 1 Carlos Garcia Campos 2014-09-21 23:48:48 PDT
(In reply to comment #0)
> Created an attachment (id=238207) [details]
> Sample package demonstrating the problem
> 
> Currently, for loading an HTML page from a GResource, such as:
> 
> webkit_web_view_load_uri (view, "resource:///com/example/my/resource/index.html");
> 
> you need to write a WebKitWebExtension and either compile the GResource into the extension, or call g_resource_load() and g_resources_register() in the extension's init function.

And that wouldn't be enough either, if you use multi-webprocess model, the network process needs to access the gresource as well.

> It would be convenient to provide some API such as webkit_web_view_register_gresource(view, "/path/to/my.gresource").

This might work, since we would notify the networking process to load the resources.
 
> See the attached tarball for a little program that demonstrates the problem. If you do not load the extension, then you get this message:
> 
> > The resource at '/com/example/WebKitTestGResource/resource.html' does not exist
> 
> Of course a workaround would be to load the contents of the GResource URI in the calling program, and feed it to WebKit with webkit_web_view_load_html(), but that disallows the HTML page from referencing other files in the GResource (which is why I included a CSS file in the example GResource as well.)

You could use a custom uri scheme, but all gresources would be loaded by the UI process and sent to the networking process.
Comment 2 Philip Chimento 2014-09-22 00:04:51 PDT
> > Of course a workaround would be to load the contents of the GResource URI in the calling program, and feed it to WebKit with webkit_web_view_load_html(), but that disallows the HTML page from referencing other files in the GResource (which is why I included a CSS file in the example GResource as well.)
>
> You could use a custom uri scheme, but all gresources would be loaded by the UI process and sent to the networking process.

I thought about that, but wouldn't that potentially send large amounts of data through IPC?