Bug 1030227 - FxA must fire onlogin() for RPs that have called watch(). r=jedp, a=2.0+
authorSam Penrose <spenrose@mozilla.com>
Thu, 26 Jun 2014 10:04:03 -0700
changeset 207492 f0fb4204362927c7b8d7582ea8f04d044970dc46
parent 207491 0b836bae4fd20507ac6a354b5db06364ad44e6f5
child 207493 b33e040d2d244967dd845f0622e21c20d0a4c3ec
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjedp, 2
bugs1030227
milestone32.0a2
Bug 1030227 - FxA must fire onlogin() for RPs that have called watch(). r=jedp, a=2.0+
toolkit/identity/FirefoxAccounts.jsm
--- a/toolkit/identity/FirefoxAccounts.jsm
+++ b/toolkit/identity/FirefoxAccounts.jsm
@@ -39,23 +39,25 @@ log.addAppender(new Log.ConsoleAppender(
 XPCOMUtils.defineLazyModuleGetter(this, "FxAccountsManager",
                                   "resource://gre/modules/FxAccountsManager.jsm",
                                   "FxAccountsManager");
 Cu.import("resource://gre/modules/FxAccountsCommon.js");
 #else
 log.warn("The FxAccountsManager is only functional in B2G at this time.");
 var FxAccountsManager = null;
 var ONVERIFIED_NOTIFICATION = null;
+var ONLOGIN_NOTIFICATION = null;
 var ONLOGOUT_NOTIFICATION = null;
 #endif
 
 function FxAccountsService() {
   Services.obs.addObserver(this, "quit-application-granted", false);
   if (ONVERIFIED_NOTIFICATION) {
     Services.obs.addObserver(this, ONVERIFIED_NOTIFICATION, false);
+    Services.obs.addObserver(this, ONLOGIN_NOTIFICATION, false);
     Services.obs.addObserver(this, ONLOGOUT_NOTIFICATION, false);
   }
 
   // Maintain interface parity with Identity.jsm and MinimalIdentity.jsm
   this.RP = this;
 
   this._rpFlows = new Map();
 
@@ -64,34 +66,42 @@ function FxAccountsService() {
 }
 
 FxAccountsService.prototype = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, Ci.nsIObserver]),
 
   observe: function observe(aSubject, aTopic, aData) {
     switch (aTopic) {
       case null:
-        // Paranoia against matching null ONVERIFIED or ONLOGOUT
+        // Guard against matching null ON*_NOTIFICATION
         break;
       case ONVERIFIED_NOTIFICATION:
         log.debug("Received " + ONVERIFIED_NOTIFICATION + "; firing request()s");
         for (let [rpId,] of this._rpFlows) {
           this.request(rpId);
         }
         break;
+      case ONLOGIN_NOTIFICATION:
+        log.debug("Received " + ONLOGIN_NOTIFICATION + "; doLogin()s fired");
+        for (let [rpId,] of this._rpFlows) {
+          this.request(rpId);
+        }
+        break;
       case ONLOGOUT_NOTIFICATION:
         log.debug("Received " + ONLOGOUT_NOTIFICATION + "; doLogout()s fired");
         for (let [rpId,] of this._rpFlows) {
           this.doLogout(rpId);
         }
         break;
       case "quit-application-granted":
         Services.obs.removeObserver(this, "quit-application-granted");
         if (ONVERIFIED_NOTIFICATION) {
           Services.obs.removeObserver(this, ONVERIFIED_NOTIFICATION);
+          Services.obs.removeObserver(this, ONLOGIN_NOTIFICATION);
+          Services.obs.removeObserver(this, ONLOGOUT_NOTIFICATION);
         }
         break;
     }
   },
 
   /**
    * Register a listener for a given windowID as a result of a call to
    * navigator.id.watch().