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