Bug 959548 - Determine what identity manager to use as sync is initialized. r=ckarlof,rnewman

This commit is contained in:
Mark Hammond 2014-01-14 13:13:08 +01:00
parent 079f8fe835
commit 3fc310513b

View File

@ -66,11 +66,35 @@ WeaveService.prototype = {
},
get fxAccountsEnabled() {
let fxAccountsEnabled = false;
// first check if Firefox accounts is available at all. This is so we can
// get this landed without forcing Fxa to be used (and require nightly
// testers to manually set this pref)
// Once we decide we want Fxa to be available, we just remove this block.
let fxAccountsAvailable;
try {
fxAccountsEnabled = Services.prefs.getBoolPref("identity.fxaccounts.enabled");
fxAccountsAvailable = Services.prefs.getBoolPref("identity.fxaccounts.enabled");
} catch (_) {
}
if (!fxAccountsAvailable) {
// Currently we don't support toggling this pref after initialization, so
// inject the pref value as a regular boolean.
delete this.fxAccountsEnabled;
this.fxAccountsEnabled = false;
return false;
}
// work out what identity manager to use. This is stored in a preference;
// if the preference exists, we trust it.
let fxAccountsEnabled;
try {
fxAccountsEnabled = Services.prefs.getBoolPref("services.sync.fxaccounts.enabled");
} catch (_) {
// That pref doesn't exist - so let's assume this is a first-run.
// If sync already appears configured, we assume it's for the legacy
// provider.
let prefs = Services.prefs.getBranch(SYNC_PREFS_BRANCH);
fxAccountsEnabled = !prefs.prefHasUserValue("username");
Services.prefs.setBoolPref("services.sync.fxaccounts.enabled", fxAccountsEnabled);
}
// Currently we don't support toggling this pref after initialization, so
// inject the pref value as a regular boolean.
delete this.fxAccountsEnabled;