-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal for runtime.onConnectNative
Event
#457
Comments
FWIW, this is implemented in Chrome dev channel, disabled by default, enabled via --enable-features=OnConnectNative command line, see https://crbug.com/967262 for more implementation details. |
Discussed this at the WECG Meet-Up. We agreed the general shape of this looks fine. We don't have immediate plans on the Chrome side to expand this past dev channel, but in case we do decide to expand this on a later date, please take a look at the Chrome version and let's discuss if there are any changes that would need to be made from the Chrome signature. |
It's worth noting that Chrome's implementation has several requirements before a "connection" can be established between the native messaging app and the browser:
|
Currently, web extensions are required to initiate communication with native apps via
runtime.connectNative
. This approach has limitations. For example, Safari always allows native apps to send messages to an extension, and will hold these messages in a queue until the extension callsruntime.connectNative
. To address this issue, I propose the addition of aruntime.onConnectNative
event.For example:
The
port.name
property would serve as an identifier for the native app, matching thename
parameter used inruntime.connectNative(name)
. In Safari's specific scenario with a containing app delivery mechanism, thename
parameter is optional for outgoing connections from the extension. Nonetheless, incoming connections from native apps should always include an app identifier in theport.name
property.To control which native apps can connect, a new
app_ids
field could be added to theexternally_connectable
section of the manifest. This field could also potentially support wildcard entries, like the existingids
field for external extension connections. Despite this, the browser would reserve the right to allow or deny app connections at its discretion.For instance:
On the native app side, error-handling mechanisms will be crucial for cases where the extension is either not loaded or restricted from connecting due to manifest or browser constraints; however, this falls outside the scope of this group but is worth mentioning for a complete developer narrative.
The text was updated successfully, but these errors were encountered: