Bug 1865382 - Remove legacy WebRTC indicator implementation. r=pbz,fluent-reviewers,desktop-theme-reviewers,bolsson,emilio

Depends on D193933

Differential Revision: https://phabricator.services.mozilla.com/D193934
This commit is contained in:
Mike Conley 2023-11-27 16:43:32 +00:00
parent 73a56de07f
commit 5b77060db6
10 changed files with 0 additions and 534 deletions

View File

@ -57,7 +57,6 @@ browser/base/content/macWindow.inc.xhtml
browser/base/content/main-popupset.inc.xhtml
browser/base/content/pageinfo/pageInfo.xhtml
browser/base/content/webext-panels.xhtml
browser/base/content/webrtcLegacyIndicator.xhtml
browser/components/downloads/content/contentAreaDownloadsView.xhtml
browser/components/places/content/bookmarkProperties.xhtml
browser/components/places/content/bookmarksSidebar.xhtml

View File

@ -12,11 +12,6 @@ const { showStreamSharingMenu, webrtcUI } = ChromeUtils.importESModule(
"resource:///modules/webrtcUI.sys.mjs"
);
ChromeUtils.defineESModuleGetters(this, {
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs",
MacOSWebRTCStatusbarIndicator: "resource:///modules/webrtcUI.sys.mjs",
});
XPCOMUtils.defineLazyServiceGetter(
this,
"gScreenManager",

View File

@ -1,208 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const { webrtcUI } = ChromeUtils.importESModule(
"resource:///modules/webrtcUI.sys.mjs"
);
function init(event) {
for (let id of ["audioVideoButton", "screenSharePopup"]) {
let popup = document.getElementById(id);
popup.addEventListener("popupshowing", onPopupMenuShowing);
popup.addEventListener("popuphiding", onPopupMenuHiding);
popup.addEventListener("command", onPopupMenuCommand);
}
let fxButton = document.getElementById("firefoxButton");
fxButton.addEventListener("click", onFirefoxButtonClick);
fxButton.addEventListener("mousedown", PositionHandler);
updateIndicatorState();
// Alert accessibility implementations stuff just changed. We only need to do
// this initially, because changes after this will automatically fire alert
// events if things change materially.
let ev = new CustomEvent("AlertActive", { bubbles: true, cancelable: true });
document.documentElement.dispatchEvent(ev);
}
function updateIndicatorState() {
updateWindowAttr("sharingvideo", webrtcUI.showCameraIndicator);
updateWindowAttr("sharingaudio", webrtcUI.showMicrophoneIndicator);
updateWindowAttr("sharingscreen", webrtcUI.showScreenSharingIndicator);
// Camera and microphone button tooltip.
const audioVideoButton = document.getElementById("audioVideoButton");
let avL10nId;
if (webrtcUI.showCameraIndicator) {
avL10nId = webrtcUI.showMicrophoneIndicator
? "webrtc-indicator-sharing-camera-and-microphone"
: "webrtc-indicator-sharing-camera";
} else {
avL10nId = webrtcUI.showMicrophoneIndicator
? "webrtc-indicator-sharing-microphone"
: "";
}
if (avL10nId) {
document.l10n.setAttributes(audioVideoButton, avL10nId);
} else {
audioVideoButton.removeAttribute("data-l10n-id");
audioVideoButton.removeAttribute("tooltiptext");
}
// Screen sharing button tooltip.
const screenShareButton = document.getElementById("screenShareButton");
let ssL10nId;
const ssi = webrtcUI.showScreenSharingIndicator;
switch (ssi) {
case "Application":
ssL10nId = "webrtc-indicator-sharing-application";
break;
case "Browser":
ssL10nId = "webrtc-indicator-sharing-browser";
break;
case "Screen":
ssL10nId = "webrtc-indicator-sharing-screen";
break;
case "Window":
ssL10nId = "webrtc-indicator-sharing-window";
break;
default:
if (ssi) {
console.error(`Unknown showScreenSharingIndicator: ${ssi}`);
}
ssL10nId = "";
}
if (ssL10nId) {
document.l10n.setAttributes(screenShareButton, ssL10nId);
} else {
screenShareButton.removeAttribute("data-l10n-id");
screenShareButton.removeAttribute("tooltiptext");
}
// Resize and ensure the window position is correct
// (sizeToContent messes with our position).
window.sizeToContent();
PositionHandler.adjustPosition();
}
function updateWindowAttr(attr, value) {
let docEl = document.documentElement;
if (value) {
docEl.setAttribute(attr, "true");
} else {
docEl.removeAttribute(attr);
}
}
function onPopupMenuShowing(event) {
let popup = event.target;
let activeStreams;
if (popup.getAttribute("type") == "Devices") {
activeStreams = webrtcUI.getActiveStreams(true, true, false);
} else {
activeStreams = webrtcUI.getActiveStreams(false, false, true, true);
}
if (activeStreams.length) {
let index = activeStreams.length - 1;
webrtcUI.showSharingDoorhanger(activeStreams[index], event);
event.preventDefault();
return;
}
for (let stream of activeStreams) {
let item = document.createElement("menuitem");
item.setAttribute("label", stream.browser.contentTitle || stream.uri);
item.setAttribute("tooltiptext", stream.uri);
item.stream = stream;
popup.appendChild(item);
}
}
function onPopupMenuHiding(event) {
let popup = event.target;
while (popup.firstChild) {
popup.firstChild.remove();
}
}
function onPopupMenuCommand(event) {
webrtcUI.showSharingDoorhanger(event.target.stream, event);
}
function onFirefoxButtonClick(event) {
event.target.blur();
let activeStreams = webrtcUI.getActiveStreams(true, true, true, true);
activeStreams[0].browser.ownerGlobal.focus();
}
var PositionHandler = {
positionCustomized: false,
threshold: 10,
adjustPosition() {
if (!this.positionCustomized) {
// Center the window horizontally on the screen (not the available area).
// Until we have moved the window to y=0, 'screen.width' may give a value
// for a secondary screen, so use values from the screen manager instead.
let primaryScreen = Cc["@mozilla.org/gfx/screenmanager;1"].getService(
Ci.nsIScreenManager
).primaryScreen;
let widthDevPix = {};
primaryScreen.GetRect({}, {}, widthDevPix, {});
let availTopDevPix = {};
primaryScreen.GetAvailRect({}, availTopDevPix, {}, {});
let scaleFactor = primaryScreen.defaultCSSScaleFactor;
let widthCss = widthDevPix.value / scaleFactor;
window.moveTo(
(widthCss - document.documentElement.clientWidth) / 2,
availTopDevPix.value / scaleFactor
);
} else {
// This will ensure we're at y=0.
this.setXPosition(window.screenX);
}
},
setXPosition(desiredX) {
// Ensure the indicator isn't moved outside the available area of the screen.
desiredX = Math.max(desiredX, screen.availLeft);
let maxX =
screen.availLeft +
screen.availWidth -
document.documentElement.clientWidth;
window.moveTo(Math.min(desiredX, maxX), screen.availTop);
},
handleEvent(aEvent) {
switch (aEvent.type) {
case "mousedown":
if (aEvent.button != 0 || aEvent.defaultPrevented) {
return;
}
this._startMouseX = aEvent.screenX;
this._startWindowX = window.screenX;
this._deltaX = this._startMouseX - this._startWindowX;
window.addEventListener("mousemove", this);
window.addEventListener("mouseup", this);
break;
case "mousemove":
let moveOffset = Math.abs(aEvent.screenX - this._startMouseX);
if (this._dragFullyStarted || moveOffset > this.threshold) {
this.setXPosition(aEvent.screenX - this._deltaX);
this._dragFullyStarted = true;
}
break;
case "mouseup":
this._dragFullyStarted = false;
window.removeEventListener("mousemove", this);
window.removeEventListener("mouseup", this);
this.positionCustomized =
Math.abs(this._startWindowX - window.screenX) >= this.threshold;
break;
}
},
};

View File

@ -1,43 +0,0 @@
<?xml version="1.0"?>
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
<!DOCTYPE window>
<window xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="webrtcIndicator"
role="alert"
#ifndef XP_MACOSX
data-l10n-id="webrtc-indicator-window"
#endif
windowtype="Browser:WebRTCGlobalIndicator"
onload="init(event);"
sizemode="normal"
hidechrome="true"
orient="horizontal"
>
<linkset>
<html:link rel="stylesheet" href="chrome://global/skin/global.css" />
<html:link
rel="stylesheet"
href="chrome://browser/skin/webRTC-legacy-indicator.css"
/>
<html:link rel="localization" href="branding/brand.ftl"/>
<html:link rel="localization" href="browser/webrtcIndicator.ftl"/>
</linkset>
<script src="chrome://browser/content/webrtcLegacyIndicator.js"/>
<button id="firefoxButton"/>
<button id="audioVideoButton" type="menu">
<menupopup id="audioVideoPopup" type="Devices"/>
</button>
<separator id="shareSeparator"/>
<button id="screenShareButton" type="menu">
<menupopup id="screenSharePopup" type="Screen"/>
</button>
</window>

View File

@ -89,10 +89,6 @@ browser.jar:
# XXX: We should exclude this one as well (bug 71895)
* content/browser/hiddenWindowMac.xhtml (content/hiddenWindowMac.xhtml)
content/browser/nonbrowser-mac.js (content/nonbrowser-mac.js)
#endif
#ifndef XP_MACOSX
* content/browser/webrtcLegacyIndicator.xhtml (content/webrtcLegacyIndicator.xhtml)
content/browser/webrtcLegacyIndicator.js (content/webrtcLegacyIndicator.js)
#endif
content/browser/webrtcIndicator.xhtml (content/webrtcIndicator.xhtml)
content/browser/webrtcIndicator.js (content/webrtcIndicator.js)

View File

@ -6,8 +6,6 @@
## enumerate/look for window titles. It is not normally visible anywhere.
webrtc-indicator-title = { -brand-short-name } — Sharing Indicator
webrtc-indicator-window =
.title = { -brand-short-name } — Sharing Indicator
## Used as list items in sharing menu
@ -59,23 +57,6 @@ webrtc-microphone-system-menu =
webrtc-screen-system-menu =
.label = You are sharing a window or a screen. Click to control sharing.
## Tooltips used by the legacy global sharing indicator
webrtc-indicator-sharing-camera-and-microphone =
.tooltiptext = Your camera and microphone are being shared. Click to control sharing.
webrtc-indicator-sharing-camera =
.tooltiptext = Your camera is being shared. Click to control sharing.
webrtc-indicator-sharing-microphone =
.tooltiptext = Your microphone is being shared. Click to control sharing.
webrtc-indicator-sharing-application =
.tooltiptext = An application is being shared. Click to control sharing.
webrtc-indicator-sharing-screen =
.tooltiptext = Your screen is being shared. Click to control sharing.
webrtc-indicator-sharing-window =
.tooltiptext = A window is being shared. Click to control sharing.
webrtc-indicator-sharing-browser =
.tooltiptext = A tab is being shared. Click to control sharing.
## These strings are only used on Mac for menus attached to icons
## near the clock on the mac menubar.
## Variables:

View File

@ -1053,137 +1053,6 @@ export function showStreamSharingMenu(win, event, inclWindow = false) {
}
}
/**
* Controls the visibility of screen, camera and microphone sharing indicators
* in the macOS global menu bar. This class should only ever be instantiated
* on macOS.
*
* The public methods on this class intentionally match the interface for the
* WebRTC global sharing indicator, because the MacOSWebRTCStatusbarIndicator
* acts as the indicator when in the legacy indicator configuration.
*/
export class MacOSWebRTCStatusbarIndicator {
constructor() {
this._camera = null;
this._microphone = null;
this._screen = null;
this._hiddenDoc = Services.appShell.hiddenDOMWindow.document;
this._statusBar = Cc["@mozilla.org/widget/systemstatusbar;1"].getService(
Ci.nsISystemStatusBar
);
this.updateIndicatorState();
}
/**
* Public method that will determine the most appropriate
* set of indicators to show, and then show them or hide
* them as necessary.
*/
updateIndicatorState() {
this._setIndicatorState("Camera", webrtcUI.showCameraIndicator);
this._setIndicatorState("Microphone", webrtcUI.showMicrophoneIndicator);
this._setIndicatorState("Screen", webrtcUI.showScreenSharingIndicator);
}
/**
* Public method that will hide all indicators.
*/
close() {
this._setIndicatorState("Camera", false);
this._setIndicatorState("Microphone", false);
this._setIndicatorState("Screen", false);
}
handleEvent(event) {
switch (event.type) {
case "popupshowing": {
this._popupShowing(event);
break;
}
case "popuphiding": {
this._popupHiding(event);
break;
}
case "command": {
this._command(event);
break;
}
}
}
/**
* Handler for command events fired by the <menuitem> elements
* inside any of the indicator <menu>'s.
*
* @param {Event} aEvent - The command event for the <menuitem>.
*/
_command(aEvent) {
webrtcUI.showSharingDoorhanger(aEvent.target.stream, aEvent);
}
/**
* Handler for the popupshowing event for one of the status
* bar indicator menus.
*
* @param {Event} aEvent - The popupshowing event for the <menu>.
*/
_popupShowing(aEvent) {
const menu = aEvent.target;
showStreamSharingMenu(menu.ownerGlobal, aEvent);
return true;
}
/**
* Handler for the popuphiding event for one of the status
* bar indicator menus.
*
* @param {Event} aEvent - The popuphiding event for the <menu>.
*/
_popupHiding(aEvent) {
let menu = aEvent.target;
while (menu.firstChild) {
menu.firstChild.remove();
}
}
/**
* Updates the status bar to show or hide a screen, camera or
* microphone indicator.
*
* @param {String} aName - One of the following: "screen", "camera",
* "microphone"
* @param {boolean} aState - True to show the indicator for the aName
* type of stream, false ot hide it.
*/
_setIndicatorState(aName, aState) {
let field = "_" + aName.toLowerCase();
if (aState && !this[field]) {
let menu = this._hiddenDoc.createXULElement("menu");
menu.setAttribute("id", "webRTC-sharing" + aName + "-menu");
// The CSS will only be applied if the menu is actually inserted in the DOM.
this._hiddenDoc.documentElement.appendChild(menu);
this._statusBar.addItem(menu);
let menupopup = this._hiddenDoc.createXULElement("menupopup");
menupopup.setAttribute("type", aName);
menupopup.addEventListener("popupshowing", this);
menupopup.addEventListener("popuphiding", this);
menupopup.addEventListener("command", this);
menu.appendChild(menupopup);
this[field] = menu;
} else if (this[field] && !aState) {
this._statusBar.removeItem(this[field]);
this[field].remove();
this[field] = null;
}
}
}
function onTabSharingMenuPopupShowing(e) {
const streams = webrtcUI.getActiveStreams(true, true, true, true);
for (let streamInfo of streams) {

View File

@ -11,7 +11,6 @@ browser.jar:
skin/classic/browser/monitor-base.png
skin/classic/browser/monitor-border.png
skin/classic/browser/pageInfo.png
skin/classic/browser/webRTC-legacy-indicator.css (../shared/webRTC-legacy-indicator.css)
skin/classic/browser/customizableui/panelUI.css (customizableui/panelUI.css)
skin/classic/browser/downloads/allDownloadsView.css (downloads/allDownloadsView.css)
skin/classic/browser/downloads/downloads.css (downloads/downloads.css)

View File

@ -1,121 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
window {
border: 1px solid #ff9500;
}
#audioVideoButton,
#screenShareButton,
#firefoxButton {
height: 29px;
margin: 0;
appearance: none;
border-style: none;
}
#audioVideoButton,
#screenShareButton {
-moz-context-properties: fill;
fill: white;
}
#firefoxButton {
background-image: url("chrome://branding/content/icon48.png");
background-repeat: no-repeat;
background-size: 22px;
background-position: center center;
min-width: 29px;
background-color: white;
}
#firefoxButton:hover {
background-color: #f2f2f2;
}
#screenShareButton {
background-image: url("chrome://browser/skin/notification-icons/screen.svg");
background-position: center center;
background-repeat: no-repeat;
background-size: 16px;
min-width: 27px;
display: none;
}
window[sharingscreen] > #screenShareButton {
display: flex;
}
#audioVideoButton {
display: none;
background-repeat: no-repeat;
}
/* When screen sharing, need to pull in the separator: */
window[sharingscreen] > #audioVideoButton {
margin-right: -1px;
}
/* Single icon button: */
window[sharingvideo] > #audioVideoButton,
window[sharingaudio] > #audioVideoButton {
display: flex;
background-position: center center;
background-size: 16px;
min-width: 26px;
}
window[sharingvideo] > #audioVideoButton {
background-image: url("chrome://browser/skin/notification-icons/camera.svg");
}
window[sharingaudio] > #audioVideoButton {
background-image: url("chrome://browser/skin/notification-icons/microphone.svg");
}
/* Multi-icon button: */
window[sharingaudio][sharingvideo] > #audioVideoButton {
background-image: url("chrome://browser/skin/notification-icons/camera.svg"),
url("chrome://browser/skin/notification-icons/microphone.svg");
background-position: 6px center, 26px center;
background-size: 16px, 16px;
min-width: 46px;
}
/* Hover styles */
#audioVideoButton,
#screenShareButton {
background-color: #ffaa33;
}
#audioVideoButton:hover,
#screenShareButton:hover {
background-color: #ff9500;
}
/* Don't show the dropmarker for the type="menu" case */
#audioVideoButton > .box-inherit > .button-menu-dropmarker,
#screenShareButton > .box-inherit > .button-menu-dropmarker {
display: none;
}
/* Separator in case of screen sharing + video/audio sharing */
#shareSeparator {
width: 1px;
margin: 4px -1px 4px 0;
background-color: #FFCA80;
/* Separator needs to show above either button when they're hovered: */
position: relative;
z-index: 1;
display: none;
}
window[sharingscreen][sharingvideo] > #shareSeparator,
window[sharingscreen][sharingaudio] > #shareSeparator {
display: flex;
}
:is(#audioVideoButton, #screenShareButton, #firefoxButton):-moz-focusring {
outline: none;
}

View File

@ -12,7 +12,6 @@ browser.jar:
skin/classic/browser/monitor-base.png
skin/classic/browser/monitor-border.png
skin/classic/browser/pageInfo.png
skin/classic/browser/webRTC-legacy-indicator.css (../shared/webRTC-legacy-indicator.css)
skin/classic/browser/customizableui/panelUI.css (customizableui/panelUI.css)
skin/classic/browser/downloads/allDownloadsView.css (downloads/allDownloadsView.css)
skin/classic/browser/downloads/downloads.css (downloads/downloads.css)