<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 13, 2017 at 12:15 PM, Adrian Perez de Castro <span dir="ltr"><<a href="mailto:aperez@igalia.com" target="_blank">aperez@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Wed, 13 Sep 2017 17:55:20 +0200, Jérémy Lal <<a href="mailto:kapouer@melix.org">kapouer@melix.org</a>> wrote:<br>
> Also it's simpler to setup a limited javascript -> main process event<br>
> listener using a "script message handler".<br>
<br>
</span>I was about to mention this :-)<br>
<br>
For the opposite direction (Main process -> JavaScript), you can use<br>
webkit_web_view_run_<wbr>javascript() and call code in the JS world:<br>
<br>
<a href="https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-run-javascript" rel="noreferrer" target="_blank">https://webkitgtk.org/<wbr>reference/webkit2gtk/stable/<wbr>WebKitWebView.html#webkit-web-<wbr>view-run-javascript</a></blockquote><div><br></div><div>Note, this callback does not provide a return value back to javascript. It is useful if no return value is needed.</div><div>If return value is needed, the webextension route has to be taken<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
As a complement to the above, if you need to add extra glue code to the JS<br>
world that is not included in your loaded web content, you can use<br>
webkit_user_content_manager_<wbr>add_script() to inject JS code from the main<br>
process:<br>
<br>
<a href="https://webkitgtk.org/reference/webkit2gtk/stable/WebKitUserContentManager.html#webkit-user-content-manager-add-script" rel="noreferrer" target="_blank">https://webkitgtk.org/<wbr>reference/webkit2gtk/stable/<wbr>WebKitUserContentManager.html#<wbr>webkit-user-content-manager-<wbr>add-script</a><br>
<br>
Hope this helps!<br>
<br>
<br>
--<br>
Adrián 🎩<br>
<br>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Leo Ufimtsev, Software Engineer, Red Hat</div>
</div></div>