brettw | 58cd1f1 | 2016-01-30 05:56:05 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
brettw | 06650868 | 2016-02-03 08:22:02 | [diff] [blame] | 5 | #ifndef COMPONENTS_PREFS_PREF_REGISTRY_SIMPLE_H_ |
| 6 | #define COMPONENTS_PREFS_PREF_REGISTRY_SIMPLE_H_ |
brettw | 58cd1f1 | 2016-01-30 05:56:05 | [diff] [blame] | 7 | |
| 8 | #include <stdint.h> |
| 9 | |
| 10 | #include <string> |
| 11 | |
| 12 | #include "base/macros.h" |
brettw | f00b9b4 | 2016-02-01 22:11:38 | [diff] [blame] | 13 | #include "components/prefs/base_prefs_export.h" |
| 14 | #include "components/prefs/pref_registry.h" |
brettw | 58cd1f1 | 2016-01-30 05:56:05 | [diff] [blame] | 15 | |
| 16 | namespace base { |
| 17 | class DictionaryValue; |
| 18 | class FilePath; |
| 19 | class ListValue; |
| 20 | } |
| 21 | |
| 22 | // A simple implementation of PrefRegistry. |
brettw | 06650868 | 2016-02-03 08:22:02 | [diff] [blame] | 23 | class COMPONENTS_PREFS_EXPORT PrefRegistrySimple : public PrefRegistry { |
brettw | 58cd1f1 | 2016-01-30 05:56:05 | [diff] [blame] | 24 | public: |
| 25 | PrefRegistrySimple(); |
| 26 | |
| 27 | void RegisterBooleanPref(const std::string& path, bool default_value); |
| 28 | void RegisterIntegerPref(const std::string& path, int default_value); |
| 29 | void RegisterDoublePref(const std::string& path, double default_value); |
| 30 | void RegisterStringPref(const std::string& path, |
| 31 | const std::string& default_value); |
| 32 | void RegisterFilePathPref(const std::string& path, |
| 33 | const base::FilePath& default_value); |
| 34 | void RegisterListPref(const std::string& path); |
| 35 | void RegisterDictionaryPref(const std::string& path); |
| 36 | void RegisterListPref(const std::string& path, |
| 37 | base::ListValue* default_value); |
| 38 | void RegisterDictionaryPref(const std::string& path, |
| 39 | base::DictionaryValue* default_value); |
| 40 | void RegisterInt64Pref(const std::string& path, int64_t default_value); |
| 41 | void RegisterUint64Pref(const std::string&, uint64_t default_value); |
| 42 | |
| 43 | // Versions of registration functions that accept PrefRegistrationFlags. |
| 44 | // |flags| is a bitmask of PrefRegistrationFlags. |
| 45 | void RegisterBooleanPref(const std::string&, |
| 46 | bool default_value, |
| 47 | uint32_t flags); |
| 48 | void RegisterIntegerPref(const std::string&, |
| 49 | int default_value, |
| 50 | uint32_t flags); |
| 51 | void RegisterDoublePref(const std::string&, |
| 52 | double default_value, |
| 53 | uint32_t flags); |
| 54 | void RegisterStringPref(const std::string&, |
| 55 | const std::string& default_value, |
| 56 | uint32_t flags); |
| 57 | void RegisterFilePathPref(const std::string&, |
| 58 | const base::FilePath& default_value, |
| 59 | uint32_t flags); |
| 60 | void RegisterListPref(const std::string&, uint32_t flags); |
| 61 | void RegisterDictionaryPref(const std::string&, uint32_t flags); |
| 62 | void RegisterListPref(const std::string&, |
| 63 | base::ListValue* default_value, |
| 64 | uint32_t flags); |
| 65 | void RegisterDictionaryPref(const std::string&, |
| 66 | base::DictionaryValue* default_value, |
| 67 | uint32_t flags); |
| 68 | void RegisterInt64Pref(const std::string&, |
| 69 | int64_t default_value, |
| 70 | uint32_t flags); |
| 71 | void RegisterUint64Pref(const std::string&, |
| 72 | uint64_t default_value, |
| 73 | uint32_t flags); |
| 74 | |
| 75 | protected: |
| 76 | ~PrefRegistrySimple() override; |
| 77 | |
| 78 | // Allows subclasses to hook into pref registration. |
| 79 | virtual void OnPrefRegistered(const std::string&, |
| 80 | base::Value* default_value, |
| 81 | uint32_t flags); |
| 82 | |
| 83 | private: |
| 84 | void RegisterPrefAndNotify(const std::string&, |
| 85 | base::Value* default_value, |
| 86 | uint32_t flags); |
| 87 | |
| 88 | DISALLOW_COPY_AND_ASSIGN(PrefRegistrySimple); |
| 89 | }; |
| 90 | |
brettw | 06650868 | 2016-02-03 08:22:02 | [diff] [blame] | 91 | #endif // COMPONENTS_PREFS_PREF_REGISTRY_SIMPLE_H_ |