| OLD | NEW |
| 1 // Copyright (c) 2010 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_EXTENSIONS_EXTENSION_PREF_STORE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_STORE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_STORE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_STORE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/time.h" |
| 12 #include "chrome/browser/extensions/extension_pref_value_map.h" |
| 9 #include "chrome/browser/prefs/value_map_pref_store.h" | 13 #include "chrome/browser/prefs/value_map_pref_store.h" |
| 10 | 14 |
| 11 // A PrefStore implementation that holds preferences set by extensions. | 15 // A (non-persistent) PrefStore implementation that holds effective preferences |
| 12 class ExtensionPrefStore : public ValueMapPrefStore { | 16 // set by extensions. These preferences are managed by and fetched from an |
| 17 // ExtensionPrefValueMap. |
| 18 class ExtensionPrefStore : public ValueMapPrefStore, |
| 19 public ExtensionPrefValueMap::Observer { |
| 13 public: | 20 public: |
| 14 ExtensionPrefStore(); | 21 // Constructs an ExtensionPrefStore for a regular or an incognito profile. |
| 15 virtual ~ExtensionPrefStore() {} | 22 explicit ExtensionPrefStore(ExtensionPrefValueMap* extension_pref_value_map, |
| 16 | 23 bool incognito_pref_store); |
| 17 // Set an extension preference |value| for |key|. Takes ownership of |value|. | 24 virtual ~ExtensionPrefStore(); |
| 18 void SetExtensionPref(const std::string& key, Value* value); | |
| 19 | |
| 20 // Remove the extension preference value for |key|. | |
| 21 void RemoveExtensionPref(const std::string& key); | |
| 22 | |
| 23 // Tell the store it's now fully initialized. | |
| 24 void OnInitializationCompleted(); | |
| 25 | 25 |
| 26 private: | 26 private: |
| 27 // PrefStore overrides: | 27 // Overrides for ExtensionPrefValueMap::Observer: |
| 28 virtual bool IsInitializationComplete() const; | 28 virtual void OnInitializationCompleted(); |
| 29 virtual void OnPrefValueChanged(const std::string& key); |
| 30 virtual void OnExtensionPrefValueMapDestruction(); |
| 29 | 31 |
| 30 bool initialization_complete_; | 32 ExtensionPrefValueMap* extension_pref_value_map_; // Weak pointer. |
| 33 bool incognito_pref_store_; |
| 31 | 34 |
| 32 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefStore); | 35 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefStore); |
| 33 }; | 36 }; |
| 34 | 37 |
| 35 | |
| 36 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_STORE_H_ | 38 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_STORE_H_ |
| OLD | NEW |