Bug 965641 - [Australis] prompt user to sign-in again UI in the menu panel r=markh
authorTim Taubert <ttaubert@mozilla.com>
Wed, 29 Jan 2014 19:06:50 -0800
changeset 182216 7560f1dfaa97410f57b7478cd4f657868b1233f7
parent 182215 a4638840181d0dbfae71beaff778292d74858209
child 182217 1471e8762222e0373873ed2a8e48a9709230de3f
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh
bugs965641
milestone29.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 965641 - [Australis] prompt user to sign-in again UI in the menu panel r=markh
browser/base/content/browser-fxaccounts.js
browser/components/customizableui/content/panelUI.inc.xul
browser/locales/en-US/chrome/browser/browser.dtd
--- a/browser/base/content/browser-fxaccounts.js
+++ b/browser/base/content/browser-fxaccounts.js
@@ -6,56 +6,61 @@ XPCOMUtils.defineLazyGetter(this, "FxAcc
   return Cu.import("resource://gre/modules/FxAccountsCommon.js", {});
 });
 
 const PREF_SYNC_START_DOORHANGER = "services.sync.ui.showSyncStartDoorhanger";
 
 let gFxAccounts = {
 
   _initialized: false,
-  _originalLabel: null,
   _inCustomizationMode: false,
 
   get weave() {
     delete this.weave;
     return this.weave = Cc["@mozilla.org/weave/service;1"]
                           .getService(Ci.nsISupports)
                           .wrappedJSObject;
   },
 
   get topics() {
     delete this.topics;
     return this.topics = [
+      "weave:service:sync:start",
+      "weave:service:login:error",
       FxAccountsCommon.ONLOGIN_NOTIFICATION,
       FxAccountsCommon.ONVERIFIED_NOTIFICATION,
-      FxAccountsCommon.ONLOGOUT_NOTIFICATION,
-      "weave:service:sync:start"
+      FxAccountsCommon.ONLOGOUT_NOTIFICATION
     ];
   },
 
   get button() {
     delete this.button;
     return this.button = document.getElementById("PanelUI-fxa-status");
   },
 
+  get loginFailed() {
+    if (Weave.Status.login != Weave.LOGIN_SUCCEEDED) {
+      Weave.Service.verifyLogin();
+    }
+    return Weave.Service.identity.readyToAuthenticate &&
+           Weave.Status.login != Weave.LOGIN_SUCCEEDED;
+  },
+
   init: function () {
     if (this._initialized) {
       return;
     }
 
     for (let topic of this.topics) {
       Services.obs.addObserver(this, topic, false);
     }
 
     gNavToolbox.addEventListener("customizationstarting", this);
     gNavToolbox.addEventListener("customizationending", this);
 
-    // Save the button's original label so that
-    // we can restore it if overridden later.
-    this._originalLabel = this.button.getAttribute("label");
     this._initialized = true;
 
     this.updateUI();
   },
 
   uninit: function () {
     if (!this._initialized) {
       return;
@@ -131,27 +136,37 @@ let gFxAccounts = {
 
     // Make sure the button is disabled in customization mode.
     if (this._inCustomizationMode) {
       this.button.setAttribute("disabled", "true");
     } else {
       this.button.removeAttribute("disabled");
     }
 
+    let defaultLabel = this.button.getAttribute("defaultlabel");
+    let errorLabel = this.button.getAttribute("errorlabel");
+
     // If the user is signed into their Firefox account and we are not
     // currently in customization mode, show their email address.
     fxAccounts.getSignedInUser().then(userData => {
-      if (userData && !this._inCustomizationMode) {
-        this.button.setAttribute("signedin", "true");
-        this.button.setAttribute("label", userData.email);
-        this.button.setAttribute("tooltiptext", userData.email);
-      } else {
-        this.button.removeAttribute("signedin");
-        this.button.setAttribute("label", this._originalLabel);
-        this.button.removeAttribute("tooltiptext");
+      // Reset the button to its original state.
+      this.button.setAttribute("label", defaultLabel);
+      this.button.removeAttribute("tooltiptext");
+      this.button.removeAttribute("signedin");
+      this.button.removeAttribute("failed");
+
+      if (!this._inCustomizationMode) {
+        if (this.loginFailed) {
+          this.button.setAttribute("failed", "true");
+          this.button.setAttribute("label", errorLabel);
+        } else if (userData) {
+          this.button.setAttribute("signedin", "true");
+          this.button.setAttribute("label", userData.email);
+          this.button.setAttribute("tooltiptext", userData.email);
+        }
       }
     });
   },
 
   toggle: function (event) {
     if (event.originalTarget.hasAttribute("signedin")) {
       this.openPreferences();
     } else {
--- a/browser/components/customizableui/content/panelUI.inc.xul
+++ b/browser/components/customizableui/content/panelUI.inc.xul
@@ -10,17 +10,19 @@
        noautofocus="true">
   <panelmultiview id="PanelUI-multiView" mainViewId="PanelUI-mainView">
     <panelview id="PanelUI-mainView" context="customizationPanelContextMenu">
       <vbox id="PanelUI-contents-scroller">
         <vbox id="PanelUI-contents" class="panelUI-grid"/>
       </vbox>
 
       <footer id="PanelUI-footer">
-        <toolbarbutton id="PanelUI-fxa-status" label="&fxaSignIn.label;"
+        <toolbarbutton id="PanelUI-fxa-status"
+                       defaultlabel="&fxaSignIn.label;"
+                       errorlabel="&fxaSignInError.label;"
                        oncommand="gFxAccounts.toggle(event);"
                        hidden="true"/>
 
         <hbox id="PanelUI-footer-inner">
           <toolbarbutton id="PanelUI-customize" label="&appMenuCustomize.label;"
                          exitLabel="&appMenuCustomizeExit.label;"
                          tooltiptext="&appMenuCustomize.tooltip;"
                          exitTooltiptext="&appMenuCustomizeExit.tooltip;"
--- a/browser/locales/en-US/chrome/browser/browser.dtd
+++ b/browser/locales/en-US/chrome/browser/browser.dtd
@@ -92,16 +92,17 @@ These should match what Safari and other
 <!ENTITY exitFullScreenCmd.accesskey "F">
 <!ENTITY fullScreenCmd.label "Full Screen">
 <!ENTITY fullScreenCmd.accesskey "F">
 <!ENTITY fullScreenCmd.macCommandKey "f">
 <!ENTITY showAllTabsCmd.label "Show All Tabs">
 <!ENTITY showAllTabsCmd.accesskey "A">
 
 <!ENTITY fxaSignIn.label "Sign in to &syncBrand.shortName.label;">
+<!ENTITY fxaSignInError.label "Reconnect to &syncBrand.shortName.label;">
 <!ENTITY syncStartPanel.title "&brandShortName; is now syncing.">
 <!ENTITY syncStartPanel.subTitle "You can manage &syncBrand.shortName.label; in Options.">
 <!ENTITY syncStartPanel.subTitleUnix "You can manage &syncBrand.shortName.label; in Preferences.">
 <!ENTITY syncErrorPanel.title "Cannot connect to &syncBrand.shortName.label;">
 <!ENTITY syncErrorPanel.subTitle "Please sign in to resume syncing.">
 <!ENTITY syncErrorPanel.prefButton.label "Options">
 <!ENTITY syncErrorPanel.prefButton.accesskey "O">
 <!ENTITY syncErrorPanel.prefButtonUnix.label "Preferences">