Chromium Code Reviews| Index: chrome/browser/extensions/extension_prefs.h |
| diff --git a/chrome/browser/extensions/extension_prefs.h b/chrome/browser/extensions/extension_prefs.h |
| index 298d03ce849aed1c541f6688858ec667586392df..56c7deb0df24d324e85ca4385c5911054fb9dd16 100644 |
| --- a/chrome/browser/extensions/extension_prefs.h |
| +++ b/chrome/browser/extensions/extension_prefs.h |
| @@ -19,6 +19,16 @@ |
| // Class for managing global and per-extension preferences. |
| // This class is instantiated by ExtensionsService, so it should be accessed |
| // from there. |
| +// |
| +// This class distinguishes the following kinds of preferences: |
| +// - global preferences: |
| +// not associated with extensions |
| +// - per-extension preferences: |
| +// meta-preferences describing properties of the extension like |
| +// installation time, whether the extension is enabled, etc. |
| +// - extension controlled preferences: |
| +// global preferences that an individual extension wants to set |
|
Mattias Nissler (ping if slow)
2010/11/18 16:30:33
Maybe not that these are arbitrary preferences (fr
battre (please use the other)
2010/11/18 16:47:33
Done.
|
| +// |
|
Mattias Nissler (ping if slow)
2010/11/18 16:30:33
Remove newline.
battre (please use the other)
2010/11/18 16:47:33
Done.
|
| class ExtensionPrefs { |
| public: |
| // Key name for a preference that keeps track of per-extension settings. This |
| @@ -73,7 +83,7 @@ class ExtensionPrefs { |
| bool external_uninstall); |
| // Returns the state (enabled/disabled) of the given extension. |
| - Extension::State GetExtensionState(const std::string& extension_id); |
| + Extension::State GetExtensionState(const std::string& extension_id) const; |
| // Called to change the extension's state when it is enabled/disabled. |
| void SetExtensionState(const Extension* extension, Extension::State); |
| @@ -194,11 +204,22 @@ class ExtensionPrefs { |
| const std::string& data); |
| std::string GetUpdateUrlData(const std::string& extension_id); |
| + // Sets a preference value that is controlled by the extension. In other |
| + // words, this is not a pref value *about* the extension but something |
| + // global the extension wants to override. |
| + void SetExtensionControlledPref(const std::string& extension_id, |
| + const std::string& pref_key, |
| + Value* value); |
| + |
| static void RegisterUserPrefs(PrefService* prefs); |
| // The underlying PrefService. |
| PrefService* pref_service() const { return prefs_; } |
| + protected: |
| + // For unit testing |
|
Mattias Nissler (ping if slow)
2010/11/18 16:30:33
Missing period.
And I think this deserves a more
battre (please use the other)
2010/11/18 16:47:33
Done.
|
| + base::Time GetCurrentTime() const; |
| + |
| private: |
| // Converts absolute paths in the pref to paths relative to the |
| // install_directory_. |
| @@ -240,6 +261,11 @@ class ExtensionPrefs { |
| // Same as above, but returns NULL if it doesn't exist. |
| DictionaryValue* GetExtensionPref(const std::string& id) const; |
| + // Returns the dictionary of preferences controlled by the specified extension |
| + // or NULL if unknown. All entries in the dictionary contain non-expanded |
| + // paths. |
| + DictionaryValue* GetExtensionControlledPrefs(const std::string& id) const; |
| + |
| // Serializes the data and schedules a persistent save via the |PrefService|. |
| // Additionally fires a PREF_CHANGED notification with the top-level |
| // |kExtensionsPref| path set. |
| @@ -257,6 +283,28 @@ class ExtensionPrefs { |
| base::Time LastPingDayImpl(const DictionaryValue* dictionary) const; |
| void SetLastPingDayImpl(const base::Time& time, DictionaryValue* dictionary); |
| + // Helper method to acquire the installation time of an extension |
| + base::Time GetInstallTime(const DictionaryValue* extension) const; |
|
Mattias Nissler (ping if slow)
2010/11/18 16:30:33
Why is that parameter a DictionaryValue*? I'd expe
battre (please use the other)
2010/11/18 16:47:33
It is a simple helper method and we need to compar
|
| + |
| + // Installs the persistent extension preferences into prefs_'s extension |
|
Mattias Nissler (ping if slow)
2010/11/18 16:30:33
|pref_|'s
battre (please use the other)
2010/11/18 16:47:33
Done.
|
| + // pref store. |
| + void InstallPersistedExtensionControlledPrefs(); |
| + |
| + // Returns the extension controlled preference value of the extension that was |
| + // installed most recently. |
| + const Value* WinningExtensionControlledPrefValue(const std::string& key) |
|
Mattias Nissler (ping if slow)
2010/11/18 16:30:33
Again, why a Value* and not an extension ID?
battre (please use the other)
2010/11/18 16:47:33
this time it is "...Controlle*d*PrefValue", not "C
|
| + const; |
| + |
| + // Store the WinningExtensionControlledPrefValue in the PrefValueStore's |
|
Mattias Nissler (ping if slow)
2010/11/18 16:30:33
what value? ;) Maybe say it in prose :)
battre (please use the other)
2010/11/18 16:47:33
Done.
|
| + // extension pref store and send notifications to provider in case of |
| + // a changed value. |
| + void UpdateWinningPref(const std::string& pref_key); |
| + |
| + // Retrieves a list of preference keys that the specified extension |
| + // intents to manage. |
| + void GetExtensionControlledPrefKeys(const std::string& extension_id, |
| + std::vector<std::string> *out) const; |
| + |
| // The pref service specific to this set of extension prefs. |
| PrefService* prefs_; |