On Tue, May 4 2021 at 08:07:00 AM +0200, linux...@tin.it wrote:
I noticed that there is a very similar signal also in
webkit, but to use it one has to use an extension which, it seems to
me, has to be an external library. Even if I could try to write and
compile a similar library, then the dialog between the library and the
main application would be quite complicated, I think.

This is the only way to do it. You need to use the WebKitWebPage::send-request signal. Return TRUE to cancel the resource load, or FALSE to continue the load. WebKitWebPage is a web process object: you wouldn't want this API in the UI process because then the web process to have to wait on IPC to the UI process for every single resource to be loaded.

Writing a web process extension is easy, don't worry. Especially so when you only have one signal to implement. There are plenty of examples out there, e.g.:

https://gitlab.gnome.org/GNOME/epiphany/-/blob/6be2365125f7c3710635aabb1aeed420df5d84c7/embed/web-process-extension/ephy-web-process-extension.c.

Except your extension will be much simpler than that. You connect to WebKitWebExtension::page-created in your WebKitWebKitensionInitializeFunction, and in your page-created callback you can connect to WebKitWebPage::send-request. And that's about it.

Compiling it into a shared object is easy too, e.g.:

https://gitlab.gnome.org/GNOME/epiphany/-/blob/6be2365125f7c3710635aabb1aeed420df5d84c7/embed/web-process-extension/meson.build#L23

Good luck,

Michael


_______________________________________________
webkit-gtk mailing list
webkit-gtk@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-gtk

Reply via email to