[webkit-gtk] Selective blocking of image requests

Ben Boeckel mathstuf at gmail.com
Wed Aug 28 20:44:11 PDT 2013


[Sorry for digging up an old thread.]

On Mon, 25 Mar, 2013 at 07:18:00 GMT, Carlos Garcia Campos wrote:
> Yes, there's a low-level API called Web Extensions API[1], that allow
> you to run code in the Web process. In such API there's
> WebKitWebPage::send-request signal[2] that you can connect to intercept
> any resource request for a page. You don't need to change the URI to
> about:blank, simply return TRUE from the callback and the request won't
> be sent.=20
>
> To use the Web Extensions API you need to provide a plugin with an
> initialization function[3] that receives a WebKitWebExtension object[4]
> and tell the UI process where your plugin is[5]. You can connect to the
> WebKitWebExtension::page-created signal[6] to be notified when a web
> page is created and get the pointer to the WebKitWebPage to connect a
> callback to send-request signal.
>
> You have examples of how to do this in Epiphany[7], although the ephy
> web extension is a lot more complex. To implement only the send-request
> feature you don't need any communication with between the UI process and
> your extension.=20
>
>> Thanks for any help!
>
> Hope it helps, if you have any other question, do not hesitate to ask
> here or in the IRC channel.=20
>
> [1] http://www.webkitgtk.org/reference/webkit2gtk/unstable/ch02.html
> [2] http://www.webkitgtk.org/reference/webkit2gtk/unstable/WebKitWebPage.html#WebKitWebPage-send-request
> [3] http://www.webkitgtk.org/reference/webkit2gtk/unstable/WebKitWebExtension.html#WebKitWebExtensionInitializeFunction
> [4] http://www.webkitgtk.org/reference/webkit2gtk/unstable/WebKitWebExtension.html
> [5] http://www.webkitgtk.org/reference/webkit2gtk/unstable/WebKitWebContext.html#webkit-web-context-set-web-extensions-directory
> [6] http://www.webkitgtk.org/reference/webkit2gtk/unstable/WebKitWebExtension.html#WebKitWebExtension-page-created
> [7] https://git.gnome.org/browse/epiphany/tree/embed/web-extension

Could this information be put into the docs (ideally before 2.2.0)? The
docs just give a typedef for the function to implement, not a name for
it. Some docs on what an extension could be used for would be great as
well.

Thanks,

--Ben



More information about the webkit-gtk mailing list