1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00

code review for last commit

This commit is contained in:
gorhill 2015-08-15 16:19:38 -04:00
parent 2d131e8fab
commit 56451cf069

View File

@ -156,55 +156,43 @@ vAPI.browserSettings = {
getValue: function(path, setting) { getValue: function(path, setting) {
var branch = Services.prefs.getBranch(path + '.'); var branch = Services.prefs.getBranch(path + '.');
var getMethod;
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPrefBranch#getPrefType%28%29 // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPrefBranch#getPrefType%28%29
var getMethod;
switch ( branch.getPrefType(setting) ) { switch ( branch.getPrefType(setting) ) {
// PREF_INT case 64: // PREF_INT
case 64:
getMethod = 'getIntPref'; getMethod = 'getIntPref';
break; break;
// PREF_BOOL case 128: // PREF_BOOL
case 128:
getMethod = 'getBoolPref'; getMethod = 'getBoolPref';
break; break;
default: default: // not supported
break; return;
} }
if ( getMethod !== undefined ) {
try { try {
return branch[getMethod](setting); return branch[getMethod](setting);
} catch (ex) { } catch (ex) {
} }
}
return undefined;
}, },
setValue: function(path, setting, value) { setValue: function(path, setting, value) {
var branch = Services.prefs.getBranch(path + '.');
var setMethod; var setMethod;
switch ( typeof value ) { switch ( typeof value ) {
// PREF_INT
case 'number': case 'number':
setMethod = 'setIntPref'; setMethod = 'setIntPref';
break; break;
// PREF_BOOL
case 'boolean': case 'boolean':
setMethod = 'setBoolPref'; setMethod = 'setBoolPref';
break; break;
default: default: // not supported
break; return;
} }
if ( setMethod !== undefined ) {
try { try {
branch[setMethod](setting, value); Services.prefs.getBranch(path + '.')[setMethod](setting, value);
} catch (ex) { } catch (ex) {
} }
}
}, },
set: function(details) { set: function(details) {