Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interprocess communication between browser extension and native application

How can an interprocess communication be estabilished between a browser extension and a native application? Is there any cross-platform (Linux and Mac OS X) and cross-browser solution (Firefox, Chrome, Safari)?

The only idea that comes to my mind is using native Web technologies, i.e. embed a HTTP server in native application and use XmlHttpRequest or WebSockets. However, this sounds like clunky overkill with handful of issues (e.g. security). Is there a better alternative?

like image 774
el.pescado - нет войне Avatar asked Apr 23 '14 20:04

el.pescado - нет войне


People also ask

Can Chrome extensions communicate with each other?

In addition to sending messages between different components in your extension, you can use the messaging API to communicate with other extensions.

What is native messaging in Chrome?

Native messaging enables an extension to exchange messages with a native application, installed on the user's computer. The native messaging serves the extensions without additional accesses over the web.

What is native messaging trace host?

The native app host sends and receives messages with extensions using standard input and standard output. Extensions that use native messaging are installed in Microsoft Edge similar to any other extension. However, native apps aren't installed or managed by Microsoft Edge.


1 Answers

I believe the most commonly used method is websocket connections. Two examples I can think of are 1Password and LiveReload (source code available).

As far as I know, you need to open the websocket connection from within your global page to avoid cross-domain restrictions.

Also, in the past I have seen other apps watch and modify an extension's settings file. The extension just reads and writes from it's own settings store, while the other process watches the preferences file for changes. I believe this is less reliable and doesn't conform to sandboxing requirements for the Mac App Store so I would recommend the websockets method.

like image 193
Matt Swain Avatar answered Oct 13 '22 10:10

Matt Swain