toolkit/obsolete/content/nsUserSettings.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5
michael@0 6 /**
michael@0 7 * nsPreferences - a wrapper around nsIPrefService. Provides built in
michael@0 8 * exception handling to make preferences access simpler.
michael@0 9 **/
michael@0 10 var nsPreferences = {
michael@0 11 get mPrefService()
michael@0 12 {
michael@0 13 return Components.classes["@mozilla.org/preferences-service;1"]
michael@0 14 .getService(Components.interfaces.nsIPrefBranch);
michael@0 15 },
michael@0 16
michael@0 17 setBoolPref: function (aPrefName, aPrefValue)
michael@0 18 {
michael@0 19 try
michael@0 20 {
michael@0 21 this.mPrefService.setBoolPref(aPrefName, aPrefValue);
michael@0 22 }
michael@0 23 catch(e)
michael@0 24 {
michael@0 25 }
michael@0 26 },
michael@0 27
michael@0 28 getBoolPref: function (aPrefName, aDefVal)
michael@0 29 {
michael@0 30 try
michael@0 31 {
michael@0 32 return this.mPrefService.getBoolPref(aPrefName);
michael@0 33 }
michael@0 34 catch(e)
michael@0 35 {
michael@0 36 return aDefVal != undefined ? aDefVal : null;
michael@0 37 }
michael@0 38 return null; // quiet warnings
michael@0 39 },
michael@0 40
michael@0 41 setUnicharPref: function (aPrefName, aPrefValue)
michael@0 42 {
michael@0 43 try
michael@0 44 {
michael@0 45 var str = Components.classes["@mozilla.org/supports-string;1"]
michael@0 46 .createInstance(Components.interfaces.nsISupportsString);
michael@0 47 str.data = aPrefValue;
michael@0 48 this.mPrefService.setComplexValue(aPrefName,
michael@0 49 Components.interfaces.nsISupportsString, str);
michael@0 50 }
michael@0 51 catch(e)
michael@0 52 {
michael@0 53 }
michael@0 54 },
michael@0 55
michael@0 56 copyUnicharPref: function (aPrefName, aDefVal)
michael@0 57 {
michael@0 58 try
michael@0 59 {
michael@0 60 return this.mPrefService.getComplexValue(aPrefName,
michael@0 61 Components.interfaces.nsISupportsString).data;
michael@0 62 }
michael@0 63 catch(e)
michael@0 64 {
michael@0 65 return aDefVal != undefined ? aDefVal : null;
michael@0 66 }
michael@0 67 return null; // quiet warnings
michael@0 68 },
michael@0 69
michael@0 70 setIntPref: function (aPrefName, aPrefValue)
michael@0 71 {
michael@0 72 try
michael@0 73 {
michael@0 74 this.mPrefService.setIntPref(aPrefName, aPrefValue);
michael@0 75 }
michael@0 76 catch(e)
michael@0 77 {
michael@0 78 }
michael@0 79 },
michael@0 80
michael@0 81 getIntPref: function (aPrefName, aDefVal)
michael@0 82 {
michael@0 83 try
michael@0 84 {
michael@0 85 return this.mPrefService.getIntPref(aPrefName);
michael@0 86 }
michael@0 87 catch(e)
michael@0 88 {
michael@0 89 return aDefVal != undefined ? aDefVal : null;
michael@0 90 }
michael@0 91 return null; // quiet warnings
michael@0 92 },
michael@0 93
michael@0 94 getLocalizedUnicharPref: function (aPrefName, aDefVal)
michael@0 95 {
michael@0 96 try
michael@0 97 {
michael@0 98 return this.mPrefService.getComplexValue(aPrefName,
michael@0 99 Components.interfaces.nsIPrefLocalizedString).data;
michael@0 100 }
michael@0 101 catch(e)
michael@0 102 {
michael@0 103 return aDefVal != undefined ? aDefVal : null;
michael@0 104 }
michael@0 105 return null; // quiet warnings
michael@0 106 }
michael@0 107 };
michael@0 108

mercurial