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