--- a/services/sync/Weave.js
+++ b/services/sync/Weave.js
@@ -60,16 +60,28 @@ WeaveService.prototype = {
ensureLoaded: function () {
Components.utils.import("resource://services-sync/main.js");
// Side-effect of accessing the service is that it is instantiated.
Weave.Service;
},
+ get fxAccountsEnabled() {
+ let fxAccountsEnabled = false;
+ try {
+ fxAccountsEnabled = Services.prefs.getBoolPref("identity.fxaccounts.enabled");
+ } catch (_) {
+ }
+ // Currently we don't support toggling this pref after initialization, so
+ // inject the pref value as a regular boolean.
+ delete this.fxAccountsEnabled;
+ return this.fxAccountsEnabled = fxAccountsEnabled;
+ },
+
maybeInitWithFxAccountsAndEnsureLoaded: function() {
Components.utils.import("resource://services-sync/main.js");
// FxAccounts imports lots of stuff, so only do this as we need it
Cu.import("resource://gre/modules/FxAccounts.jsm");
// This isn't quite sufficient here to handle all the cases. Cases
// we need to handle:
// - User is signed in to FxAccounts, btu hasn't set up sync.
@@ -120,30 +132,39 @@ WeaveService.prototype = {
os.addObserver(this, "fxaccounts:onlogout", true);
break;
case "final-ui-startup":
// Force Weave service to load if it hasn't triggered from overlays
this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
this.timer.initWithCallback({
notify: function() {
- // We only load more if it looks like Sync is configured.
- let prefs = Services.prefs.getBranch(SYNC_PREFS_BRANCH);
- if (!prefs.prefHasUserValue("username")) {
- return;
- }
+ if (this.fxAccountsEnabled) {
+ // init the fxAccounts identity manager.
+ this.maybeInitWithFxAccountsAndEnsureLoaded();
+ } else {
+ // init the "old" style, sync-specific identity manager.
+ // We only load more if it looks like Sync is configured.
+ let prefs = Services.prefs.getBranch(SYNC_PREFS_BRANCH);
+ if (!prefs.prefHasUserValue("username")) {
+ return;
+ }
- // We have a username. So, do a more thorough check. This will
- // import a number of modules and thus increase memory
- // accordingly. We could potentially copy code performed by
- // this check into this file if our above code is yielding too
- // many false positives.
- this.maybeInitWithFxAccountsAndEnsureLoaded();
+ // We have a username. So, do a more thorough check. This will
+ // import a number of modules and thus increase memory
+ // accordingly. We could potentially copy code performed by
+ // this check into this file if our above code is yielding too
+ // many false positives.
+ Components.utils.import("resource://services-sync/main.js");
+ if (Weave.Status.checkSetup() != Weave.CLIENT_NOT_CONFIGURED) {
+ this.ensureLoaded();
+ }
+ }
}.bind(this)
- }, 1000, Ci.nsITimer.TYPE_ONE_SHOT);
+ }, 10000, Ci.nsITimer.TYPE_ONE_SHOT);
break;
case 'fxaccounts:onlogin':
// Tell sync that if this is a first sync, it should try and sync the
// server data with what is on the client - despite the name implying
// otherwise, this is what "resetClient" does.
// TOOD: This implicitly assumes we're in the CLIENT_NOT_CONFIGURED state, and
// if we're not, we should handle it here.