Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2711)

Unified Diff: chrome/browser/extensions/extension_pref_store.h

Issue 4438001: First part to fix Bug 50726 "Save extension list and "winning" prefs from extensions" (Closed) Base URL: http://git.chromium.org/git/chromium.git/@trunk
Patch Set: whitespaces Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_pref_store.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_pref_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698