зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1325797 - shield-recipe-client: Don't fail if the dev-mode pref is missing on startup r=rhelmer
MozReview-Commit-ID: CTse7NSUgF2 --HG-- extra : rebase_source : edc533a3a3b9412bf910f60377d6c2b4b843117a
This commit is contained in:
Родитель
5d4cad020a
Коммит
ad1c6503e1
|
@ -19,7 +19,7 @@ const REASONS = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const PREF_BRANCH = "extensions.shield-recipe-client.";
|
const PREF_BRANCH = "extensions.shield-recipe-client.";
|
||||||
const PREFS = {
|
const DEFAULT_PREFS = {
|
||||||
api_url: "https://self-repair.mozilla.org/api/v1",
|
api_url: "https://self-repair.mozilla.org/api/v1",
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
@ -35,7 +35,7 @@ this.install = function() {
|
||||||
// next startup to run, unless the dev_mode preference is set.
|
// next startup to run, unless the dev_mode preference is set.
|
||||||
if (Preferences.get(PREF_SELF_SUPPORT_ENABLED, true)) {
|
if (Preferences.get(PREF_SELF_SUPPORT_ENABLED, true)) {
|
||||||
Preferences.set(PREF_SELF_SUPPORT_ENABLED, false);
|
Preferences.set(PREF_SELF_SUPPORT_ENABLED, false);
|
||||||
if (!Services.prefs.getBoolPref(PREF_DEV_MODE, false)) {
|
if (!Preferences.get(PREF_DEV_MODE, false)) {
|
||||||
shouldRun = false;
|
shouldRun = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,21 +82,11 @@ this.uninstall = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
function setDefaultPrefs() {
|
function setDefaultPrefs() {
|
||||||
const branch = Services.prefs.getDefaultBranch(PREF_BRANCH);
|
for (const [key, val] of Object.entries(DEFAULT_PREFS)) {
|
||||||
for (const [key, val] of Object.entries(PREFS)) {
|
const fullKey = PREF_BRANCH + key;
|
||||||
// If someone beat us to setting a default, don't overwrite it.
|
// If someone beat us to setting a default, don't overwrite it.
|
||||||
if (branch.getPrefType(key) !== branch.PREF_INVALID)
|
if (!Preferences.isSet(fullKey)) {
|
||||||
continue;
|
Preferences.set(fullKey, val);
|
||||||
switch (typeof val) {
|
|
||||||
case "boolean":
|
|
||||||
branch.setBoolPref(key, val);
|
|
||||||
break;
|
|
||||||
case "number":
|
|
||||||
branch.setIntPref(key, val);
|
|
||||||
break;
|
|
||||||
case "string":
|
|
||||||
branch.setCharPref(key, val);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче