diff options
author | raymes <raymes@chromium.org> | 2015-04-26 18:23:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-27 01:23:14 +0000 |
commit | 25fb8e7f1fd5769b9fb782d39b17599544236b50 (patch) | |
tree | 42fdd7625b5cd410e54523e7c42bba08ec28c65e /base/prefs | |
parent | 4273094de655e5568c4fc9cca236a45c29a635b1 (diff) | |
download | chromium_src-25fb8e7f1fd5769b9fb782d39b17599544236b50.zip chromium_src-25fb8e7f1fd5769b9fb782d39b17599544236b50.tar.gz chromium_src-25fb8e7f1fd5769b9fb782d39b17599544236b50.tar.bz2 |
Move pref registration functions into PrefRegistrySimple
This moves all pref registration functions from PrefRegistrySyncable
into PrefRegistrySimple and changes PrefRegistrySyncable to derive
from PrefRegistrySyncable. This is done to consolidate the registration
functions in a single place that can be used by syncable and unsyncable
prefs.
BUG=476800
Review URL: https://codereview.chromium.org/1095673003
Cr-Commit-Position: refs/heads/master@{#326991}
Diffstat (limited to 'base/prefs')
-rw-r--r-- | base/prefs/pref_registry_simple.cc | 127 | ||||
-rw-r--r-- | base/prefs/pref_registry_simple.h | 41 |
2 files changed, 145 insertions, 23 deletions
diff --git a/base/prefs/pref_registry_simple.cc b/base/prefs/pref_registry_simple.cc index 1719419..93c2686 100644 --- a/base/prefs/pref_registry_simple.cc +++ b/base/prefs/pref_registry_simple.cc @@ -16,63 +16,146 @@ PrefRegistrySimple::~PrefRegistrySimple() { void PrefRegistrySimple::RegisterBooleanPref(const std::string& path, bool default_value) { - RegisterPreference(path, - new base::FundamentalValue(default_value), - NO_REGISTRATION_FLAGS); + RegisterPrefAndNotify(path, new base::FundamentalValue(default_value), + NO_REGISTRATION_FLAGS); } void PrefRegistrySimple::RegisterIntegerPref(const std::string& path, int default_value) { - RegisterPreference(path, - new base::FundamentalValue(default_value), - NO_REGISTRATION_FLAGS); + RegisterPrefAndNotify(path, new base::FundamentalValue(default_value), + NO_REGISTRATION_FLAGS); } void PrefRegistrySimple::RegisterDoublePref(const std::string& path, double default_value) { - RegisterPreference(path, - new base::FundamentalValue(default_value), - NO_REGISTRATION_FLAGS); + RegisterPrefAndNotify(path, new base::FundamentalValue(default_value), + NO_REGISTRATION_FLAGS); } void PrefRegistrySimple::RegisterStringPref(const std::string& path, const std::string& default_value) { - RegisterPreference(path, - new base::StringValue(default_value), - NO_REGISTRATION_FLAGS); + RegisterPrefAndNotify(path, new base::StringValue(default_value), + NO_REGISTRATION_FLAGS); } void PrefRegistrySimple::RegisterFilePathPref( const std::string& path, const base::FilePath& default_value) { - RegisterPreference(path, - new base::StringValue(default_value.value()), - NO_REGISTRATION_FLAGS); + RegisterPrefAndNotify(path, new base::StringValue(default_value.value()), + NO_REGISTRATION_FLAGS); } void PrefRegistrySimple::RegisterListPref(const std::string& path) { - RegisterPreference(path, new base::ListValue(), NO_REGISTRATION_FLAGS); + RegisterPrefAndNotify(path, new base::ListValue(), NO_REGISTRATION_FLAGS); } void PrefRegistrySimple::RegisterListPref(const std::string& path, base::ListValue* default_value) { - RegisterPreference(path, default_value, NO_REGISTRATION_FLAGS); + RegisterPrefAndNotify(path, default_value, NO_REGISTRATION_FLAGS); } void PrefRegistrySimple::RegisterDictionaryPref(const std::string& path) { - RegisterPreference(path, new base::DictionaryValue(), NO_REGISTRATION_FLAGS); + RegisterPrefAndNotify(path, new base::DictionaryValue(), + NO_REGISTRATION_FLAGS); } void PrefRegistrySimple::RegisterDictionaryPref( const std::string& path, base::DictionaryValue* default_value) { - RegisterPreference(path, default_value, NO_REGISTRATION_FLAGS); + RegisterPrefAndNotify(path, default_value, NO_REGISTRATION_FLAGS); } void PrefRegistrySimple::RegisterInt64Pref(const std::string& path, int64 default_value) { - RegisterPreference( - path, - new base::StringValue(base::Int64ToString(default_value)), + RegisterPrefAndNotify( + path, new base::StringValue(base::Int64ToString(default_value)), NO_REGISTRATION_FLAGS); } + +void PrefRegistrySimple::RegisterUint64Pref(const std::string& path, + uint64 default_value) { + RegisterPrefAndNotify( + path, new base::StringValue(base::Uint64ToString(default_value)), + NO_REGISTRATION_FLAGS); +} + +void PrefRegistrySimple::RegisterBooleanPref(const std::string& path, + bool default_value, + uint32 flags) { + RegisterPrefAndNotify(path, new base::FundamentalValue(default_value), flags); +} + +void PrefRegistrySimple::RegisterIntegerPref(const std::string& path, + int default_value, + uint32 flags) { + RegisterPrefAndNotify(path, new base::FundamentalValue(default_value), flags); +} + +void PrefRegistrySimple::RegisterDoublePref(const std::string& path, + double default_value, + uint32 flags) { + RegisterPrefAndNotify(path, new base::FundamentalValue(default_value), flags); +} + +void PrefRegistrySimple::RegisterStringPref(const std::string& path, + const std::string& default_value, + uint32 flags) { + RegisterPrefAndNotify(path, new base::StringValue(default_value), flags); +} + +void PrefRegistrySimple::RegisterFilePathPref( + const std::string& path, + const base::FilePath& default_value, + uint32 flags) { + RegisterPrefAndNotify(path, new base::StringValue(default_value.value()), + flags); +} + +void PrefRegistrySimple::RegisterListPref(const std::string& path, + uint32 flags) { + RegisterPrefAndNotify(path, new base::ListValue(), flags); +} + +void PrefRegistrySimple::RegisterListPref(const std::string& path, + base::ListValue* default_value, + uint32 flags) { + RegisterPrefAndNotify(path, default_value, flags); +} + +void PrefRegistrySimple::RegisterDictionaryPref(const std::string& path, + uint32 flags) { + RegisterPrefAndNotify(path, new base::DictionaryValue(), flags); +} + +void PrefRegistrySimple::RegisterDictionaryPref( + const std::string& path, + base::DictionaryValue* default_value, + uint32 flags) { + RegisterPrefAndNotify(path, default_value, flags); +} + +void PrefRegistrySimple::RegisterInt64Pref(const std::string& path, + int64 default_value, + uint32 flags) { + RegisterPrefAndNotify( + path, new base::StringValue(base::Int64ToString(default_value)), flags); +} + +void PrefRegistrySimple::RegisterUint64Pref(const std::string& path, + uint64 default_value, + uint32 flags) { + RegisterPrefAndNotify( + path, new base::StringValue(base::Uint64ToString(default_value)), flags); +} + +void PrefRegistrySimple::OnPrefRegistered(const std::string& path, + base::Value* default_value, + uint32 flags) { +} + +void PrefRegistrySimple::RegisterPrefAndNotify(const std::string& path, + base::Value* default_value, + uint32 flags) { + RegisterPreference(path, default_value, flags); + OnPrefRegistered(path, default_value, flags); +} diff --git a/base/prefs/pref_registry_simple.h b/base/prefs/pref_registry_simple.h index 73ae216..6b69e30 100644 --- a/base/prefs/pref_registry_simple.h +++ b/base/prefs/pref_registry_simple.h @@ -35,10 +35,49 @@ class BASE_PREFS_EXPORT PrefRegistrySimple : public PrefRegistry { void RegisterDictionaryPref(const std::string& path, base::DictionaryValue* default_value); void RegisterInt64Pref(const std::string& path, int64 default_value); + void RegisterUint64Pref(const std::string&, uint64 default_value); - private: + // Versions of registration functions that accept PrefRegistrationFlags. + // |flags| is a bitmask of PrefRegistrationFlags. + void RegisterBooleanPref(const std::string&, + bool default_value, + uint32 flags); + void RegisterIntegerPref(const std::string&, int default_value, uint32 flags); + void RegisterDoublePref(const std::string&, + double default_value, + uint32 flags); + void RegisterStringPref(const std::string&, + const std::string& default_value, + uint32 flags); + void RegisterFilePathPref(const std::string&, + const base::FilePath& default_value, + uint32 flags); + void RegisterListPref(const std::string&, uint32 flags); + void RegisterDictionaryPref(const std::string&, uint32 flags); + void RegisterListPref(const std::string&, + base::ListValue* default_value, + uint32 flags); + void RegisterDictionaryPref(const std::string&, + base::DictionaryValue* default_value, + uint32 flags); + void RegisterInt64Pref(const std::string&, int64 default_value, uint32 flags); + void RegisterUint64Pref(const std::string&, + uint64 default_value, + uint32 flags); + + protected: ~PrefRegistrySimple() override; + // Allows subclasses to hook into pref registration. + virtual void OnPrefRegistered(const std::string&, + base::Value* default_value, + uint32 flags); + + private: + void RegisterPrefAndNotify(const std::string&, + base::Value* default_value, + uint32 flags); + DISALLOW_COPY_AND_ASSIGN(PrefRegistrySimple); }; |