1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/browser-webrtcUI.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +# -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 +# This Source Code Form is subject to the terms of the Mozilla Public 1.6 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 + 1.9 +let WebrtcIndicator = { 1.10 + init: function () { 1.11 + let temp = {}; 1.12 + Cu.import("resource:///modules/webrtcUI.jsm", temp); 1.13 + this.UIModule = temp.webrtcUI; 1.14 + 1.15 + this.updateButton(); 1.16 + }, 1.17 + 1.18 + get button() { 1.19 + delete this.button; 1.20 + return this.button = document.getElementById("webrtc-status-button"); 1.21 + }, 1.22 + 1.23 + updateButton: function () { 1.24 + this.button.hidden = !this.UIModule.showGlobalIndicator; 1.25 + }, 1.26 + 1.27 + fillPopup: function (aPopup) { 1.28 + this._menuitemData = new WeakMap; 1.29 + for (let streamData of this.UIModule.activeStreams) { 1.30 + let pageURI = Services.io.newURI(streamData.uri, null, null); 1.31 + let menuitem = document.createElement("menuitem"); 1.32 + menuitem.setAttribute("class", "menuitem-iconic"); 1.33 + menuitem.setAttribute("label", streamData.browser.contentTitle || streamData.uri); 1.34 + menuitem.setAttribute("tooltiptext", streamData.uri); 1.35 + PlacesUtils.favicons.getFaviconURLForPage(pageURI, function (aURI) { 1.36 + if (aURI) { 1.37 + let iconURL = PlacesUtils.favicons.getFaviconLinkForIcon(aURI).spec; 1.38 + menuitem.setAttribute("image", iconURL); 1.39 + } 1.40 + }); 1.41 + 1.42 + this._menuitemData.set(menuitem, streamData); 1.43 + 1.44 + aPopup.appendChild(menuitem); 1.45 + } 1.46 + }, 1.47 + 1.48 + clearPopup: function (aPopup) { 1.49 + while (aPopup.lastChild) 1.50 + aPopup.removeChild(aPopup.lastChild); 1.51 + }, 1.52 + 1.53 + menuCommand: function (aMenuitem) { 1.54 + let streamData = this._menuitemData.get(aMenuitem); 1.55 + if (!streamData) 1.56 + return; 1.57 + 1.58 + let browserWindow = streamData.browser.ownerDocument.defaultView; 1.59 + if (streamData.tab) { 1.60 + browserWindow.gBrowser.selectedTab = streamData.tab; 1.61 + } else { 1.62 + streamData.browser.focus(); 1.63 + } 1.64 + browserWindow.focus(); 1.65 + PopupNotifications.getNotification("webRTC-sharingDevices", 1.66 + streamData.browser).reshow(); 1.67 + } 1.68 +}