Index: chrome/browser/extensions/extension_pref_store.h |
diff --git a/chrome/browser/extensions/extension_pref_store.h b/chrome/browser/extensions/extension_pref_store.h |
index f1767589a9aee4a67b2dec4814c4e19716e3803f..67c7335c05af5922c705254dd628bee72e0011e5 100644 |
--- a/chrome/browser/extensions/extension_pref_store.h |
+++ b/chrome/browser/extensions/extension_pref_store.h |
@@ -30,6 +30,15 @@ class Value; |
// proxy settings. A stack of relevant extensions is stored in order of |
// their addition to this PrefStore. For each preference, the last-added |
// enabled extension that tries to set it overrules any others. |
+// |
+// TODO(battre): The ExtensionPrefStore has an issue if it serves for storing |
+// extension preferences in the local-state (shared among all profiles on a |
+// machine). In this context, there is no meaningful definition of a precedence |
+// order as the same extensions can be installed in different profiles. |
+// One instance would override the preferences of another instance. Also it is |
+// unclear how settings should be removed in this case. For this reason we |
+// (pamg, battre) decided to not support the ExtensionPrefStore for local-state. |
+// This needs to be enforced by the code. |
class ExtensionPrefStore : public PrefStore, |
public NotificationObserver { |
public: |
@@ -72,13 +81,21 @@ class ExtensionPrefStore : public PrefStore, |
// subclasses for unit-testing. |
virtual PrefService* GetPrefService(); |
+ // The following functions delegate to |
+ // profile_->GetExtensionsService()->extension_prefs() |
+ // and are defined here only for injection in case of unit tests. |
+ virtual void PersistExtensionPrecedences( |
+ const std::vector<std::string>& precedence); |
+ virtual void GetExtensionPrecedences( |
+ std::vector<std::string>* precedence) const; |
+ |
private: |
// Associates an extension with the prefs it sets. Owns the pref values. |
struct ExtensionPrefs { |
- ExtensionPrefs(const Extension* extension, PrefValueMap* values); |
+ ExtensionPrefs(const std::string& extension_id, PrefValueMap* values); |
~ExtensionPrefs(); |
- const Extension* extension; |
+ std::string extension_id; |
PrefValueMap* pref_values; |
}; |
@@ -102,6 +119,23 @@ class ExtensionPrefStore : public PrefStore, |
const NotificationSource& source, |
const NotificationDetails& details); |
+ // The following functions update the precedence list maintained by |
+ // ExtensionPrefs. They are not responsible for updating the |prefs_| cache. |
+ // Therefore, they should not be called outside of InstallExtensionPref and |
+ // UninstallExtension. |
+ |
+ // Appends |extension_id| to the end of the precedence list. This makes |
+ // |extension_id| the extension that overwrites preferences of all other |
+ // extensions. |
+ void AddPrecedence(const std::string& extension_id); |
+ |
+ // Removes |extension_id| from the precedence list. |
+ void RemovePrecedence(const std::string& extension_id); |
+ |
+ // Initializes the extension_stack_ with empty dictionaries for all |
+ // extensions registered in the precedence list. |
+ void LazyInit(); |
+ |
// A cache of the highest-priority values for each preference that any |
// extension is controlling, for quick read access. Owns the stored values. |
scoped_ptr<DictionaryValue> prefs_; |