зеркало из https://github.com/mozilla/gecko-dev.git
Bug 835953 - Remove browser-specific notification when a page releases webcam/microphone access. r=dolske
--HG-- extra : rebase_source : 69454e2461746853981e0de7161be62c08f25f1a
This commit is contained in:
Родитель
e46ca95a6c
Коммит
0760deb884
|
@ -22,11 +22,13 @@ this.webrtcUI = {
|
|||
init: function () {
|
||||
Services.obs.addObserver(handleRequest, "getUserMedia:request", false);
|
||||
Services.obs.addObserver(updateGlobalIndicator, "recording-device-events", false);
|
||||
Services.obs.addObserver(removeBrowserSpecificIndicator, "recording-window-ended", false);
|
||||
},
|
||||
|
||||
uninit: function () {
|
||||
Services.obs.removeObserver(handleRequest, "getUserMedia:request");
|
||||
Services.obs.removeObserver(updateGlobalIndicator, "recording-device-events");
|
||||
Services.obs.removeObserver(removeBrowserSpecificIndicator, "recording-window-ended");
|
||||
},
|
||||
|
||||
showGlobalIndicator: false,
|
||||
|
@ -54,18 +56,21 @@ this.webrtcUI = {
|
|||
}
|
||||
}
|
||||
|
||||
function handleRequest(aSubject, aTopic, aData) {
|
||||
let {windowID: windowID, callID: callID} = JSON.parse(aData);
|
||||
|
||||
function getBrowserForWindowId(aWindowID) {
|
||||
let someWindow = Services.wm.getMostRecentWindow(null);
|
||||
let contentWindow = someWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils)
|
||||
.getOuterWindowWithId(windowID);
|
||||
let browser = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShell)
|
||||
.chromeEventHandler;
|
||||
.getOuterWindowWithId(aWindowID);
|
||||
return contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShell)
|
||||
.chromeEventHandler;
|
||||
}
|
||||
|
||||
function handleRequest(aSubject, aTopic, aData) {
|
||||
let {windowID: windowID, callID: callID} = JSON.parse(aData);
|
||||
|
||||
let browser = getBrowserForWindowId(windowID);
|
||||
let params = aSubject.QueryInterface(Ci.nsIMediaStreamOptions);
|
||||
|
||||
browser.ownerDocument.defaultView.navigator.mozGetUserMediaDevices(
|
||||
|
@ -211,3 +216,13 @@ function updateGlobalIndicator() {
|
|||
while (e.hasMoreElements())
|
||||
e.getNext().WebrtcIndicator.updateButton();
|
||||
}
|
||||
|
||||
function removeBrowserSpecificIndicator(aSubject, aTopic, aData) {
|
||||
let browser = getBrowserForWindowId(aData);
|
||||
let PopupNotifications = browser.ownerDocument.defaultView.PopupNotifications;
|
||||
let notification = PopupNotifications &&
|
||||
PopupNotifications.getNotification("webRTC-sharingDevices",
|
||||
browser);
|
||||
if (notification)
|
||||
PopupNotifications.remove(notification);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче