Bug 1025309 - Fire FxA onlogout for RPs such as FMD. r=jedp, a=2.0+
authorSam Penrose <spenrose@mozilla.com>
Tue, 17 Jun 2014 11:28:25 -0700
changeset 208191 f5d13392d3dbdf1e1646ca58d8554eff48d1d73d
parent 208190 6619d09e8d805bfd0eda8f4845ed1c5fb577f5b4
child 208192 b5a868ef685f68f47ea5839b4b8991c538967e95
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjedp, 2
bugs1025309
milestone32.0a2
Bug 1025309 - Fire FxA onlogout for RPs such as FMD. r=jedp, a=2.0+
toolkit/identity/FirefoxAccounts.jsm
--- a/toolkit/identity/FirefoxAccounts.jsm
+++ b/toolkit/identity/FirefoxAccounts.jsm
@@ -39,22 +39,24 @@ 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 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, ONLOGOUT_NOTIFICATION, false);
   }
 
   // Maintain interface parity with Identity.jsm and MinimalIdentity.jsm
   this.RP = this;
 
   this._rpFlows = new Map();
 
   // Enable us to mock FxAccountsManager service in testing
@@ -62,24 +64,30 @@ 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_NOTIFICATION
+        // Paranoia against matching null ONVERIFIED or ONLOGOUT
         break;
       case ONVERIFIED_NOTIFICATION:
         log.debug("Received " + ONVERIFIED_NOTIFICATION + "; firing request()s");
         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);
         }
         break;
     }
   },