| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_PREFS_PREF_REGISTRY_SIMPLE_H_ | 5 #ifndef BASE_PREFS_PREF_REGISTRY_SIMPLE_H_ |
| 6 #define BASE_PREFS_PREF_REGISTRY_SIMPLE_H_ | 6 #define BASE_PREFS_PREF_REGISTRY_SIMPLE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <string> | 10 #include <string> |
| 9 | 11 |
| 12 #include "base/macros.h" |
| 10 #include "base/prefs/base_prefs_export.h" | 13 #include "base/prefs/base_prefs_export.h" |
| 11 #include "base/prefs/pref_registry.h" | 14 #include "base/prefs/pref_registry.h" |
| 12 | 15 |
| 13 namespace base { | 16 namespace base { |
| 14 class DictionaryValue; | 17 class DictionaryValue; |
| 15 class FilePath; | 18 class FilePath; |
| 16 class ListValue; | 19 class ListValue; |
| 17 } | 20 } |
| 18 | 21 |
| 19 // A simple implementation of PrefRegistry. | 22 // A simple implementation of PrefRegistry. |
| 20 class BASE_PREFS_EXPORT PrefRegistrySimple : public PrefRegistry { | 23 class BASE_PREFS_EXPORT PrefRegistrySimple : public PrefRegistry { |
| 21 public: | 24 public: |
| 22 PrefRegistrySimple(); | 25 PrefRegistrySimple(); |
| 23 | 26 |
| 24 void RegisterBooleanPref(const std::string& path, bool default_value); | 27 void RegisterBooleanPref(const std::string& path, bool default_value); |
| 25 void RegisterIntegerPref(const std::string& path, int default_value); | 28 void RegisterIntegerPref(const std::string& path, int default_value); |
| 26 void RegisterDoublePref(const std::string& path, double default_value); | 29 void RegisterDoublePref(const std::string& path, double default_value); |
| 27 void RegisterStringPref(const std::string& path, | 30 void RegisterStringPref(const std::string& path, |
| 28 const std::string& default_value); | 31 const std::string& default_value); |
| 29 void RegisterFilePathPref(const std::string& path, | 32 void RegisterFilePathPref(const std::string& path, |
| 30 const base::FilePath& default_value); | 33 const base::FilePath& default_value); |
| 31 void RegisterListPref(const std::string& path); | 34 void RegisterListPref(const std::string& path); |
| 32 void RegisterDictionaryPref(const std::string& path); | 35 void RegisterDictionaryPref(const std::string& path); |
| 33 void RegisterListPref(const std::string& path, | 36 void RegisterListPref(const std::string& path, |
| 34 base::ListValue* default_value); | 37 base::ListValue* default_value); |
| 35 void RegisterDictionaryPref(const std::string& path, | 38 void RegisterDictionaryPref(const std::string& path, |
| 36 base::DictionaryValue* default_value); | 39 base::DictionaryValue* default_value); |
| 37 void RegisterInt64Pref(const std::string& path, int64 default_value); | 40 void RegisterInt64Pref(const std::string& path, int64_t default_value); |
| 38 void RegisterUint64Pref(const std::string&, uint64 default_value); | 41 void RegisterUint64Pref(const std::string&, uint64_t default_value); |
| 39 | 42 |
| 40 // Versions of registration functions that accept PrefRegistrationFlags. | 43 // Versions of registration functions that accept PrefRegistrationFlags. |
| 41 // |flags| is a bitmask of PrefRegistrationFlags. | 44 // |flags| is a bitmask of PrefRegistrationFlags. |
| 42 void RegisterBooleanPref(const std::string&, | 45 void RegisterBooleanPref(const std::string&, |
| 43 bool default_value, | 46 bool default_value, |
| 44 uint32 flags); | 47 uint32_t flags); |
| 45 void RegisterIntegerPref(const std::string&, int default_value, uint32 flags); | 48 void RegisterIntegerPref(const std::string&, |
| 49 int default_value, |
| 50 uint32_t flags); |
| 46 void RegisterDoublePref(const std::string&, | 51 void RegisterDoublePref(const std::string&, |
| 47 double default_value, | 52 double default_value, |
| 48 uint32 flags); | 53 uint32_t flags); |
| 49 void RegisterStringPref(const std::string&, | 54 void RegisterStringPref(const std::string&, |
| 50 const std::string& default_value, | 55 const std::string& default_value, |
| 51 uint32 flags); | 56 uint32_t flags); |
| 52 void RegisterFilePathPref(const std::string&, | 57 void RegisterFilePathPref(const std::string&, |
| 53 const base::FilePath& default_value, | 58 const base::FilePath& default_value, |
| 54 uint32 flags); | 59 uint32_t flags); |
| 55 void RegisterListPref(const std::string&, uint32 flags); | 60 void RegisterListPref(const std::string&, uint32_t flags); |
| 56 void RegisterDictionaryPref(const std::string&, uint32 flags); | 61 void RegisterDictionaryPref(const std::string&, uint32_t flags); |
| 57 void RegisterListPref(const std::string&, | 62 void RegisterListPref(const std::string&, |
| 58 base::ListValue* default_value, | 63 base::ListValue* default_value, |
| 59 uint32 flags); | 64 uint32_t flags); |
| 60 void RegisterDictionaryPref(const std::string&, | 65 void RegisterDictionaryPref(const std::string&, |
| 61 base::DictionaryValue* default_value, | 66 base::DictionaryValue* default_value, |
| 62 uint32 flags); | 67 uint32_t flags); |
| 63 void RegisterInt64Pref(const std::string&, int64 default_value, uint32 flags); | 68 void RegisterInt64Pref(const std::string&, |
| 69 int64_t default_value, |
| 70 uint32_t flags); |
| 64 void RegisterUint64Pref(const std::string&, | 71 void RegisterUint64Pref(const std::string&, |
| 65 uint64 default_value, | 72 uint64_t default_value, |
| 66 uint32 flags); | 73 uint32_t flags); |
| 67 | 74 |
| 68 protected: | 75 protected: |
| 69 ~PrefRegistrySimple() override; | 76 ~PrefRegistrySimple() override; |
| 70 | 77 |
| 71 // Allows subclasses to hook into pref registration. | 78 // Allows subclasses to hook into pref registration. |
| 72 virtual void OnPrefRegistered(const std::string&, | 79 virtual void OnPrefRegistered(const std::string&, |
| 73 base::Value* default_value, | 80 base::Value* default_value, |
| 74 uint32 flags); | 81 uint32_t flags); |
| 75 | 82 |
| 76 private: | 83 private: |
| 77 void RegisterPrefAndNotify(const std::string&, | 84 void RegisterPrefAndNotify(const std::string&, |
| 78 base::Value* default_value, | 85 base::Value* default_value, |
| 79 uint32 flags); | 86 uint32_t flags); |
| 80 | 87 |
| 81 DISALLOW_COPY_AND_ASSIGN(PrefRegistrySimple); | 88 DISALLOW_COPY_AND_ASSIGN(PrefRegistrySimple); |
| 82 }; | 89 }; |
| 83 | 90 |
| 84 #endif // BASE_PREFS_PREF_REGISTRY_SIMPLE_H_ | 91 #endif // BASE_PREFS_PREF_REGISTRY_SIMPLE_H_ |
| OLD | NEW |