Bug 1037415 - remove existing webrtc indicator in the browser toolbar r=florian

This commit is contained in:
Tim Taubert 2014-07-23 17:34:31 +02:00
Родитель f6f4630b3a
Коммит 5d377d2e9f
14 изменённых файлов: 17 добавлений и 122 удалений

Просмотреть файл

@ -1,70 +0,0 @@
# -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
# 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/.
let WebrtcIndicator = {
init: function () {
let temp = {};
Cu.import("resource:///modules/webrtcUI.jsm", temp);
this.UIModule = temp.webrtcUI;
this.updateButton();
},
get button() {
delete this.button;
return this.button = document.getElementById("webrtc-status-button");
},
updateButton: function () {
this.button.hidden = !this.UIModule.showGlobalIndicator;
},
fillPopup: function (aPopup) {
this._menuitemData = new WeakMap;
for (let streamData of this.UIModule.getActiveStreams(true, true, true)) {
let pageURI = Services.io.newURI(streamData.uri, null, null);
let menuitem = document.createElement("menuitem");
menuitem.setAttribute("class", "menuitem-iconic");
menuitem.setAttribute("label", streamData.browser.contentTitle || streamData.uri);
menuitem.setAttribute("tooltiptext", streamData.uri);
PlacesUtils.favicons.getFaviconURLForPage(pageURI, function (aURI) {
if (aURI) {
let iconURL = PlacesUtils.favicons.getFaviconLinkForIcon(aURI).spec;
menuitem.setAttribute("image", iconURL);
}
});
this._menuitemData.set(menuitem, streamData);
aPopup.appendChild(menuitem);
}
},
clearPopup: function (aPopup) {
while (aPopup.lastChild)
aPopup.removeChild(aPopup.lastChild);
},
menuCommand: function (aMenuitem) {
let streamData = this._menuitemData.get(aMenuitem);
if (!streamData)
return;
let browserWindow = streamData.browser.ownerDocument.defaultView;
if (streamData.tab) {
browserWindow.gBrowser.selectedTab = streamData.tab;
} else {
streamData.browser.focus();
}
browserWindow.focus();
let notif = PopupNotifications.getNotification("webRTC-sharingDevices",
streamData.browser);
if (!notif) {
notif = PopupNotifications.getNotification("webRTC-sharingScreen",
streamData.browser);
}
notif.reshow();
}
}

Просмотреть файл

@ -160,6 +160,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "SessionStore",
XPCOMUtils.defineLazyModuleGetter(this, "fxAccounts",
"resource://gre/modules/FxAccounts.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "gWebRTCUI",
"resource:///modules/webrtcUI.jsm", "webrtcUI");
#ifdef MOZ_CRASHREPORTER
XPCOMUtils.defineLazyModuleGetter(this, "TabCrashReporter",
"resource:///modules/TabCrashReporter.jsm");
@ -187,7 +190,6 @@ let gInitialPages = [
#include browser-tabPreviews.js
#include browser-tabview.js
#include browser-thumbnails.js
#include browser-webrtcUI.js
#include browser-gestureSupport.js
#ifdef MOZ_DATA_REPORTING
@ -1165,7 +1167,6 @@ var gBrowserInit = {
FullZoom.init();
PanelUI.init();
LightweightThemeListener.init();
WebrtcIndicator.init();
#ifdef MOZ_CRASHREPORTER
if (gMultiProcessBrowser)

Просмотреть файл

@ -669,7 +669,7 @@
aria-label="&navbarCmd.label;"
fullscreentoolbar="true" mode="icons" customizable="true"
iconsize="small"
defaultset="urlbar-container,search-container,webrtc-status-button,bookmarks-menu-button,downloads-button,home-button,loop-call-button,social-share-button,social-toolbar-item"
defaultset="urlbar-container,search-container,bookmarks-menu-button,downloads-button,home-button,loop-call-button,social-share-button,social-toolbar-item"
customizationtarget="nav-bar-customization-target"
overflowable="true"
overflowbutton="nav-bar-overflow-button"
@ -788,19 +788,6 @@
<searchbar id="searchbar" flex="1"/>
</toolbaritem>
<toolbarbutton id="webrtc-status-button"
class="toolbarbutton-1 chromeclass-toolbar-additional"
type="menu"
hidden="true"
orient="horizontal"
label="&webrtcIndicatorButton.label;"
tooltiptext="&webrtcIndicatorButton.tooltip;"
overflows="false">
<menupopup onpopupshowing="WebrtcIndicator.fillPopup(this);"
onpopuphiding="WebrtcIndicator.clearPopup(this);"
oncommand="WebrtcIndicator.menuCommand(event.target);"/>
</toolbarbutton>
<toolbarbutton id="bookmarks-menu-button"
class="toolbarbutton-1 chromeclass-toolbar-additional"
persist="class"

Просмотреть файл

@ -25,7 +25,7 @@
accesskey="&getUserMedia.selectWindowOrScreen.accesskey;"
control="webRTC-selectWindow-menulist"/>
<menulist id="webRTC-selectWindow-menulist"
oncommand="WebrtcIndicator.UIModule.updateMainActionLabel(this);">
oncommand="gWebRTCUI.updateMainActionLabel(this);">
<menupopup id="webRTC-selectWindow-menupopup"/>
</menulist>
<description id="webRTC-all-windows-shared" hidden="true">&getUserMedia.allWindowsShared.message;</description>

Просмотреть файл

@ -185,8 +185,7 @@ function closeStream(aAlreadyClosed) {
if (!aAlreadyClosed)
expectObserverCalled("recording-window-ended");
let statusButton = document.getElementById("webrtc-status-button");
ok(statusButton.hidden, "WebRTC status button hidden");
assertWebRTCIndicatorStatus(false);
}
function checkDeviceSelectors(aAudio, aVideo) {
@ -205,8 +204,8 @@ function checkDeviceSelectors(aAudio, aVideo) {
function checkSharingUI() {
yield promisePopupNotification("webRTC-sharingDevices");
let statusButton = document.getElementById("webrtc-status-button");
ok(!statusButton.hidden, "WebRTC status button visible");
assertWebRTCIndicatorStatus(true);
}
function checkNotSharing() {
@ -215,8 +214,7 @@ function checkNotSharing() {
ok(!PopupNotifications.getNotification("webRTC-sharingDevices"),
"no webRTC-sharingDevices popup notification");
let statusButton = document.getElementById("webrtc-status-button");
ok(statusButton.hidden, "WebRTC status button hidden");
assertWebRTCIndicatorStatus(false);
}
let gTests = [

Просмотреть файл

@ -122,8 +122,7 @@ function closeStream(aAlreadyClosed) {
if (!aAlreadyClosed)
expectObserverCalled("recording-window-ended");
let statusButton = document.getElementById("webrtc-status-button");
ok(statusButton.hidden, "WebRTC status button hidden");
assertWebRTCIndicatorStatus(false);
}
function loadPage(aUrl) {

Просмотреть файл

@ -511,3 +511,9 @@ function promiseTabLoadEvent(tab, url, eventType="load")
tab.linkedBrowser.loadURI(url);
return deferred.promise;
}
function assertWebRTCIndicatorStatus(expected) {
let ui = Cu.import("resource:///modules/webrtcUI.jsm", {}).webrtcUI;
let msg = "WebRTC indicator " + (expected ? "visible" : "hidden");
is(ui.showGlobalIndicator, expected, msg);
}

Просмотреть файл

@ -202,7 +202,6 @@ let CustomizableUIInternal = {
defaultPlacements: [
"urlbar-container",
"search-container",
"webrtc-status-button",
"bookmarks-menu-button",
"downloads-button",
"home-button",

Просмотреть файл

@ -715,9 +715,6 @@ just addresses the organization to follow, e.g. "This site is run by " -->
<!ENTITY getUserMedia.selectMicrophone.accesskey "M">
<!ENTITY getUserMedia.allWindowsShared.message "All visible windows on your screen will be shared.">
<!ENTITY webrtcIndicatorButton.label "Camera / Microphone Access">
<!ENTITY webrtcIndicatorButton.tooltip "Display sites you are currently sharing your camera or microphone with">
<!ENTITY loopCallButton.tooltip "Invite someone to talk">
<!ENTITY mixedContentBlocked.moreinfo "Most websites will still work properly even when this content is blocked.">

Просмотреть файл

@ -48,7 +48,6 @@ XPCOMUtils.defineLazyGetter(this, "DEFAULT_AREA_PLACEMENTS", function() {
"nav-bar": [
"urlbar-container",
"search-container",
"webrtc-status-button",
"bookmarks-menu-button",
"downloads-button",
"home-button",

Просмотреть файл

@ -555,11 +555,6 @@ function updateIndicators() {
let count = contentWindowSupportsArray.Count();
webrtcUI.showGlobalIndicator = count > 0;
let e = Services.wm.getEnumerator("navigator:browser");
while (e.hasMoreElements())
e.getNext().WebrtcIndicator.updateButton();
webrtcUI.showCameraIndicator = false;
webrtcUI.showMicrophoneIndicator = false;
webrtcUI.showScreenSharingIndicator = "";

Просмотреть файл

@ -775,10 +775,6 @@ toolbar .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker > .dropmarker-ic
-moz-image-region: rect(18px, 576px, 36px, 558px);
}
#webrtc-status-button@toolbarButtonPressed@ {
-moz-image-region: rect(18px, 594px, 36px, 576px);
}
#nav-bar-overflow-button@toolbarButtonPressed@ {
-moz-image-region: rect(18px, 612px, 36px, 594px);
}
@ -1087,14 +1083,6 @@ toolbar .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker > .dropmarker-ic
-moz-image-region: rect(36px, 1152px, 72px, 1116px);
}
#webrtc-status-button {
-moz-image-region: rect(0, 1188px, 36px, 1152px);
}
#webrtc-status-button:hover:active:not([disabled="true"]) {
-moz-image-region: rect(36px, 1188px, 72px, 1152px);
}
#nav-bar-overflow-button {
-moz-image-region: rect(0, 1224px, 36px, 1188px);
}

Просмотреть файл

@ -2,7 +2,7 @@
% Note that zoom-reset-button is a bit different since it doesn't use an image and thus has the image with display: none.
%define nestedButtons #zoom-out-button, #zoom-reset-button, #zoom-in-button, #cut-button, #copy-button, #paste-button
%define primaryToolbarButtons #back-button, #forward-button, #home-button, #print-button, #downloads-button, #bookmarks-menu-button, #new-tab-button, #new-window-button, #fullscreen-button, #sync-button, #feed-button, #tabview-button, #webrtc-status-button, #social-share-button, #open-file-button, #find-button, #developer-button, #preferences-button, #privatebrowsing-button, #save-page-button, #switch-to-metro-button, #add-ons-button, #history-panelmenu, #nav-bar-overflow-button, #PanelUI-menu-button, #characterencoding-button, #email-link-button, #sidebar-button, @nestedButtons@, #e10s-button
%define primaryToolbarButtons #back-button, #forward-button, #home-button, #print-button, #downloads-button, #bookmarks-menu-button, #new-tab-button, #new-window-button, #fullscreen-button, #sync-button, #feed-button, #tabview-button, #social-share-button, #open-file-button, #find-button, #developer-button, #preferences-button, #privatebrowsing-button, #save-page-button, #switch-to-metro-button, #add-ons-button, #history-panelmenu, #nav-bar-overflow-button, #PanelUI-menu-button, #characterencoding-button, #email-link-button, #sidebar-button, @nestedButtons@, #e10s-button
%ifdef XP_MACOSX
% Prior to 10.7 there wasn't a native fullscreen button so we use #restore-button to exit fullscreen

Просмотреть файл

@ -148,10 +148,6 @@ toolbar[brighttext] #sync-button[status="active"]:hover:active:not([disabled="tr
-moz-image-region: rect(0, 576px, 18px, 558px);
}
#webrtc-status-button {
-moz-image-region: rect(0, 594px, 18px, 576px);
}
#nav-bar-overflow-button {
-moz-image-region: rect(0, 612px, 18px, 594px);
}