0
votes

The new Microsoft Edge program is now open to accept chromium-based extensions for the new Microsoft Edge (ver. 77 or above). I have tested my chrome extension on Edge browser and it gets installed in Edge browser. I am trying to reuse the native host in Edge browser which is developed for Chrome browser. But somehow it is not working.

Does anyone has any idea about how to support the chrome native host in Edge browser? or do I need to implement the native host by using UWP?

I have tried communicationg with native host from my edge extension but getting the "Unchecked runtime.lastError: Specified native messaging host not found." Error. code from .js file

var hostname = "com.microsoft.edge.myExtension";
port = chrome.runtime.connectNative(hostname);

Manifest(com.microsoft.edge.myExtension.json) file for my native host

    "name": "com.microsoft.edge.myExtension",
    "description": "My Native Host",
    "path": "C:\\EdgeNativeHost.exe",
    "type": "stdio",
    "allowed_origins": [
        "extension://pbdancjikoidhjcgkfpipggnhlackjpe/"
    ]
}

Added registry key by running shell command

REG ADD "HKCU\Software\Microsoft\Edge\NativeMessagingHosts\com.microsoft.edge.myExtension" /ve /t REG_SZ /d "C:\com.microsoft.edge.myExtension.json" /f

Please let me know what's the wrong with me?

2

2 Answers

0
votes

Extensions written for Chromium, in most cases, run on Microsoft (Chromium) Edge with minimal changes. You could refer to this guide about how to port a Chrome Extension to Microsoft (Chromium) Edge.

You should check if you have used the following extension APIs which are not supported by Microsoft Edge:

The extension APIs and manifest keys supported by Chrome are code-compatible with Microsoft (Chromium) Edge. However, Microsoft Edge does not support the following Extension APIs:

  • chrome.gcm
  • chrome.identity.getAccounts
  • chrome.identity.getAuthToken
  • chrome.identity.getProfileUserInfo
  • chrome.instanceID

You should also re-brand the Extension for Microsoft Edge if you are using Chrome in the name or description of your Extension.

For native messaging host, you should especially note:

If your Extension exchanges messages with a native application using chrome.runtime.connectNative API, ensure that you set allowedorigins to "extension://[Microsoft-Catalog-extensionID]" in your native messaging host manifest file. This enables the app to identify the Extension.

For more information, you could refer to this article. The native messaging host location is also a little different from Chrome Extension. Google\Chrome in the registry key should be Microsoft\Edge.

0
votes

Sam,

According to the information you provided us, there is an issue in your registry configuration.

Note, that if your using "HKEY_LOCAL_MACHINE", the path has "Microsoft" in it instead of "Google"

Otherwise, you can use "HKEY_CURRENT_USER", in where the path has "Google" in it instead of "Microsoft."

Lastly, your key must have its default value set to the path of your native-message-host manifest.json file.

See below explanation from Microsoft's documentation

On Windows, the manifest file may be located anywhere in the file system. The application installer must create registry key

HKEY_LOCAL_MACHINE\SOFTWARE\ Microsoft\Edge \NativeMessagingHosts\com.my_company.my_application

or

HKEY_CURRENT_USER\SOFTWARE\ Google\Chrome \NativeMessagingHosts\com.my_company.my_application

Also mind you that there are some other requirements before it will work like setting the origin to your extensions's and that your manifest must have the 'path' value set to your native-message-host executable.