Commit 7636707c authored by Emma Zuehlcke's avatar Emma Zuehlcke Committed by Pier Angelo Vendrame
Browse files

Bug 1665334, r=mconley,fluent-reviewers,bolsson

parent 2b2b6eec
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ webrtc-screen-system-menu =
## These strings are only used on Mac for menus attached to icons
## near the clock on the mac menubar.
## Variables:
##   $streamTitle (String): the title of the tab using the share.
##   $streamTitle (String): the host of the tab using the share.
##   $tabCount (Number): the title of the tab using the share.

webrtc-indicator-menuitem-control-sharing =
+25 −4
Original line number Diff line number Diff line
@@ -983,8 +983,10 @@ export function showStreamSharingMenu(win, event, inclWindow = false) {
    let stream = activeStreams[0];

    const sharingItem = doc.createXULElement("menuitem");
    const streamTitle = stream.browser.contentTitle || stream.uri;
    doc.l10n.setAttributes(sharingItem, l10nIds[0], { streamTitle });
    const displayHost = getDisplayHostForStream(stream);
    doc.l10n.setAttributes(sharingItem, l10nIds[0], {
      streamTitle: displayHost,
    });
    sharingItem.setAttribute("disabled", "true");
    menu.appendChild(sharingItem);

@@ -1008,11 +1010,11 @@ export function showStreamSharingMenu(win, event, inclWindow = false) {

    for (let stream of activeStreams) {
      const controlItem = doc.createXULElement("menuitem");
      const streamTitle = stream.browser.contentTitle || stream.uri;
      const displayHost = getDisplayHostForStream(stream);
      doc.l10n.setAttributes(
        controlItem,
        "webrtc-indicator-menuitem-control-sharing-on",
        { streamTitle }
        { streamTitle: displayHost }
      );
      controlItem.stream = stream;
      controlItem.addEventListener("command", this);
@@ -1021,6 +1023,25 @@ export function showStreamSharingMenu(win, event, inclWindow = false) {
  }
}

function getDisplayHostForStream(stream) {
  let uri = Services.io.newURI(stream.uri);

  let displayHost;

  try {
    displayHost = uri.displayHost;
  } catch (ex) {
    displayHost = null;
  }

  // Host getter threw or returned "". Fall back to spec.
  if (displayHost == null || displayHost == "") {
    displayHost = uri.displaySpec;
  }

  return displayHost;
}

function onTabSharingMenuPopupShowing(e) {
  const streams = webrtcUI.getActiveStreams(true, true, true, true);
  for (let streamInfo of streams) {