[webkit-gtk] Q: How to synchronise UI process and web process extension?

Albrecht Dreß albrecht.dress at netcologne.de
Fri Jul 30 12:17:29 PDT 2021


Hi all,

I want to implement content blocking for external material loaded from HTML messages in a MUA (balsa).  Unfortunately, webkit_settings_set_auto_load_images() is not a solution, as I still want to display embedded images in the email, but I also want to suppress loading external styles, etc.  The blocking shall work on a per-message basis, e.g. it shall always be allowed for some senders, but only after user permission for others.

 From [1] I understand that I have to use the WebKitWebPage::send-request signal in an extension.  So I wrote an extension which

(1) connects the page "page-created" signal in webkit_web_extension_initialize();
(2) the callback for (1)
     (a) sends a message using webkit_web_page_send_message_to_view() to get the blocking settings for the particular message, and
     (b) connects to the "send-request" signal.

This seems to work just fine, but I feel that I need some synchronisation between the main UI and the web process:

When the callback for (2b), i.e. for "send-request", is called, I must ensure that the reply from the main UI process with the decision if external material shall be loaded for the particular instance (email) has already been received, i.e. the callback registered in step (2a) has already been called.  IOW, the callback (2b) must not be called before the callback (2a) has been processed, or I have to somehow "delay" the web process until this reply has been received.

Is this possible?  How?

Thanks in advance for any insight,
best,
Albrecht.


[1] <https://lists.webkit.org/pipermail/webkit-gtk/2021-May/003704.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.webkit.org/pipermail/webkit-gtk/attachments/20210730/cddce2bc/attachment.bin>


More information about the webkit-gtk mailing list