Bug 1025309 - Fire FxA onlogout for RPs such as FMD. r=jedp

This commit is contained in:
Sam Penrose 2014-06-17 11:28:25 -07:00
parent 9f9f9a040a
commit 704ea0627b

View File

@ -44,12 +44,14 @@ Cu.import("resource://gre/modules/FxAccountsCommon.js");
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
@ -67,7 +69,7 @@ FxAccountsService.prototype = {
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");
@ -75,6 +77,12 @@ FxAccountsService.prototype = {
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) {