diff --git a/browser/modules/webrtcUI.jsm b/browser/modules/webrtcUI.jsm index 53733d1f3a32..401445b46021 100644 --- a/browser/modules/webrtcUI.jsm +++ b/browser/modules/webrtcUI.jsm @@ -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); +}