PrefManager.setPref Member

Syntax

object.setPref(prefName, value);

Arguments

ArgumentSummary
prefName
value

Returns

Remarks

See Also

Source Code

function pm_setpref(prefName, value)
{
var prefManager = this;
function updateArrayPref() { prefManager.updateArrayPref(prefName); };
var record = this.prefRecords[prefName];
if (!ASSERT(record, "Unknown pref: " + prefName))
return null;
var defaultValue = record.defaultValue;
if (typeof defaultValue == "function")
defaultValue = defaultValue(prefName);
if ((record.realValue == null && value == defaultValue) ||
record.realValue == value)
{
// no realvalue, and value is the same as default value ... OR ...
// no change at all. just bail.
return record.realValue;
}
if (value == defaultValue)
{
this.clearPref(prefName);
return value;
}
if (typeof defaultValue == "boolean")
{
this.prefBranch.setBoolPref(prefName, value);
}
else if (typeof defaultValue == "number")
{
this.prefBranch.setIntPref(prefName, value);
}
else if (isinstance(defaultValue, Array))
{
var str = this.arrayToString(value);
this.prefBranch.setCharPref(prefName, str);
value.update = updateArrayPref;
}
else
{
this.prefBranch.setCharPref(prefName, fromUnicode(value, PREF_CHARSET));
}
this.delayedSave();
// Always update this after changing the preference.
record.realValue = value;
return value;
}