Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/prefs.js

Issue 6647895159734272: Issue 1489 - Support preconfigured defaults (Closed)
Patch Set: Added braces around the if body Created April 28, 2015, 9:28 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/prefs.js
===================================================================
--- a/lib/prefs.js
+++ b/lib/prefs.js
@@ -8,6 +8,8 @@
let {addonRoot, addonName} = require("info");
let branchName = "extensions." + addonName + ".";
let branch = Services.prefs.getBranch(branchName);
+let preconfiguredBranch =
+ Services.prefs.getBranch(branchName + "preconfigured.");
let ignorePrefChanges = false;
function init()
@@ -16,7 +18,7 @@
let defaultBranch = Services.prefs.getDefaultBranch(branchName);
let scope =
{
- pref: function(pref, value)
+ pref: function(pref, value, preconfigurable)
{
if (pref.substr(0, branchName.length) != branchName)
{
@@ -26,6 +28,14 @@
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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld