diff options
Diffstat (limited to 'modules/libpref/nsPrefBranch.cpp')
-rw-r--r-- | modules/libpref/nsPrefBranch.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/modules/libpref/nsPrefBranch.cpp b/modules/libpref/nsPrefBranch.cpp index 98e06aaa4..5173db06e 100644 --- a/modules/libpref/nsPrefBranch.cpp +++ b/modules/libpref/nsPrefBranch.cpp @@ -141,6 +141,20 @@ NS_IMETHODIMP nsPrefBranch::GetPrefType(const char *aPrefName, int32_t *_retval) return NS_OK; } +NS_IMETHODIMP nsPrefBranch::GetBoolPrefWithDefault(const char *aPrefName, + bool aDefaultValue, + uint8_t _argc, bool *_retval) +{ + nsresult rv = GetBoolPref(aPrefName, _retval); + + if (NS_FAILED(rv) && _argc == 1) { + *_retval = aDefaultValue; + return NS_OK; + } + + return rv; +} + NS_IMETHODIMP nsPrefBranch::GetBoolPref(const char *aPrefName, bool *_retval) { NS_ENSURE_ARG(aPrefName); @@ -156,6 +170,20 @@ NS_IMETHODIMP nsPrefBranch::SetBoolPref(const char *aPrefName, bool aValue) return PREF_SetBoolPref(pref, aValue, mIsDefault); } +NS_IMETHODIMP nsPrefBranch::GetFloatPrefWithDefault(const char *aPrefName, + float aDefaultValue, + uint8_t _argc, float *_retval) +{ + nsresult rv = GetFloatPref(aPrefName, _retval); + + if (NS_FAILED(rv) && _argc == 1) { + *_retval = aDefaultValue; + return NS_OK; + } + + return rv; +} + NS_IMETHODIMP nsPrefBranch::GetFloatPref(const char *aPrefName, float *_retval) { NS_ENSURE_ARG(aPrefName); @@ -169,6 +197,21 @@ NS_IMETHODIMP nsPrefBranch::GetFloatPref(const char *aPrefName, float *_retval) return rv; } +NS_IMETHODIMP nsPrefBranch::GetCharPrefWithDefault(const char *aPrefName, + const char *aDefaultValue, + uint8_t _argc, char **_retval) +{ + nsresult rv = GetCharPref(aPrefName, _retval); + + if (NS_FAILED(rv) && _argc == 1) { + NS_ENSURE_ARG(aDefaultValue); + *_retval = NS_strdup(aDefaultValue); + return NS_OK; + } + + return rv; +} + NS_IMETHODIMP nsPrefBranch::GetCharPref(const char *aPrefName, char **_retval) { NS_ENSURE_ARG(aPrefName); @@ -195,6 +238,20 @@ nsresult nsPrefBranch::SetCharPrefInternal(const char *aPrefName, const char *aV return PREF_SetCharPref(pref, aValue, mIsDefault); } +NS_IMETHODIMP nsPrefBranch::GetIntPrefWithDefault(const char *aPrefName, + int32_t aDefaultValue, + uint8_t _argc, int32_t *_retval) +{ + nsresult rv = GetIntPref(aPrefName, _retval); + + if (NS_FAILED(rv) && _argc == 1) { + *_retval = aDefaultValue; + return NS_OK; + } + + return rv; +} + NS_IMETHODIMP nsPrefBranch::GetIntPref(const char *aPrefName, int32_t *_retval) { NS_ENSURE_ARG(aPrefName); |