Yeah, sorry, I made a little bit messy mail. Small explanation of what I did.
I am using *webkit_web_context_register_uri_scheme <http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebContext.html#webkit-web-context-register-uri-scheme>* to register my scheme, lets say *book*. Then I make an URL request with the registered scheme for the *html* file *ex1.html*: *webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), "book:ex1.html").* Two cases are: *1. ex1.html* file contains relative path to the image: * <img src="*img*.jpg" alt="title page"/>* *2. ex1.html* file contains absolute path to the image: * <img src="book:*img*.jpg" alt="title page"/>* In the first case when I use a relative path *WebKitURISchemeRequestCallback* <http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebContext.html#WebKitURISchemeRequestCallback> isn't being called. In the other case, when I use an absolute path (with the registered scheme) the callback is called. The question is why doesn't it work for the first case? Of course, if I check document.URL it gives: book:ex1.html, so the requested URL should be book:img.jpg. Thanks for the answers, Marta ᐧ On Tue, Jun 24, 2014 at 12:33 AM, Robert Schroll <[email protected]> wrote: > On Sun, Jun 22, 2014 at 3:30 AM, Marta Milaković < > [email protected]> 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 > > > > -- Marta Milaković
_______________________________________________ webkit-gtk mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-gtk
