Index: lib/prefs.js |
=================================================================== |
--- a/lib/prefs.js |
+++ b/lib/prefs.js |
@@ -16,31 +16,28 @@ |
{ |
// Load default preferences and set up properties for them |
let defaultBranch = Services.prefs.getDefaultBranch(branchName); |
- let scope = |
+ |
+ let request = new XMLHttpRequest(); |
+ request.open("GET", addonRoot + "defaults/prefs.json", false); |
Felix Dahlke
2015/05/01 20:36:52
Not really happy with using a sync request here -
|
+ request.responseType = "json"; |
+ request.send(); |
+ |
+ let defaults = request.response.defaults; |
+ for (let pref in defaults) |
{ |
- pref: function(pref, value, preconfigurable) |
+ let value = defaults[pref]; |
+ let [getter, setter] = typeMap[typeof value]; |
+ if (request.response.preconfigurable.indexOf(pref) != -1) |
{ |
- if (pref.substr(0, branchName.length) != branchName) |
+ try |
{ |
- Cu.reportError(new Error("Ignoring default preference " + pref + ", wrong branch.")); |
- return; |
+ value = getter(preconfiguredBranch, pref); |
} |
- pref = pref.substr(branchName.length); |
- |
- let [getter, setter] = typeMap[typeof value]; |
- if (preconfigurable) |
- { |
- try |
- { |
- value = getter(preconfiguredBranch, pref); |
- } |
- catch (e) {} |
- } |
- setter(defaultBranch, pref, value); |
- defineProperty(pref, false, getter, setter); |
+ catch (e) {} |
} |
- }; |
- Services.scriptloader.loadSubScript(addonRoot + "defaults/prefs.js", scope); |
+ setter(defaultBranch, pref, value); |
+ defineProperty(pref, false, getter, setter); |
+ } |
// Add preference change observer |
try |