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_DEFAULT_PREF_STORE_H_ | 5 #ifndef BASE_PREFS_DEFAULT_PREF_STORE_H_ |
6 #define BASE_PREFS_DEFAULT_PREF_STORE_H_ | 6 #define BASE_PREFS_DEFAULT_PREF_STORE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/prefs/base_prefs_export.h" | 10 #include "base/prefs/base_prefs_export.h" |
11 #include "base/prefs/pref_store.h" | 11 #include "base/prefs/pref_store.h" |
12 #include "base/prefs/pref_value_map.h" | 12 #include "base/prefs/pref_value_map.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 | 14 |
15 // This PrefStore keeps track of default preference values set when a | 15 // Used within a PrefRegistry to keep track of default preference values. |
16 // preference is registered with the PrefService. | |
17 class BASE_PREFS_EXPORT DefaultPrefStore : public PrefStore { | 16 class BASE_PREFS_EXPORT DefaultPrefStore : public PrefStore { |
18 public: | 17 public: |
19 typedef PrefValueMap::const_iterator const_iterator; | 18 typedef PrefValueMap::const_iterator const_iterator; |
20 | 19 |
21 DefaultPrefStore(); | 20 DefaultPrefStore(); |
22 | 21 |
23 virtual bool GetValue(const std::string& key, | 22 virtual bool GetValue(const std::string& key, |
24 const base::Value** result) const OVERRIDE; | 23 const base::Value** result) const OVERRIDE; |
25 | 24 |
26 // Stores a new |value| for |key|. Assumes ownership of |value|. | 25 // Stores a new |value| for |key|. Assumes ownership of |value|. |
27 void SetDefaultValue(const std::string& key, Value* value); | 26 void SetDefaultValue(const std::string& key, Value* value); |
28 | 27 |
29 // Removes the value for |key|. | 28 // Removes the value for |key|. |
30 void RemoveDefaultValue(const std::string& key); | 29 void RemoveDefaultValue(const std::string& key); |
31 | 30 |
32 // Returns the registered type for |key| or Value::TYPE_NULL if the |key| | |
33 // has not been registered. | |
34 base::Value::Type GetType(const std::string& key) const; | |
35 | |
36 const_iterator begin() const; | 31 const_iterator begin() const; |
37 const_iterator end() const; | 32 const_iterator end() const; |
38 | 33 |
39 protected: | 34 protected: |
40 virtual ~DefaultPrefStore(); | 35 virtual ~DefaultPrefStore(); |
41 | 36 |
42 private: | 37 private: |
43 PrefValueMap prefs_; | 38 PrefValueMap prefs_; |
44 | 39 |
45 DISALLOW_COPY_AND_ASSIGN(DefaultPrefStore); | 40 DISALLOW_COPY_AND_ASSIGN(DefaultPrefStore); |
46 }; | 41 }; |
47 | 42 |
48 #endif // BASE_PREFS_DEFAULT_PREF_STORE_H_ | 43 #endif // BASE_PREFS_DEFAULT_PREF_STORE_H_ |
OLD | NEW |