| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_PREFS_OVERLAY_USER_PREF_STORE_H_ | 5 #ifndef CHROME_BROWSER_PREFS_OVERLAY_USER_PREF_STORE_H_ |
| 6 #define CHROME_BROWSER_PREFS_OVERLAY_USER_PREF_STORE_H_ | 6 #define CHROME_BROWSER_PREFS_OVERLAY_USER_PREF_STORE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 virtual void SetValue(const std::string& key, base::Value* value) OVERRIDE; | 43 virtual void SetValue(const std::string& key, base::Value* value) OVERRIDE; |
| 44 virtual void SetValueSilently(const std::string& key, | 44 virtual void SetValueSilently(const std::string& key, |
| 45 base::Value* value) OVERRIDE; | 45 base::Value* value) OVERRIDE; |
| 46 virtual void RemoveValue(const std::string& key) OVERRIDE; | 46 virtual void RemoveValue(const std::string& key) OVERRIDE; |
| 47 virtual bool ReadOnly() const OVERRIDE; | 47 virtual bool ReadOnly() const OVERRIDE; |
| 48 virtual PrefReadError ReadPrefs() OVERRIDE; | 48 virtual PrefReadError ReadPrefs() OVERRIDE; |
| 49 virtual void ReadPrefsAsync(ReadErrorDelegate* delegate) OVERRIDE; | 49 virtual void ReadPrefsAsync(ReadErrorDelegate* delegate) OVERRIDE; |
| 50 virtual void CommitPendingWrite() OVERRIDE; | 50 virtual void CommitPendingWrite() OVERRIDE; |
| 51 virtual void ReportValueChanged(const std::string& key) OVERRIDE; | 51 virtual void ReportValueChanged(const std::string& key) OVERRIDE; |
| 52 | 52 |
| 53 protected: | 53 void RegisterOverlayPref(const std::string& key); |
| 54 void RegisterOverlayProperty(const std::string& key); | 54 void RegisterOverlayPref(const std::string& overlay_key, |
| 55 void RegisterOverlayProperty(const std::string& overlay_key, | 55 const std::string& underlay_key); |
| 56 const std::string& underlay_key); | |
| 57 | 56 |
| 58 private: | 57 private: |
| 59 friend class OverlayUserPrefStoreTest; | |
| 60 | |
| 61 typedef std::map<std::string, std::string> NamesMap; | 58 typedef std::map<std::string, std::string> NamesMap; |
| 62 | 59 |
| 63 // Methods of PrefStore::Observer. | 60 // Methods of PrefStore::Observer. |
| 64 virtual void OnPrefValueChanged(const std::string& key) OVERRIDE; | 61 virtual void OnPrefValueChanged(const std::string& key) OVERRIDE; |
| 65 virtual void OnInitializationCompleted(bool succeeded) OVERRIDE; | 62 virtual void OnInitializationCompleted(bool succeeded) OVERRIDE; |
| 66 | 63 |
| 67 const std::string& GetOverlayKey(const std::string& underlay_key) const; | 64 const std::string& GetOverlayKey(const std::string& underlay_key) const; |
| 68 const std::string& GetUnderlayKey(const std::string& overlay_key) const; | 65 const std::string& GetUnderlayKey(const std::string& overlay_key) const; |
| 69 | 66 |
| 70 // Returns true if |key| corresponds to a preference that shall be stored in | 67 // Returns true if |key| corresponds to a preference that shall be stored in |
| 71 // an in-memory PrefStore that is not persisted to disk. | 68 // an in-memory PrefStore that is not persisted to disk. |
| 72 bool ShallBeStoredInOverlay(const std::string& key) const; | 69 bool ShallBeStoredInOverlay(const std::string& key) const; |
| 73 | 70 |
| 74 ObserverList<PrefStore::Observer, true> observers_; | 71 ObserverList<PrefStore::Observer, true> observers_; |
| 75 PrefValueMap overlay_; | 72 PrefValueMap overlay_; |
| 76 scoped_refptr<PersistentPrefStore> underlay_; | 73 scoped_refptr<PersistentPrefStore> underlay_; |
| 77 NamesMap overlay_to_underlay_names_map_; | 74 NamesMap overlay_to_underlay_names_map_; |
| 78 NamesMap underlay_to_overlay_names_map_; | 75 NamesMap underlay_to_overlay_names_map_; |
| 79 | 76 |
| 80 DISALLOW_COPY_AND_ASSIGN(OverlayUserPrefStore); | 77 DISALLOW_COPY_AND_ASSIGN(OverlayUserPrefStore); |
| 81 }; | 78 }; |
| 82 | 79 |
| 83 #endif // CHROME_BROWSER_PREFS_OVERLAY_USER_PREF_STORE_H_ | 80 #endif // CHROME_BROWSER_PREFS_OVERLAY_USER_PREF_STORE_H_ |
| OLD | NEW |