Google Chrome Extension compatibility in Node-webkit: How to make desktop/screen share work?
See original GitHub issueMy Situation:
I am working for a large hospital project where i need to use Node-Webkit (and stop depending on Opera, Google Chrome, Chromium 46). My biggest issue is right now desktop share (Which worked perfectly fine with Google Chrome and Chromium 46). But i need to make it compatible with node-webkit.
Problem in node-webkit:
If you open this URL in node-webkit https://talky.io/nodenode
then you can do WebRTC video/audio test calls fine.
But, then when you press desktop share button it does not work because the extension is in Google chrome webstore (try with Google chrome stable it works)
FYI: this is how we make extensions for Google chrome for that desktop share.
manifest.json:
{
"name": "Screen sharing",
"author": "iMeMySelf",
"description": "Screensharing BLABLA",
"homepage_url": "https://www.domain1.com/",
"version": "0.0.2",
"manifest_version": 2,
"minimum_chrome_version": "34",
"icons": {
"48" : "icon.png"
},
"permissions": [
"desktopCapture"
],
"background": {
"scripts": ["background.js"]
},
"content_scripts": [ {
"js": [ "content.js" ],
"all_frames": true,
"run_at": "document_start",
"matches": ["*://*.domain1.com/*", "*://*.domain2.com/*"]
}],
"web_accessible_resources": [
"icon.png"
]
}
background.js:
/* background page, responsible for actually choosing media */
chrome.runtime.onConnect.addListener(function (channel) {
channel.onMessage.addListener(function (message) {
switch(message.type) {
case 'getScreen':
//channel.sender.tab.url = 'https://nodewebkit.domain1.com';// this works for version 40
var pending = chrome.desktopCapture.chooseDesktopMedia(message.options || ['screen', 'window'],
channel.sender.tab, function (streamid) {
// communicate this string to the app so it can call getUserMedia with it
message.type = 'gotScreen';
message.sourceId = streamid;
channel.postMessage(message);
});
// let the app know that it can cancel the timeout
message.type = 'getScreenPending';
message.request = pending;
channel.postMessage(message);
break;
case 'cancelGetScreen':
chrome.desktopCapture.cancelChooseDesktopMedia(message.request);
message.type = 'canceledGetScreen';
channel.postMessage(message);
break;
}
});
});
content.js:
/* the chrome content script which can listen to the page dom events */
var channel = chrome.runtime.connect();
channel.onMessage.addListener(function (message) {
console.log('channel message', message);
window.postMessage(message, '*');
});
window.addEventListener('message', function (event) {
if (event.source != window)
return;
if (!event.data && (event.data.type == 'getScreen' || event.data.type == 'cancelGetScreen'))
return;
channel.postMessage(event.data);
});
How can we make that extensions compatible for Node webkit please?
<bountysource-plugin>
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (1 by maintainers)
Top GitHub Comments
Please ask questions in our mailing list: https://groups.google.com/forum/#!forum/nwjs-general