Bug 835953: front-end for disabling getUserMedia notification when page stops using it r=dolske

This commit is contained in:
Randell Jesup 2013-02-15 19:54:30 -05:00
parent 3981afdc31
commit 030d86d9cd

View File

@ -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(
@ -205,3 +210,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);
}