зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1752331: Expose a HasDefaultValue preference r=KrisWright
Differential Revision: https://phabricator.services.mozilla.com/D137149
This commit is contained in:
Родитель
0cee01db03
Коммит
d6682db9e7
|
@ -2493,6 +2493,16 @@ nsPrefBranch::PrefHasUserValue(const char* aPrefName, bool* aRetVal) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrefBranch::PrefHasDefaultValue(const char* aPrefName, bool* aRetVal) {
|
||||
NS_ENSURE_ARG_POINTER(aRetVal);
|
||||
NS_ENSURE_ARG(aPrefName);
|
||||
|
||||
const PrefName& pref = GetPrefName(aPrefName);
|
||||
*aRetVal = Preferences::HasDefaultValue(pref.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrefBranch::LockPref(const char* aPrefName) {
|
||||
NS_ENSURE_ARG(aPrefName);
|
||||
|
@ -5011,6 +5021,14 @@ bool Preferences::HasUserValue(const char* aPrefName) {
|
|||
return pref.isSome() && pref->HasUserValue();
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool Preferences::HasDefaultValue(const char* aPrefName) {
|
||||
NS_ENSURE_TRUE(InitStaticMembers(), false);
|
||||
|
||||
Maybe<PrefWrapper> pref = pref_Lookup(aPrefName);
|
||||
return pref.isSome() && pref->HasDefaultValue();
|
||||
}
|
||||
|
||||
/* static */
|
||||
int32_t Preferences::GetType(const char* aPrefName) {
|
||||
NS_ENSURE_TRUE(InitStaticMembers(), nsIPrefBranch::PREF_INVALID);
|
||||
|
|
|
@ -223,6 +223,9 @@ class Preferences final : public nsIPrefService,
|
|||
// Whether the pref has a user value or not.
|
||||
static bool HasUserValue(const char* aPref);
|
||||
|
||||
// Whether the pref has a user value or not.
|
||||
static bool HasDefaultValue(const char* aPref);
|
||||
|
||||
// Adds/Removes the observer for the root pref branch. See nsIPrefBranch.idl
|
||||
// for details.
|
||||
static nsresult AddStrongObserver(nsIObserver* aObserver,
|
||||
|
|
|
@ -278,6 +278,25 @@ interface nsIPrefBranch : nsISupports
|
|||
*/
|
||||
boolean prefHasUserValue(in string aPrefName);
|
||||
|
||||
/**
|
||||
* Called to check if a specific preference has a default value associated to
|
||||
* it.
|
||||
*
|
||||
* @param aPrefName The preference to be tested.
|
||||
*
|
||||
* @note
|
||||
* This method can be called on either a default or user branch but, in
|
||||
* effect, always operates on the user branch.
|
||||
*
|
||||
* @note
|
||||
* This method can be used to distinguish between a built-in preference and a
|
||||
* user-added preference.
|
||||
*
|
||||
* @return boolean true The preference has a default value.
|
||||
* false The preference only has a user value.
|
||||
*/
|
||||
boolean prefHasDefaultValue(in string aPrefName);
|
||||
|
||||
/**
|
||||
* Called to check if a specific preference is locked. If a preference is
|
||||
* locked calling its Get method will always return the default value.
|
||||
|
|
Загрузка…
Ссылка в новой задаче