Bug 1051855 - window sharing indicator on the URL bar stays on after stream.stop has been called, r=Gijs.

This commit is contained in:
Florian Quèze 2014-08-14 19:29:49 +02:00
parent 60d0603045
commit 018dbc7842

View File

@ -690,7 +690,7 @@ function updateIndicators() {
else if (window.value && !webrtcUI.showScreenSharingIndicator)
webrtcUI.showScreenSharingIndicator = "Window";
showBrowserSpecificIndicator(getBrowserForWindow(contentWindow));
updateBrowserSpecificIndicator(getBrowserForWindow(contentWindow));
}
let browserWindowEnum = Services.wm.getEnumerator("navigator:browser");
@ -724,7 +724,7 @@ function updateIndicators() {
}
}
function showBrowserSpecificIndicator(aBrowser) {
function updateBrowserSpecificIndicator(aBrowser) {
let camera = {}, microphone = {}, screen = {}, window = {};
MediaManagerService.mediaCaptureWindowState(aBrowser.contentWindow,
camera, microphone, screen, window);
@ -735,9 +735,6 @@ function showBrowserSpecificIndicator(aBrowser) {
captureState = "Camera";
} else if (microphone.value) {
captureState = "Microphone";
} else if (!screen.value && !window.value) {
Cu.reportError("showBrowserSpecificIndicator: got neither video nor audio access");
return;
}
let chromeWin = aBrowser.ownerDocument.defaultView;
@ -796,10 +793,15 @@ function showBrowserSpecificIndicator(aBrowser) {
chromeWin.PopupNotifications.show(aBrowser, "webRTC-sharingDevices", message,
anchorId, mainAction, secondaryActions, options);
}
else {
removeBrowserNotification(aBrowser,"webRTC-sharingDevices");
}
// Now handle the screen sharing indicator.
if (!screen.value && !window.value)
if (!screen.value && !window.value) {
removeBrowserNotification(aBrowser,"webRTC-sharingScreen");
return;
}
options = {
hideNotNow: true,
@ -820,15 +822,14 @@ function showBrowserSpecificIndicator(aBrowser) {
mainAction, secondaryActions, options);
}
function removeBrowserSpecificIndicator(aSubject, aTopic, aData) {
let browser = getBrowserForWindowId(aData);
let PopupNotifications = browser.ownerDocument.defaultView.PopupNotifications;
if (!PopupNotifications)
return;
for (let notifId of ["webRTC-sharingDevices", "webRTC-sharingScreen"]) {
let notification = PopupNotifications.getNotification(notifId, browser);
if (notification)
PopupNotifications.remove(notification);
}
function removeBrowserNotification(aBrowser, aNotificationId) {
let win = aBrowser.ownerDocument.defaultView;
let notification =
win.PopupNotifications.getNotification(aNotificationId, aBrowser);
if (notification)
win.PopupNotifications.remove(notification);
}
function removeBrowserSpecificIndicator(aSubject, aTopic, aData) {
updateBrowserSpecificIndicator(getBrowserForWindowId(aData));
}