0
votes

So I wrote a question here earlier about opening native software (browsers) in my chrome application with PNaCl,NaCl, or NPAPI which I guess are not allowed anymore or were never allowed depending on which we are talking about. So a user pointed me to Native Messaging, and I am just trying to create something that will open a users HTML file in a browser they chose.

So they have index.html and they want to test it in Firefox, Chrome, and IE so they run each one and test.

Documentation

https://developer.chrome.com/extensions/nativeMessaging

Example from Google http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/nativeMessaging/host/

This is my first time dealing with this stuff and I don't want to have my users go to a REGEDIT file and add it and blah blah blah. It should be simple as possible, they download my app and it's done.

Native Messaging Manifest --- (which not 100% sure where to put it)

{
    "name": "com.kandidesigns.kodex",
    "description": "Kodex is a Chrome Application to make programming websites easier and efficient",
    "path": "C:\\Program Files\\My Application\\chrome_native_messaging_host.exe",
    "type": "stdio", //standard input or standard output not sure which one to use
     "allowed_origins": [
        "chrome-extension://bbbgompnaiddjohgmdhmienllkjkilap/"
      ]
}

Permissions have inside the apps manifest : "nativeMessaging"

BATCH program to run a file

SET /p ID="Enter browser"
SET /p URL="Enter URL"
IF "%ID%"=="0" start chrome %URL%
IF "%ID%"=="1" start firefox %URL%
IF "%ID%"=="2" start edge %URL%
IF "%ID%"=="3" start internet explorer %URL%
IF "%ID%"=="4" start safari %URL%
ELSE ECHO "No browser found by that classification"

Never wrote a bat file to figure out where to go and what to open etc... Here is another tutorial I've watched which is very low and pathetic sorry.

https://www.youtube.com/watch?v=H82-9hg1Plg

Anyways if someone could lead me the right way and assist on this I'd be greatly appreciated.

1

1 Answers

0
votes

The manifest file they are referring to is an independent file, not to be confused with your application manifest. Just declare a new json file, and introduce the code for the manifest (in the documentation, the file should be named nmh-manifest.json). The file can be located anywhere in the system file, but you'll need to describe the full path.

Here is a reference for a demo app implementing Native Messaging: https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/docs/examples/api/nativeMessaging