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:
Dão Gottwald 2013-02-16 11:10:41 +01:00
Родитель e46ca95a6c
Коммит 0760deb884
1 изменённых файлов: 23 добавлений и 8 удалений

Просмотреть файл

@ -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);
}