browser/base/content/browser-webrtcUI.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 # -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2 # This Source Code Form is subject to the terms of the Mozilla Public
     3 # License, v. 2.0. If a copy of the MPL was not distributed with this
     4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     6 let WebrtcIndicator = {
     7   init: function () {
     8     let temp = {};
     9     Cu.import("resource:///modules/webrtcUI.jsm", temp);
    10     this.UIModule = temp.webrtcUI;
    12     this.updateButton();
    13   },
    15   get button() {
    16     delete this.button;
    17     return this.button = document.getElementById("webrtc-status-button");
    18   },
    20   updateButton: function () {
    21     this.button.hidden = !this.UIModule.showGlobalIndicator;
    22   },
    24   fillPopup: function (aPopup) {
    25     this._menuitemData = new WeakMap;
    26     for (let streamData of this.UIModule.activeStreams) {
    27       let pageURI = Services.io.newURI(streamData.uri, null, null);
    28       let menuitem = document.createElement("menuitem");
    29       menuitem.setAttribute("class", "menuitem-iconic");
    30       menuitem.setAttribute("label", streamData.browser.contentTitle || streamData.uri);
    31       menuitem.setAttribute("tooltiptext", streamData.uri);
    32       PlacesUtils.favicons.getFaviconURLForPage(pageURI, function (aURI) {
    33         if (aURI) {
    34           let iconURL = PlacesUtils.favicons.getFaviconLinkForIcon(aURI).spec;
    35           menuitem.setAttribute("image", iconURL);
    36         }
    37       });
    39       this._menuitemData.set(menuitem, streamData);
    41       aPopup.appendChild(menuitem);
    42     }
    43   },
    45   clearPopup: function (aPopup) {
    46     while (aPopup.lastChild)
    47       aPopup.removeChild(aPopup.lastChild);
    48   },
    50   menuCommand: function (aMenuitem) {
    51     let streamData = this._menuitemData.get(aMenuitem);
    52     if (!streamData)
    53       return;
    55     let browserWindow = streamData.browser.ownerDocument.defaultView;
    56     if (streamData.tab) {
    57       browserWindow.gBrowser.selectedTab = streamData.tab;
    58     } else {
    59       streamData.browser.focus();
    60     }
    61     browserWindow.focus();
    62     PopupNotifications.getNotification("webRTC-sharingDevices",
    63                                        streamData.browser).reshow();
    64   }
    65 }

mercurial