JS accessing mojo service in Utility process

190 views
Skip to first unread message

Peter Qiu

unread,
Oct 19, 2018, 4:23:33 PM10/19/18
to chromium-mojo, Adam Whiteside
Hi All,

I am wondering if it is possible to have JavaScript connect/bind to an interface exposed by a mojo service running in a Utility process. And is there example code that I can follow if this is possible?

There was some discussions regarding JS accessing mojo interfaces hosted by browser process, but some of the code links seems to be out-dated.

Thanks,
Peter,

Ken Rockot

unread,
Oct 19, 2018, 4:39:24 PM10/19/18
to Peter Qiu, chromium-mojo, awhit...@google.com
Depends where the JS is running. We let WebUI pages access Mojo IDL natives like Mojo.bindInterface(), which essentially lets you pass an interface request to the document's RenderFrameHost. There are then generated JS bindings which you can use to build on top of that.

The detail of how your interface request gets routed to a service process is really up to you, since JS can only send requests to the frame host. You have to plug in browser-side code to, e.g., route specific requests onward to a service.

--
You received this message because you are subscribed to the Google Groups "chromium-mojo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-moj...@chromium.org.
To post to this group, send email to chromi...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-mojo/1094960d-a7ff-4a2e-ae5d-eeb688019913%40chromium.org.

Ken Rockot

unread,
Oct 19, 2018, 4:40:23 PM10/19/18
to Peter Qiu, chromium-mojo, awhit...@google.com
FWIW you can also access Mojo IDL natives in any document context if you run Chrome with --enable-blink-features=MojoJS

Peter Qiu

unread,
Oct 20, 2018, 5:21:53 PM10/20/18
to Ken Rockot, awhit...@google.com, chromium-mojo
Ken, thanks for the info. We will look into it.

maco...@azet.sk

unread,
Nov 8, 2018, 2:02:47 AM11/8/18
to chromium-mojo, awhit...@google.com


Dňa piatok, 19. októbra 2018 22:23:33 UTC+2 Peter Qiu napísal(-a):
Reply all
Reply to author
Forward
0 new messages