| Index: chrome/browser/prefs/pref_value_store.cc
|
| diff --git a/chrome/browser/prefs/pref_value_store.cc b/chrome/browser/prefs/pref_value_store.cc
|
| index 0fd3449ad2b407f23ab902e96f9129c89830bd38..f67927ea48c7e41a513f31725ef11f7ef0f507b6 100644
|
| --- a/chrome/browser/prefs/pref_value_store.cc
|
| +++ b/chrome/browser/prefs/pref_value_store.cc
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| @@ -24,7 +24,7 @@ void PrefValueStore::PrefStoreKeeper::Initialize(
|
| pref_store_->RemoveObserver(this);
|
| type_ = type;
|
| pref_value_store_ = store;
|
| - pref_store_.reset(pref_store);
|
| + pref_store_ = pref_store;
|
| if (pref_store_.get())
|
| pref_store_->AddObserver(this);
|
| }
|
| @@ -61,48 +61,31 @@ PrefValueStore::PrefValueStore(PrefStore* managed_platform_prefs,
|
| PrefValueStore::~PrefValueStore() {}
|
|
|
| bool PrefValueStore::GetValue(const std::string& name,
|
| + Value::ValueType type,
|
| Value** out_value) const {
|
| + *out_value = NULL;
|
| // Check the |PrefStore|s in order of their priority from highest to lowest
|
| // to find the value of the preference described by the given preference name.
|
| for (size_t i = 0; i <= PREF_STORE_TYPE_MAX; ++i) {
|
| if (GetValueFromStore(name.c_str(), static_cast<PrefStoreType>(i),
|
| - out_value))
|
| + out_value)) {
|
| + if (!(*out_value)->IsType(type)) {
|
| + LOG(WARNING) << "Expected type for " << name << " is " << type
|
| + << " but got " << (*out_value)->GetType()
|
| + << " in store " << i;
|
| + continue;
|
| + }
|
| return true;
|
| + }
|
| }
|
| return false;
|
| }
|
|
|
| -void PrefValueStore::RegisterPreferenceType(const std::string& name,
|
| - Value::ValueType type) {
|
| - pref_types_[name] = type;
|
| -}
|
| -
|
| -Value::ValueType PrefValueStore::GetRegisteredType(
|
| - const std::string& name) const {
|
| - PrefTypeMap::const_iterator found = pref_types_.find(name);
|
| - if (found == pref_types_.end())
|
| - return Value::TYPE_NULL;
|
| - return found->second;
|
| -}
|
| -
|
| -bool PrefValueStore::HasPrefPath(const char* path) const {
|
| - Value* tmp_value = NULL;
|
| - const std::string name(path);
|
| - bool rv = GetValue(name, &tmp_value);
|
| - // Merely registering a pref doesn't count as "having" it: we require a
|
| - // non-default value set.
|
| - return rv && !PrefValueFromDefaultStore(path);
|
| -}
|
| -
|
| void PrefValueStore::NotifyPrefChanged(
|
| const char* path,
|
| PrefValueStore::PrefStoreType new_store) {
|
| DCHECK(new_store != INVALID_STORE);
|
|
|
| - // If this pref is not registered, just discard the notification.
|
| - if (!pref_types_.count(path))
|
| - return;
|
| -
|
| bool changed = true;
|
| // Replying that the pref has changed in case the new store is invalid may
|
| // cause problems, but it's the safer choice.
|
| @@ -155,24 +138,6 @@ bool PrefValueStore::PrefValueUserModifiable(const char* name) const {
|
| effective_store == INVALID_STORE;
|
| }
|
|
|
| -// Returns true if the actual value is a valid type for the expected type when
|
| -// found in the given store.
|
| -bool PrefValueStore::IsValidType(Value::ValueType expected,
|
| - Value::ValueType actual,
|
| - PrefValueStore::PrefStoreType store) {
|
| - if (expected == actual)
|
| - return true;
|
| -
|
| - // Dictionaries and lists are allowed to hold TYPE_NULL values too, but only
|
| - // in the default pref store.
|
| - if (store == DEFAULT_STORE &&
|
| - actual == Value::TYPE_NULL &&
|
| - (expected == Value::TYPE_DICTIONARY || expected == Value::TYPE_LIST)) {
|
| - return true;
|
| - }
|
| - return false;
|
| -}
|
| -
|
| bool PrefValueStore::PrefValueInStore(
|
| const char* name,
|
| PrefValueStore::PrefStoreType store) const {
|
| @@ -224,12 +189,7 @@ bool PrefValueStore::GetValueFromStore(const char* name,
|
| }
|
| // Fall through...
|
| case PrefStore::READ_OK:
|
| - if (IsValidType(GetRegisteredType(name),
|
| - (*out_value)->GetType(),
|
| - store_type)) {
|
| - return true;
|
| - }
|
| - break;
|
| + return true;
|
| case PrefStore::READ_NO_VALUE:
|
| break;
|
| }
|
| @@ -257,7 +217,8 @@ void PrefValueStore::InitPrefStore(PrefValueStore::PrefStoreType type,
|
|
|
| void PrefValueStore::CheckInitializationCompleted() {
|
| for (size_t i = 0; i <= PREF_STORE_TYPE_MAX; ++i) {
|
| - PrefStore* store = GetPrefStore(static_cast<PrefStoreType>(i));
|
| + scoped_refptr<PrefStore> store =
|
| + GetPrefStore(static_cast<PrefStoreType>(i));
|
| if (store && !store->IsInitializationComplete())
|
| return;
|
| }
|
|
|