Bug 793036 - Close all service windows on logout. r=jaws
authorMark Hammond <mhammond@skippinet.com.au>
Mon, 24 Sep 2012 09:49:28 +1000
changeset 107860 503de52e9c72efe4bffe1545777bbb728759222a
parent 107859 b29d0e8668c316b29942cb1c864acf6489caf208
child 107861 013a65100228ba7564d8c870c08ab915130b7877
push id15248
push usermhammond@skippinet.com.au
push dateSun, 23 Sep 2012 23:49:42 +0000
treeherdermozilla-inbound@503de52e9c72 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs793036
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 793036 - Close all service windows on logout. r=jaws
browser/base/content/browser-social.js
--- a/browser/base/content/browser-social.js
+++ b/browser/base/content/browser-social.js
@@ -48,16 +48,17 @@ let SocialUI = {
         }
         break;
       case "social:ambient-notification-changed":
         SocialToolbar.updateButton();
         break;
       case "social:profile-changed":
         SocialToolbar.updateProfile();
         SocialShareButton.updateProfileInfo();
+        SocialChatBar.update();
         break;
       case "nsPref:changed":
         SocialSidebar.updateSidebar();
     }
   },
 
   get toggleCommand() {
     return document.getElementById("Social:Toggle");
@@ -153,25 +154,31 @@ let SocialUI = {
 
   get notificationPanel() {
     return document.getElementById("socialActivatedNotification")
   },
 
   undoActivation: function SocialUI_undoActivation() {
     Social.active = false;
     this.notificationPanel.hidePopup();
+  },
+
+  haveLoggedInUser: function SocialUI_haveLoggedInUser() {
+    return !!(Social.provider && Social.provider.profile && Social.provider.profile.userName);
   }
 }
 
 let SocialChatBar = {
   get chatbar() {
     return document.getElementById("pinnedchats");
   },
   // Whether the chats can be shown for this window.
   get canShow() {
+    if (!SocialUI.haveLoggedInUser())
+      return false;
     let docElem = document.documentElement;
     let chromeless = docElem.getAttribute("disablechrome") ||
                      docElem.getAttribute("chromehidden").indexOf("extrachrome") >= 0;
     return Social.uiVisible && !chromeless;
   },
   openChat: function(aProvider, aURL, aCallback, aMode) {
     if (this.canShow)
       this.chatbar.openChat(aProvider, aURL, aCallback, aMode);
@@ -398,17 +405,17 @@ let SocialShareButton = {
   dismissSharePopup: function SSB_dismissSharePopup() {
     this.sharePopup.hidePopup();
   },
 
   updateButtonHiddenState: function SSB_updateButtonHiddenState() {
     let shareButton = this.shareButton;
     if (shareButton)
       shareButton.hidden = !Social.uiVisible || this.promptImages == null ||
-                           !Social.provider.profile || !Social.provider.profile.userName;
+                           !SocialUI.haveLoggedInUser();
   },
 
   onClick: function SSB_onClick(aEvent) {
     if (aEvent.button != 0)
       return;
 
     // Don't bubble to the textbox, to avoid unwanted selection of the address.
     aEvent.stopPropagation();
@@ -494,17 +501,17 @@ var SocialToolbar = {
   },
 
   get button() {
     return document.getElementById("social-toolbar-button");
   },
 
   updateButtonHiddenState: function SocialToolbar_updateButtonHiddenState() {
     this.button.hidden = !Social.uiVisible;
-    if (!Social.provider || !Social.provider.profile || !Social.provider.profile.userName) {
+    if (!SocialUI.haveLoggedInUser()) {
       ["social-notification-box",
        "social-status-iconbox"].forEach(function removeChildren(parentId) {
         let parent = document.getElementById(parentId);
         while(parent.hasChildNodes())
           parent.removeChild(parent.firstChild);
       });
     }
   },