PrefManager.getPref Member
Syntax
object.getPref(prefName, reload);
Arguments
Argument | Summary |
---|---|
prefName | |
reload |
Returns
Remarks
See Also
Source Code
function pm_getpref(prefName, reload)
{
var prefManager = this;
function updateArrayPref() { prefManager.updateArrayPref(prefName); };
var record = this.prefRecords[prefName];
if (!ASSERT(record, "Unknown pref: " + prefName))
return null;
var defaultValue;
if (typeof record.defaultValue == "function")
{
// deferred pref, call the getter, and don't cache the result.
defaultValue = record.defaultValue(prefName);
}
else
{
if (!reload && record.realValue != null)
return record.realValue;
defaultValue = record.defaultValue;
}
var realValue = defaultValue;
try
{
if (typeof defaultValue == "boolean")
{
realValue = this.prefBranch.getBoolPref(prefName);
}
else if (typeof defaultValue == "number")
{
realValue = this.prefBranch.getIntPref(prefName);
}
else if (isinstance(defaultValue, Array))
{
realValue = this.prefBranch.getCharPref(prefName);
realValue = this.stringToArray(realValue);
realValue.update = updateArrayPref;
}
else if (typeof defaultValue == "string" ||
defaultValue == null)
{
realValue = toUnicode(this.prefBranch.getCharPref(prefName),
PREF_CHARSET);
}
}
catch (ex)
{
// if the pref doesn't exist, ignore the exception.
}
record.realValue = realValue;
return realValue;
}