OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 |
| 5 #ifndef CHROME_BROWSER_PREFS_DICTIONARY_PREF_STORE_H_ |
| 6 #define CHROME_BROWSER_PREFS_DICTIONARY_PREF_STORE_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" |
| 12 #include "base/observer_list.h" |
| 13 #include "base/prefs/writeable_pref_store.h" |
| 14 |
| 15 namespace base { |
| 16 class DictionaryValue; |
| 17 } // namespace base |
| 18 |
| 19 // An in-memory PrefStore backed by a DictionaryValue. |
| 20 class DictionaryPrefStore : public WriteablePrefStore { |
| 21 public: |
| 22 explicit DictionaryPrefStore(base::DictionaryValue* dictionary); |
| 23 |
| 24 // PrefStore implementation |
| 25 virtual bool GetValue(const std::string& key, |
| 26 const base::Value** result) const OVERRIDE; |
| 27 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; |
| 28 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE; |
| 29 virtual bool HasObservers() const OVERRIDE; |
| 30 |
| 31 // WriteablePrefStore implementation |
| 32 virtual void SetValue(const std::string& key, base::Value* value) OVERRIDE; |
| 33 virtual void RemoveValue(const std::string& key) OVERRIDE; |
| 34 virtual bool GetMutableValue(const std::string& key, |
| 35 base::Value** result) OVERRIDE; |
| 36 virtual void ReportValueChanged(const std::string& key) OVERRIDE; |
| 37 |
| 38 private: |
| 39 virtual ~DictionaryPrefStore(); |
| 40 |
| 41 base::DictionaryValue* dictionary_; |
| 42 ObserverList<PrefStore::Observer, true> observers_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(DictionaryPrefStore); |
| 45 }; |
| 46 |
| 47 #endif // CHROME_BROWSER_PREFS_DICTIONARY_PREF_STORE_H_ |
OLD | NEW |