Bug 965560 - Fix icon in sidebar toolbarbutton. r=felipc, a=sledru
authorShane Caraveo <scaraveo@mozilla.com>
Thu, 06 Feb 2014 16:46:54 -0500
changeset 176234 f0adf847ac2d5a9454fec4559cd39af1d529b087
parent 176233 c56da36e185c912f52c6cc139800af0159a57cc6
child 176235 1b369b538f591499e717e7a9cf959fb725800788
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipc, sledru
bugs965560
milestone28.0
Bug 965560 - Fix icon in sidebar toolbarbutton. r=felipc, a=sledru
browser/base/content/browser-social.js
--- a/browser/base/content/browser-social.js
+++ b/browser/base/content/browser-social.js
@@ -202,17 +202,18 @@ SocialUI = {
       // XXX Bug 789585 will implement an API for provider-specified login pages.
       openUILinkIn(Social.provider.origin, "tab");
     }
   },
 
   _updateActiveUI: function SocialUI_updateActiveUI() {
     // The "active" UI isn't dependent on there being a provider, just on
     // social being "active" (but also chromeless/PB)
-    let enabled = Social.providers.length > 0 && !this._chromeless &&
+    let providers = [p for (p of Social.providers) if (p.sidebarURL)];
+    let enabled = providers.length > 0 && !this._chromeless &&
                   !PrivateBrowsingUtils.isWindowPrivate(window);
     let broadcaster = document.getElementById("socialActiveBroadcaster");
     broadcaster.hidden = !enabled;
 
     let toggleCommand = document.getElementById("Social:Toggle");
     toggleCommand.setAttribute("hidden", enabled ? "false" : "true");
 
     if (enabled) {
@@ -876,17 +877,19 @@ SocialToolbar = {
 
   get button() {
     return document.getElementById("social-provider-button");
   },
 
   // Note: this doesn't actually handle hiding the toolbar button,
   // socialActiveBroadcaster is responsible for that.
   _updateButtonHiddenState: function SocialToolbar_updateButtonHiddenState() {
-    let socialEnabled = SocialUI.enabled;
+    // toolbar button should only show if we have providers with sidebars
+    let providers = [p for (p of Social.providers) if (p.sidebarURL)];
+    let socialEnabled = SocialUI.enabled && providers.length > 0;
     for (let className of ["social-statusarea-separator", "social-statusarea-user"]) {
       for (let element of document.getElementsByClassName(className))
         element.hidden = !socialEnabled;
     }
     let toggleNotificationsCommand = document.getElementById("Social:ToggleNotifications");
     toggleNotificationsCommand.setAttribute("hidden", !socialEnabled);
 
     // we need to remove buttons and frames if !socialEnabled or the provider
@@ -1169,17 +1172,17 @@ SocialToolbar = {
   _populateProviderMenu: function SocialToolbar_renderProviderMenu(providerMenuSep) {
     let menu = providerMenuSep.parentNode;
     // selectable providers are inserted before the provider-menu seperator,
     // remove any menuitems in that area
     while (providerMenuSep.previousSibling.nodeName == "menuitem") {
       menu.removeChild(providerMenuSep.previousSibling);
     }
     // only show a selection if enabled and there is more than one
-    let providers = [p for (p of Social.providers) if (p.workerURL || p.sidebarURL)];
+    let providers = [p for (p of Social.providers) if (p.sidebarURL)];
     if (providers.length < 2) {
       providerMenuSep.hidden = true;
       return;
     }
     for (let provider of providers) {
       let menuitem = document.createElement("menuitem");
       menuitem.className = "menuitem-iconic social-provider-menuitem";
       menuitem.setAttribute("image", provider.iconURL);