[Pkg-mozext-commits] [adblock-plus] 05/17: Issue 2444 - Configure default prefs in JSON

David Prévot taffit at moszumanska.debian.org
Mon Jun 8 20:50:30 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus.

commit 98b495fee749a2d419dc267aa281f4924ec8b587
Author: Felix Dahlke <felix at adblockplus.org>
Date:   Fri May 1 09:06:50 2015 +0200

    Issue 2444 - Configure default prefs in JSON
---
 lib/prefs.js | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/lib/prefs.js b/lib/prefs.js
index 2cf4015..7e10d2a 100644
--- a/lib/prefs.js
+++ b/lib/prefs.js
@@ -16,31 +16,28 @@ function init()
 {
   // 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);
+  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)
-      {
-        Cu.reportError(new Error("Ignoring default preference " + pref + ", wrong branch."));
-        return;
-      }
-      pref = pref.substr(branchName.length);
-
-      let [getter, setter] = typeMap[typeof value];
-      if (preconfigurable)
+      try
       {
-        try
-        {
-          value = getter(preconfiguredBranch, pref);
-        }
-        catch (e) {}
+        value = getter(preconfiguredBranch, pref);
       }
-      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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git



More information about the Pkg-mozext-commits mailing list