[webkit-gtk] [URI scheme] eBook application

Robert Schroll rschroll at gmail.com
Mon Jun 23 15:33:52 PDT 2014


On Sun, Jun 22, 2014 at 3:30 AM, Marta Milaković 
<marta.milakovic at gmail.com> wrote:
> I would like to know if there a way I could redirect all the requests 
> to use predefined URI scheme? Or maybe you know of some other 
> solution that might work.

I admit that I don't quite understand the question, so I may be telling 
you something irrelevant, but: By connecting to the 
resource_request_starting signal of your WebView, you can intercept and 
manipulate any request as it's going out.  We use this in Geary to 
allow the loading of only white-listed resources.  In the HTML, we 
added a special URI scheme to these resources.  Then, in the 
resource_request_starting handler, we block all requests without that 
scheme and strip that scheme off white-listed requests before allowing 
them to continue.  Maybe you can do something similar?  Our code is 
here: 
https://git.gnome.org/browse/geary/tree/src/client/conversation-viewer/conversation-web-view.vala#n92

That said, I'm not sure why you want to avoid having a HTTP server.  
About a year ago, I spent a weekend throwing together a basic Epub 
reader using Python and WebKitGTK.  It was pretty easy to make a simple 
server that returned bits of the Epub file as they were needed.  I 
guess there's no use in letting that code rot on my machine, so I've 
thrown it up on Github: https://github.com/rschroll/berg.  Please take 
whatever you'd like from it -- I'm excited that GNOME will be getting a 
first-class Epub reader!

Hope that helps,
Robert





More information about the webkit-gtk mailing list