Fix emulator build error
[platform/framework/web/chromium-efl.git] / components / prefs / default_pref_store.h
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.
4
5 #ifndef COMPONENTS_PREFS_DEFAULT_PREF_STORE_H_
6 #define COMPONENTS_PREFS_DEFAULT_PREF_STORE_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/observer_list.h"
12 #include "base/strings/string_piece.h"
13 #include "base/values.h"
14 #include "components/prefs/pref_store.h"
15 #include "components/prefs/pref_value_map.h"
16 #include "components/prefs/prefs_export.h"
17
18 // Used within a PrefRegistry to keep track of default preference values.
19 class COMPONENTS_PREFS_EXPORT DefaultPrefStore : public PrefStore {
20  public:
21   typedef PrefValueMap::const_iterator const_iterator;
22
23   DefaultPrefStore();
24
25   DefaultPrefStore(const DefaultPrefStore&) = delete;
26   DefaultPrefStore& operator=(const DefaultPrefStore&) = delete;
27
28   // PrefStore implementation:
29   bool GetValue(base::StringPiece key,
30                 const base::Value** result) const override;
31   base::Value::Dict GetValues() const override;
32   void AddObserver(PrefStore::Observer* observer) override;
33   void RemoveObserver(PrefStore::Observer* observer) override;
34   bool HasObservers() const override;
35
36   // Sets a |value| for |key|. Should only be called if a value has not been
37   // set yet; otherwise call ReplaceDefaultValue().
38   void SetDefaultValue(const std::string& key, base::Value value);
39
40   // Replaces the the value for |key| with a new value. Should only be called
41   // if a value has alreday been set; otherwise call SetDefaultValue().
42   void ReplaceDefaultValue(const std::string& key, base::Value value);
43
44   const_iterator begin() const;
45   const_iterator end() const;
46
47  private:
48   ~DefaultPrefStore() override;
49
50   PrefValueMap prefs_;
51
52   base::ObserverList<PrefStore::Observer, true>::Unchecked observers_;
53 };
54
55 #endif  // COMPONENTS_PREFS_DEFAULT_PREF_STORE_H_