diff --git a/browser/base/content/aboutaccounts/aboutaccounts.js b/browser/base/content/aboutaccounts/aboutaccounts.js index c98c0ae941a..e009af9fe4c 100644 --- a/browser/base/content/aboutaccounts/aboutaccounts.js +++ b/browser/base/content/aboutaccounts/aboutaccounts.js @@ -16,7 +16,7 @@ Cu.import("resource://gre/modules/FxAccountsCommon.js", fxAccountsCommon); Cu.import("resource://services-sync/util.js"); const PREF_LAST_FXA_USER = "identity.fxaccounts.lastSignedInUserHash"; -const PREF_SYNC_SHOW_CUSTOMIZATION = "services.sync.ui.showCustomizationDialog"; +const PREF_SYNC_SHOW_CUSTOMIZATION = "services.sync-setup.ui.showCustomizationDialog"; const ACTION_URL_PARAM = "action"; diff --git a/services/sync/modules/FxaMigrator.jsm b/services/sync/modules/FxaMigrator.jsm index 1027b15afb2..737ff36ab2d 100644 --- a/services/sync/modules/FxaMigrator.jsm +++ b/services/sync/modules/FxaMigrator.jsm @@ -210,27 +210,39 @@ Migrator.prototype = { // Must be ready to perform the actual migration. this.log.info("Performing final sync migration steps"); - // Do the actual migration. + // Do the actual migration. We setup one observer for when the new identity + // is about to be initialized so we can reset some key preferences - but + // there's no promise associated with this. + let observeStartOverIdentity; + Services.obs.addObserver(observeStartOverIdentity = () => { + this.log.info("observed that startOver is about to re-initialize the identity"); + Services.obs.removeObserver(observeStartOverIdentity, "weave:service:start-over:init-identity"); + // We've now reset all sync prefs - set the engine related prefs back to + // what they were. + for (let [prefName, prefType, prefVal] of enginePrefs) { + this.log.debug("Restoring pref ${prefName} (type=${prefType}) to ${prefVal}", + {prefName, prefType, prefVal}); + switch (prefType) { + case Services.prefs.PREF_BOOL: + Services.prefs.setBoolPref(prefName, prefVal); + break; + case Services.prefs.PREF_STRING: + Services.prefs.setCharPref(prefName, prefVal); + break; + default: + // _getEngineEnabledPrefs doesn't return any other type... + Cu.reportError("unknown engine pref type for " + prefName + ": " + prefType); + } + } + }, "weave:service:start-over:init-identity", false); + + // And another observer for the startOver being fully complete - the only + // reason for this is so we can wait until everything is fully reset. let startOverComplete = new Promise((resolve, reject) => { let observe; Services.obs.addObserver(observe = () => { this.log.info("observed that startOver is complete"); Services.obs.removeObserver(observe, "weave:service:start-over:finish"); - // We've now reset all sync prefs - set the engine related prefs back to - // what they were. - for (let [prefName, prefType, prefVal] of enginePrefs) { - switch (prefType) { - case Services.prefs.PREF_BOOL: - Services.prefs.setBoolPref(prefName, prefVal); - break; - case Services.prefs.PREF_STRING: - Services.prefs.setCharPref(prefName, prefVal); - break; - default: - // _getEngineEnabledPrefs doesn't return any other type... - Cu.reportError("unknown engine pref type for " + prefName + ": " + prefType); - } - } resolve(); }, "weave:service:start-over:finish", false); }); @@ -240,6 +252,8 @@ Migrator.prototype = { yield startOverComplete; // observer fired, now kick things off with the FxA user. this.log.info("scheduling initial FxA sync."); + // Note we technically don't need to unblockSync as by now all sync prefs + // have been reset - but it doesn't hurt. this._unblockSync(); Weave.Service.scheduler.scheduleNextSync(0); diff --git a/services/sync/modules/browserid_identity.js b/services/sync/modules/browserid_identity.js index ef8d737d22c..f466c386e90 100644 --- a/services/sync/modules/browserid_identity.js +++ b/services/sync/modules/browserid_identity.js @@ -47,7 +47,7 @@ const OBSERVER_TOPICS = [ fxAccountsCommon.ONLOGOUT_NOTIFICATION, ]; -const PREF_SYNC_SHOW_CUSTOMIZATION = "services.sync.ui.showCustomizationDialog"; +const PREF_SYNC_SHOW_CUSTOMIZATION = "services.sync-setup.ui.showCustomizationDialog"; function deriveKeyBundle(kB) { let out = CryptoUtils.hkdf(kB, undefined, diff --git a/services/sync/modules/policies.js b/services/sync/modules/policies.js index 80992e7eb1f..4451ca79d98 100644 --- a/services/sync/modules/policies.js +++ b/services/sync/modules/policies.js @@ -592,8 +592,10 @@ ErrorHandler.prototype = { fapp.level = Log.Level[Svc.Prefs.get("log.appender.file.level")]; root.addAppender(fapp); - // Arrange for the FxA, Hawk and TokenServer logs to also go to our appenders. - for (let extra of ["FirefoxAccounts", "Hawk", "Common.TokenServerClient"]) { + // Arrange for a number of other sync-related logs to also go to our + // appenders. + for (let extra of ["FirefoxAccounts", "Hawk", "Common.TokenServerClient", + "Sync.SyncMigration"]) { let log = Log.repository.getLogger(extra); for (let appender of [fapp, dapp, capp]) { log.addAppender(appender); diff --git a/services/sync/modules/service.js b/services/sync/modules/service.js index 88b68505f7d..22cd713148d 100644 --- a/services/sync/modules/service.js +++ b/services/sync/modules/service.js @@ -926,6 +926,9 @@ Sync11Service.prototype = { this.identity.finalize().then( () => { + // an observer so the FxA migration code can take some action before + // the new identity is created. + Svc.Obs.notify("weave:service:start-over:init-identity"); this.identity.username = ""; this.status.__authManager = null; this.identity = Status._authManager;