mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 17:55:50 +00:00
Bug 1634703 - Have the webrtcUI module track which windows are being shared. r=florian
Differential Revision: https://phabricator.services.mozilla.com/D73483
This commit is contained in:
parent
c5a8e8d361
commit
ab2b2aaf18
@ -21,6 +21,11 @@ ChromeUtils.defineModuleGetter(
|
|||||||
"PluralForm",
|
"PluralForm",
|
||||||
"resource://gre/modules/PluralForm.jsm"
|
"resource://gre/modules/PluralForm.jsm"
|
||||||
);
|
);
|
||||||
|
ChromeUtils.defineModuleGetter(
|
||||||
|
this,
|
||||||
|
"BrowserWindowTracker",
|
||||||
|
"resource:///modules/BrowserWindowTracker.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
var webrtcUI = {
|
var webrtcUI = {
|
||||||
initialized: false,
|
initialized: false,
|
||||||
@ -50,6 +55,14 @@ var webrtcUI = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
SHARING_NONE: 0,
|
||||||
|
SHARING_WINDOW: 1,
|
||||||
|
SHARING_SCREEN: 2,
|
||||||
|
|
||||||
|
// Set of browser windows that are being shared over WebRTC.
|
||||||
|
sharedWindows: new WeakSet(),
|
||||||
|
sharingScreen: false,
|
||||||
|
|
||||||
// Map of browser elements to indicator data.
|
// Map of browser elements to indicator data.
|
||||||
perTabIndicators: new Map(),
|
perTabIndicators: new Map(),
|
||||||
activePerms: new Map(),
|
activePerms: new Map(),
|
||||||
@ -264,6 +277,42 @@ var webrtcUI = {
|
|||||||
state: aData,
|
state: aData,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let sharedWindowRawDeviceIds = new Set();
|
||||||
|
this.sharingScreen = false;
|
||||||
|
for (let stream of this._streams) {
|
||||||
|
let { state } = stream;
|
||||||
|
for (let device of state.devices) {
|
||||||
|
if (!device.scary) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mediaSource = device.mediaSource;
|
||||||
|
|
||||||
|
if (mediaSource == "window") {
|
||||||
|
sharedWindowRawDeviceIds.add(device.rawId);
|
||||||
|
} else if (mediaSource == "screen") {
|
||||||
|
this.sharingScreen = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sharedWindows = new WeakSet();
|
||||||
|
|
||||||
|
for (let win of BrowserWindowTracker.orderedWindows) {
|
||||||
|
let rawDeviceId;
|
||||||
|
try {
|
||||||
|
rawDeviceId = win.windowUtils.webrtcRawDeviceId;
|
||||||
|
} catch (e) {
|
||||||
|
// This can theoretically throw if some of the underlying
|
||||||
|
// window primitives don't exist. In that case, we can skip
|
||||||
|
// to the next window.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (sharedWindowRawDeviceIds.has(rawDeviceId)) {
|
||||||
|
this.sharedWindows.add(win);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -463,6 +512,15 @@ var webrtcUI = {
|
|||||||
gIndicatorWindow = null;
|
gIndicatorWindow = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getWindowShareState(window) {
|
||||||
|
if (this.sharingScreen) {
|
||||||
|
return this.SHARING_SCREEN;
|
||||||
|
} else if (this.sharedWindows.has(window)) {
|
||||||
|
return this.SHARING_WINDOW;
|
||||||
|
}
|
||||||
|
return this.SHARING_NONE;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function getGlobalIndicator() {
|
function getGlobalIndicator() {
|
||||||
|
Loading…
Reference in New Issue
Block a user