-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbackground.js
32 lines (29 loc) · 1 KB
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* background page, responsible for actually choosing media */
chrome.runtime.onMessageExternal.addListener(function (message, sender, callback) {
switch(message.type) {
case 'getScreen': {
var pending = chrome.desktopCapture.chooseDesktopMedia(
message.options || ['screen', 'window'],
sender.tab,
function (streamid) {
// communicate this string to the app so it can call getUserMedia with it
message.type = 'gotScreen';
message.sourceId = streamid;
callback(message);
return false;
}
);
return true; // retain callback for chooseDesktopMedia result
}
case 'cancelGetScreen': {
chrome.desktopCapture.cancelChooseDesktopMedia(message.request);
message.type = 'canceledGetScreen';
callback(message);
return false; //dispose callback
}
case 'isInstalled': {
callback({ installed: true, extensionId: chrome.runtime.id });
return false; //dispose callback
}
}
});