aboutsummaryrefslogtreecommitdiffstats
path: root/platform
diff options
context:
space:
mode:
authorgorhill <rhill@raymondhill.net>2015-08-15 16:19:38 -0400
committergorhill <rhill@raymondhill.net>2015-08-15 16:19:38 -0400
commit56451cf069090fab10053f8df55d98c4ae8b8278 (patch)
treeff6cfb3007c18bc3bb62f39d0eccbabc94da2d57 /platform
parent2d131e8fab0459458cb600177c80acc94b90abd0 (diff)
downloaduBlock-56451cf069090fab10053f8df55d98c4ae8b8278.zip
uBlock-56451cf069090fab10053f8df55d98c4ae8b8278.tar.gz
uBlock-56451cf069090fab10053f8df55d98c4ae8b8278.tar.bz2
code review for last commit
Diffstat (limited to 'platform')
-rw-r--r--platform/firefox/vapi-background.js40
1 files changed, 14 insertions, 26 deletions
diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js
index b7ed8e8..19dfbb8 100644
--- a/platform/firefox/vapi-background.js
+++ b/platform/firefox/vapi-background.js
@@ -156,54 +156,42 @@ vAPI.browserSettings = {
getValue: function(path, setting) {
var branch = Services.prefs.getBranch(path + '.');
+ var getMethod;
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPrefBranch#getPrefType%28%29
- var getMethod;
switch ( branch.getPrefType(setting) ) {
- // PREF_INT
- case 64:
+ case 64: // PREF_INT
getMethod = 'getIntPref';
break;
- // PREF_BOOL
- case 128:
+ case 128: // PREF_BOOL
getMethod = 'getBoolPref';
break;
- default:
- break;
+ default: // not supported
+ return;
}
- if ( getMethod !== undefined ) {
- try {
- return branch[getMethod](setting);
- } catch (ex) {
- }
+ try {
+ return branch[getMethod](setting);
+ } catch (ex) {
}
-
- return undefined;
},
setValue: function(path, setting, value) {
- var branch = Services.prefs.getBranch(path + '.');
-
var setMethod;
switch ( typeof value ) {
- // PREF_INT
- case 'number':
+ case 'number':
setMethod = 'setIntPref';
break;
- // PREF_BOOL
case 'boolean':
setMethod = 'setBoolPref';
break;
- default:
- break;
+ default: // not supported
+ return;
}
- if ( setMethod !== undefined ) {
- try {
- branch[setMethod](setting, value);
- } catch (ex) {
- }
+ try {
+ Services.prefs.getBranch(path + '.')[setMethod](setting, value);
+ } catch (ex) {
}
},