-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Hi,
I've managed to get the integration plugin working. In the Extension - main.js file, need to change first line of 'sendMessage' function to:
sendMessage: function(application, parameters) {
port = chrome.runtime.connectNative("com.ugetdm.integration");
port.onDisconnect.addListener(Main.onDisconnected);
port.postMessage({"application": application, "parameters": parameters});
}
Also need to alter default configure argument so that com.ugetdm.integration.json for the messaging host is installed at $HOME/.config/chromium/NativeMessagingHost and ensure that the extension ID matches the
"allowed_origins": [ "chrome-extension://hefmjpopoalekinolodikjlckoocbana/" ]
in the aforementioned file.
From memory, I think that's what got it working. Sorry for my crummy md formatting, I hope that makes sense. I'd make a pull request, but I kinda suck at github...
I assume you'd have to make similar changes to support closed-source chrome. I found this documentation most helpful: https://developer.chrome.com/extensions/nativeMessaging
Linux (user-specific, default path)
Google Chrome: ~/.config/google-chrome/NativeMessagingHosts/com.my_company.my_application.json
Chromium: ~/.config/chromium/NativeMessagingHosts/com.my_company.my_application.json
And there is an example of how to use native messaging on that page too:
var port = chrome.runtime.connectNative('com.my_company.my_application');
port.onMessage.addListener(function(msg) {
console.log("Received" + msg);
});
port.onDisconnect.addListener(function() {
console.log("Disconnected");
});
port.postMessage({ text: "Hello, my_application" });
This approach also means the extension can be installed on per-user basis without root access.