| Index: chrome/browser/prefs/pref_value_store.h
|
| diff --git a/chrome/browser/prefs/pref_value_store.h b/chrome/browser/prefs/pref_value_store.h
|
| index fec16b4315b7351f2d2039d61cfbb47ef7c348d4..78edf179ba211df6df6e55c098fe9921bb3d2690 100644
|
| --- a/chrome/browser/prefs/pref_value_store.h
|
| +++ b/chrome/browser/prefs/pref_value_store.h
|
| @@ -14,7 +14,6 @@
|
| #include "base/callback.h"
|
| #include "base/gtest_prod_util.h"
|
| #include "base/ref_counted.h"
|
| -#include "base/scoped_ptr.h"
|
| #include "base/values.h"
|
| #include "chrome/browser/browser_thread.h"
|
| #include "chrome/common/notification_observer.h"
|
| @@ -66,37 +65,29 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore>,
|
| // TODO(mnissler, danno): Refactor the pref store interface and refresh logic
|
| // so refreshes can be handled by the pref store itself without swapping
|
| // stores. This way we can get rid of the profile pointer here.
|
| - PrefValueStore(PrefStore* managed_platform_prefs,
|
| - PrefStore* device_management_prefs,
|
| - PrefStore* extension_prefs,
|
| - PrefStore* command_line_prefs,
|
| - PrefStore* user_prefs,
|
| - PrefStore* recommended_prefs,
|
| - PrefStore* default_prefs,
|
| + PrefValueStore(scoped_refptr<PrefStore> managed_platform_prefs,
|
| + scoped_refptr<PrefStore> device_management_prefs,
|
| + scoped_refptr<PrefStore> extension_prefs,
|
| + scoped_refptr<PrefStore> command_line_prefs,
|
| + scoped_refptr<PrefStore> user_prefs,
|
| + scoped_refptr<PrefStore> recommended_prefs,
|
| + scoped_refptr<PrefStore> default_prefs,
|
| PrefNotifier* pref_notifier,
|
| Profile* profile);
|
| virtual ~PrefValueStore();
|
|
|
| - // Gets the value for the given preference name that has a valid value type;
|
| - // that is, the same type the preference was registered with, or NULL for
|
| - // default values of Dictionaries and Lists. Returns true if a valid value
|
| - // was found in any of the available PrefStores. Most callers should use
|
| - // Preference::GetValue() instead of calling this method directly.
|
| - bool GetValue(const std::string& name, Value** out_value) const;
|
| + // Derives a new PrefValueStore that overrides the specified attributes.
|
| + PrefValueStore* Derive(scoped_refptr<PrefStore> extension_prefs,
|
| + scoped_refptr<PrefStore> user_prefs,
|
| + PrefNotifier* pref_notifier);
|
|
|
| - // Adds a preference to the mapping of names to types.
|
| - void RegisterPreferenceType(const std::string& name, Value::ValueType type);
|
| -
|
| - // Gets the registered value type for the given preference name. Returns
|
| - // Value::TYPE_NULL if the preference has never been registered.
|
| - Value::ValueType GetRegisteredType(const std::string& name) const;
|
| -
|
| - // Returns true if the PrefValueStore contains the given preference (i.e.,
|
| - // it's been registered), and a value with the correct type has been actively
|
| - // set in some pref store. The application default specified when the pref was
|
| - // registered does not count as an "actively set" value, but another pref
|
| - // store setting a value that happens to be equal to the default does.
|
| - bool HasPrefPath(const char* name) const;
|
| + // Gets the value for the given preference name that has the specified value
|
| + // type. Returns true if a valid value was found in any of the available
|
| + // PrefStores. Most callers should use Preference::GetValue() instead of
|
| + // calling this method directly.
|
| + bool GetValue(const std::string& name,
|
| + Value::ValueType type,
|
| + Value** out_value) const;
|
|
|
| // These methods return true if a preference with the given name is in the
|
| // indicated pref store, even if that value is currently being overridden by
|
| @@ -154,11 +145,11 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore>,
|
|
|
| // Takes ownership of |pref_store|.
|
| void Initialize(PrefValueStore* store,
|
| - PrefStore* pref_store,
|
| + scoped_refptr<PrefStore> pref_store,
|
| PrefStoreType type);
|
|
|
| - PrefStore* store() { return pref_store_.get(); }
|
| - const PrefStore* store() const { return pref_store_.get(); }
|
| + scoped_refptr<PrefStore> store() { return pref_store_; }
|
| + const scoped_refptr<PrefStore> store() const { return pref_store_; }
|
|
|
| private:
|
| // PrefStore::Observer implementation.
|
| @@ -169,7 +160,7 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore>,
|
| PrefValueStore* pref_value_store_;
|
|
|
| // The PrefStore managed by this keeper.
|
| - scoped_ptr<PrefStore> pref_store_;
|
| + scoped_refptr<PrefStore> pref_store_;
|
|
|
| // Type of the pref store.
|
| PrefStoreType type_;
|
| @@ -186,12 +177,6 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore>,
|
| FRIEND_TEST_ALL_PREFIXES(PrefValueStorePolicyRefreshTest,
|
| TestConcurrentPolicyRefresh);
|
|
|
| - // Returns true if the actual type is a valid type for the expected type when
|
| - // found in the given store.
|
| - static bool IsValidType(Value::ValueType expected,
|
| - Value::ValueType actual,
|
| - PrefStoreType store);
|
| -
|
| // Returns true if the preference with the given name has a value in the
|
| // given PrefStoreType, of the same value type as the preference was
|
| // registered with.
|
| @@ -232,17 +217,23 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore>,
|
| // that initiated the policy refresh. RefreshPolicyPrefsCompletion takes
|
| // ownership of the |callback| object.
|
| void RefreshPolicyPrefsCompletion(
|
| - policy::ConfigurationPolicyPrefStore* new_managed_platform_pref_store,
|
| - policy::ConfigurationPolicyPrefStore* new_device_management_pref_store,
|
| - policy::ConfigurationPolicyPrefStore* new_recommended_pref_store);
|
| + scoped_refptr<policy::ConfigurationPolicyPrefStore>
|
| + new_managed_platform_pref_store,
|
| + scoped_refptr<policy::ConfigurationPolicyPrefStore>
|
| + new_device_management_pref_store,
|
| + scoped_refptr<policy::ConfigurationPolicyPrefStore>
|
| + new_recommended_pref_store);
|
|
|
| // Called during policy refresh to do the ReadPrefs on the FILE thread.
|
| // RefreshPolicyPrefsOnFileThread takes ownership of the |callback| object.
|
| void RefreshPolicyPrefsOnFileThread(
|
| BrowserThread::ID calling_thread_id,
|
| - policy::ConfigurationPolicyPrefStore* new_managed_platform_pref_store,
|
| - policy::ConfigurationPolicyPrefStore* new_device_management_pref_store,
|
| - policy::ConfigurationPolicyPrefStore* new_recommended_pref_store);
|
| + scoped_refptr<policy::ConfigurationPolicyPrefStore>
|
| + new_managed_platform_pref_store,
|
| + scoped_refptr<policy::ConfigurationPolicyPrefStore>
|
| + new_device_management_pref_store,
|
| + scoped_refptr<policy::ConfigurationPolicyPrefStore>
|
| + new_recommended_pref_store);
|
|
|
| // NotificationObserver methods:
|
| virtual void Observe(NotificationType type,
|
| @@ -258,7 +249,7 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore>,
|
|
|
| // Initializes a pref store keeper. Sets up a PrefStoreKeeper that will take
|
| // ownership of the passed |pref_store|.
|
| - void InitPrefStore(PrefStoreType type, PrefStore* pref_store);
|
| + void InitPrefStore(PrefStoreType type, scoped_refptr<PrefStore> pref_store);
|
|
|
| // Checks whether initialization is completed and tells the notifier if that
|
| // is the case.
|
| @@ -266,10 +257,10 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore>,
|
|
|
| // Get the PrefStore pointer for the given type. May return NULL if there is
|
| // no PrefStore for that type.
|
| - PrefStore* GetPrefStore(PrefStoreType type) {
|
| + scoped_refptr<PrefStore> GetPrefStore(PrefStoreType type) {
|
| return pref_stores_[type].store();
|
| }
|
| - const PrefStore* GetPrefStore(PrefStoreType type) const {
|
| + const scoped_refptr<PrefStore> GetPrefStore(PrefStoreType type) const {
|
| return pref_stores_[type].store();
|
| }
|
|
|
| @@ -281,9 +272,6 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore>,
|
| // corresponding PrefService.
|
| PrefNotifier* pref_notifier_;
|
|
|
| - // A mapping of preference names to their registered types.
|
| - PrefTypeMap pref_types_;
|
| -
|
| // The associated profile, in case this value store is associated with a
|
| // profile pref service. Used for recreating the device management pref store
|
| // upon policy refresh.
|
|
|