Bug 1299445 - use distribution.ini directly to check if automigration is enabled, r=mkaply

MozReview-Commit-ID: DINI8rnyMfe

--HG--
extra : rebase_source : b215ff2344417c844ffa9f73ed61de0fadf82998
This commit is contained in:
Gijs Kruitbosch 2016-08-31 14:58:23 +01:00
Родитель 8880c22504
Коммит b30d0cb67b
1 изменённых файлов: 21 добавлений и 1 удалений

Просмотреть файл

@ -41,8 +41,28 @@ const AutoMigrate = {
return BOOKMARKS | HISTORY | PASSWORDS;
},
_checkIfEnabled() {
let pref = Preferences.get(kAutoMigrateEnabledPref, false);
// User-set values should take precedence:
if (Services.prefs.prefHasUserValue(kAutoMigrateEnabledPref)) {
return pref;
}
// If we're using the default value, make sure the distribution.ini
// value is taken into account even early on startup.
try {
let distributionFile = Services.dirsvc.get("XREAppDist", Ci.nsIFile);
distributionFile.append("distribution.ini");
let parser = Cc["@mozilla.org/xpcom/ini-parser-factory;1"].
getService(Ci.nsIINIParserFactory).
createINIParser(distributionFile);
return JSON.parse(parser.getString("Preferences", kAutoMigrateEnabledPref));
} catch (ex) { /* ignore exceptions (file doesn't exist, invalid value, etc.) */ }
return pref;
},
init() {
this.enabled = Preferences.get(kAutoMigrateEnabledPref, false);
this.enabled = this._checkIfEnabled();
if (this.enabled) {
this.maybeInitUndoObserver();
}