MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
431 stars 51 forks source link

[Feature] [Extensions]: Native/Extension communication #3851

Open RendijsSmukulis opened 10 months ago

RendijsSmukulis commented 10 months ago

Describe the feature/enhancement you need

To allow any UI interaction with the extensions in our app, or to shim (modify) some of the chrome extension APIs, we first had to establish a way to communicate between our app and the extension. The currently selected method is to:

  1. attach a chrome devtools session to the extension through "Target.attachToTarget"
  2. for extension-to-app communication, "Runtime.bindingCalled" is called to create a method on the extension JS side, calling which will invoke the "Runtime.bindingCalled" event on app side
  3. for app-to-extension communication, we have multiple approaches, e.g. directly calling JS code from app through "Runtime.evaluate"

However, it would significantly ease any interop work if WebView2 provided same message exchange API for extensions as it does for webpages (https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/communicate-btwn-web-native)

The scenario/use case where you would use this feature

As we're building a browser with intention to host extensions, some amount of app-to-extension communication needs to happen as we need to re-implement some of the chrome extension APIs, e.g. chrome.tabs.query

How important is this request to you?

Nice to have. There are other ways to tackle this, but having official API support would be beneficial.

Suggested implementation

No response

What does your app do? Is there a pending deadline for this request?

No response

AB#46892739

darbid commented 10 months ago

Maybe a dumb question but why does the standard extension native messaging not work?