| 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..230cdf80dc0a104608d1242889c660227a52d11c 100644
|
| --- a/chrome/browser/extensions/extension_pref_store.h
|
| +++ b/chrome/browser/extensions/extension_pref_store.h
|
| @@ -6,117 +6,19 @@
|
| #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_STORE_H_
|
| #pragma once
|
|
|
| -#include <list>
|
| -#include <map>
|
| -#include <string>
|
| -#include <utility>
|
| -#include <vector>
|
| +#include "chrome/browser/prefs/in_memory_pref_store.h"
|
|
|
| -#include "base/basictypes.h"
|
| -#include "base/scoped_ptr.h"
|
| -#include "base/stl_util-inl.h"
|
| -#include "chrome/browser/prefs/pref_notifier.h"
|
| -#include "chrome/common/notification_observer.h"
|
| -#include "chrome/common/notification_registrar.h"
|
| -#include "chrome/common/pref_store.h"
|
| -
|
| -class DictionaryValue;
|
| -class Extension;
|
| -class PrefService;
|
| class Profile;
|
| -class Value;
|
|
|
| -// This PrefStore keeps track of preferences set by extensions: for example,
|
| -// 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.
|
| -class ExtensionPrefStore : public PrefStore,
|
| - public NotificationObserver {
|
| +// This InMemoryPrefStore registers and unregisters at the profile at
|
| +// construction and destruction time.
|
| +class ExtensionPrefStore : public InMemoryPrefStore {
|
| public:
|
| - // Maps preference paths to their values.
|
| - typedef std::map<const char*, Value*> PrefValueMap;
|
| -
|
| - // The type passed as Details for an EXTENSION_PREF_CHANGED notification.
|
| - // The nested pairs are <extension, <pref_path, pref_value> >. This is here,
|
| - // rather than in (say) notification_type.h, to keep the dependency on
|
| - // std::pair out of the many places that include notification_type.h.
|
| - typedef std::pair<const Extension*, std::pair<const char*, Value*> >
|
| - ExtensionPrefDetails;
|
| -
|
| - ExtensionPrefStore(Profile* profile, PrefNotifier::PrefStoreType type);
|
| + explicit ExtensionPrefStore(Profile* profile);
|
| virtual ~ExtensionPrefStore();
|
|
|
| - // Begins tracking the preference and value an extension wishes to set. This
|
| - // must be called each time an extension API tries to set a preference.
|
| - // The ExtensionPrefStore will take ownership of the |pref_value|.
|
| - virtual void InstallExtensionPref(const Extension* extension,
|
| - const char* pref_path,
|
| - Value* pref_value);
|
| -
|
| - // Removes an extension and all its preference settings from this PrefStore.
|
| - // This must be called when an extension is uninstalled or disabled.
|
| - virtual void UninstallExtension(const Extension* extension);
|
| -
|
| - // PrefStore methods:
|
| - virtual DictionaryValue* prefs() const { return prefs_.get(); }
|
| -
|
| - virtual PrefReadError ReadPrefs() { return PREF_READ_ERROR_NONE; }
|
| -
|
| - protected:
|
| - // Returns a vector of the extension IDs in the extension_stack_.
|
| - // This should only be accessed by subclasses for unit-testing.
|
| - void GetExtensionIDs(std::vector<std::string>* result);
|
| -
|
| - // Returns the applicable pref service from the profile (if we have one) or
|
| - // the browser's local state. This should only be accessed or overridden by
|
| - // subclasses for unit-testing.
|
| - virtual PrefService* GetPrefService();
|
| -
|
| private:
|
| - // Associates an extension with the prefs it sets. Owns the pref values.
|
| - struct ExtensionPrefs {
|
| - ExtensionPrefs(const Extension* extension, PrefValueMap* values);
|
| - ~ExtensionPrefs();
|
| -
|
| - const Extension* extension;
|
| - PrefValueMap* pref_values;
|
| - };
|
| -
|
| - // A pseudo-stack of extensions and their preferences. Extensions are always
|
| - // added to the head, but may be removed from the middle.
|
| - typedef std::list<ExtensionPrefs*> ExtensionStack;
|
| -
|
| - // Applies the highest-priority extension's setting for the given preference
|
| - // path to the |prefs_| store, or clears the setting there if no extensions
|
| - // wish to control it.
|
| - void UpdateOnePref(const char* path);
|
| -
|
| - // Updates each preference in the key set of the |pref_values| map.
|
| - void UpdatePrefs(const PrefValueMap* pref_values);
|
| -
|
| - // Registers this as an observer for relevant notifications.
|
| - void RegisterObservers();
|
| -
|
| - // Responds to observed notifications.
|
| - void Observe(NotificationType type,
|
| - const NotificationSource& source,
|
| - const NotificationDetails& details);
|
| -
|
| - // 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_;
|
| -
|
| - ExtensionStack extension_stack_;
|
| -
|
| - NotificationRegistrar notification_registrar_;
|
| -
|
| - // Weak reference to the profile whose extensions we're interested in. May be
|
| - // NULL (for the local-state preferences), in which case we watch all
|
| - // extensions.
|
| - Profile* profile_;
|
| -
|
| - // My PrefStore type, assigned by the PrefValueStore.
|
| - PrefNotifier::PrefStoreType type_;
|
| + Profile* profile_; // may be NULL in case of LocalState.
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ExtensionPrefStore);
|
| };
|
|
|