1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_PREFS_VALUE_MAP_PREF_STORE_H_
6 #define COMPONENTS_PREFS_VALUE_MAP_PREF_STORE_H_
13 #include "base/observer_list.h"
14 #include "base/strings/string_piece.h"
15 #include "base/values.h"
16 #include "components/prefs/pref_value_map.h"
17 #include "components/prefs/prefs_export.h"
18 #include "components/prefs/writeable_pref_store.h"
20 // A basic PrefStore implementation that uses a simple name-value map for
21 // storing the preference values.
22 class COMPONENTS_PREFS_EXPORT ValueMapPrefStore : public WriteablePrefStore {
26 ValueMapPrefStore(const ValueMapPrefStore&) = delete;
27 ValueMapPrefStore& operator=(const ValueMapPrefStore&) = delete;
29 // PrefStore overrides:
30 bool GetValue(base::StringPiece key,
31 const base::Value** value) const override;
32 base::Value::Dict GetValues() const override;
33 void AddObserver(PrefStore::Observer* observer) override;
34 void RemoveObserver(PrefStore::Observer* observer) override;
35 bool HasObservers() const override;
37 // WriteablePrefStore overrides:
38 void SetValue(const std::string& key,
40 uint32_t flags) override;
41 void RemoveValue(const std::string& key, uint32_t flags) override;
42 bool GetMutableValue(const std::string& key, base::Value** value) override;
43 void ReportValueChanged(const std::string& key, uint32_t flags) override;
44 void SetValueSilently(const std::string& key,
46 uint32_t flags) override;
47 void RemoveValuesByPrefixSilently(const std::string& prefix) override;
50 ~ValueMapPrefStore() override;
52 // Notify observers about the initialization completed event.
53 void NotifyInitializationCompleted();
58 base::ObserverList<PrefStore::Observer, true>::Unchecked observers_;
61 #endif // COMPONENTS_PREFS_VALUE_MAP_PREF_STORE_H_