diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/pref_service.cc | 919 | ||||
-rw-r--r-- | chrome/browser/pref_service.h | 278 | ||||
-rw-r--r-- | chrome/browser/prefs/pref_service.cc | 28 | ||||
-rw-r--r-- | chrome/browser/prefs/pref_service.h | 6 | ||||
-rw-r--r-- | chrome/browser/prefs/pref_value_store.cc | 10 | ||||
-rw-r--r-- | chrome/browser/prefs/pref_value_store.h | 9 |
6 files changed, 51 insertions, 1199 deletions
diff --git a/chrome/browser/pref_service.cc b/chrome/browser/pref_service.cc deleted file mode 100644 index 46c4a42..0000000 --- a/chrome/browser/pref_service.cc +++ /dev/null @@ -1,919 +0,0 @@ -// Copyright (c) 2010 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. - -#include "chrome/browser/pref_service.h" - -#include <algorithm> -#include <string> - -#ifndef ANDROID -// FIXME: Do we need this on Android? -#include "app/l10n_util.h" -#endif -#ifndef ANDROID -#include "base/command_line.h" -#endif -#include "base/histogram.h" -#include "base/logging.h" -#include "base/message_loop.h" -#include "base/path_service.h" -#include "base/stl_util-inl.h" -#include "base/string_util.h" -#include "base/sys_string_conversions.h" -#include "base/utf_string_conversions.h" -#include "build/build_config.h" -#ifndef ANDROID -#include "chrome/browser/chrome_thread.h" -#endif - -#if defined(OS_WIN) -#include "chrome/browser/configuration_policy_provider_win.h" -#elif defined(OS_MACOSX) -#include "chrome/browser/configuration_policy_provider_mac.h" -#elif defined(OS_POSIX) -#include "chrome/browser/config_dir_policy_provider.h" -#endif -#include "chrome/browser/dummy_configuration_policy_provider.h" - -#include "chrome/browser/command_line_pref_store.h" -#include "chrome/browser/configuration_policy_pref_store.h" -#include "chrome/browser/extensions/extension_pref_store.h" -#include "chrome/common/chrome_paths.h" -#include "chrome/common/json_pref_store.h" -#ifndef ANDROID -// Notifications do not compile on Android and are the cause -// of most of the ANDROID guards in this file. -#include "chrome/common/notification_service.h" -#include "grit/chromium_strings.h" -#include "grit/generated_resources.h" -#endif - -namespace { - -// A helper function for RegisterLocalized*Pref that creates a Value* based on -// the string value in the locale dll. Because we control the values in a -// locale dll, this should always return a Value of the appropriate type. -Value* CreateLocaleDefaultValue(Value::ValueType type, int message_id) { -#ifndef ANDROID - std::wstring resource_string = l10n_util::GetString(message_id); - DCHECK(!resource_string.empty()); - switch (type) { - case Value::TYPE_BOOLEAN: { - if (L"true" == resource_string) - return Value::CreateBooleanValue(true); - if (L"false" == resource_string) - return Value::CreateBooleanValue(false); - break; - } - - case Value::TYPE_INTEGER: { - return Value::CreateIntegerValue( - StringToInt(WideToUTF16Hack(resource_string))); - break; - } - - case Value::TYPE_REAL: { - return Value::CreateRealValue( - StringToDouble(WideToUTF16Hack(resource_string))); - break; - } - - case Value::TYPE_STRING: { - return Value::CreateStringValue(resource_string); - break; - } - - default: { - NOTREACHED() << - "list and dictionary types can not have default locale values"; - } - } -#endif - NOTREACHED(); - return Value::CreateNullValue(); -} - -// Forwards a notification after a PostMessage so that we can wait for the -// MessageLoop to run. -void NotifyReadError(PrefService* pref, int message_id) { -#ifndef ANDROID - Source<PrefService> source(pref); - NotificationService::current()->Notify(NotificationType::PROFILE_ERROR, - source, Details<int>(&message_id)); -#endif -} - -} // namespace - -// static -PrefService* PrefService::CreatePrefService(const FilePath& pref_filename) { - PrefStore* managed_prefs = NULL; - // TODO(pamg): Reinstate extension pref store after Mstone6 branch, when its - // memory leaks are fixed and any extension API is using it. - // ExtensionPrefStore* extension_prefs = new ExtensionPrefStore(NULL); - ExtensionPrefStore* extension_prefs = NULL; -#ifdef ANDROID - CommandLinePrefStore* command_line_prefs = NULL; -#else - CommandLinePrefStore* command_line_prefs = new CommandLinePrefStore( - CommandLine::ForCurrentProcess()); -#endif - -#ifdef ANDROID - PrefStore* local_prefs = NULL; -#else - PrefStore* local_prefs = new JsonPrefStore( - pref_filename, - ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)); -#endif - PrefStore* recommended_prefs = NULL; - - ConfigurationPolicyProvider* managed_prefs_provider = NULL; - ConfigurationPolicyProvider* recommended_prefs_provider = NULL; - -#if defined(OS_WIN) - managed_prefs_provider = new ConfigurationPolicyProviderWin(); - recommended_prefs_provider = new DummyConfigurationPolicyProvider(); -#elif defined(OS_MACOSX) - managed_prefs_provider = new ConfigurationPolicyProviderMac(); - recommended_prefs_provider = new DummyConfigurationPolicyProvider(); -#elif defined(OS_POSIX) - FilePath config_dir_path; - if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { - managed_prefs_provider = new ConfigDirPolicyProvider( - config_dir_path.Append(FILE_PATH_LITERAL("managed"))); - recommended_prefs_provider = new ConfigDirPolicyProvider( - config_dir_path.Append(FILE_PATH_LITERAL("recommended"))); - } else { - managed_prefs_provider = new DummyConfigurationPolicyProvider(); - recommended_prefs_provider = new DummyConfigurationPolicyProvider(); - } -#endif - -#ifdef ANDROID - managed_prefs = NULL; - recommended_prefs = NULL; -#else - // The ConfigurationPolicyPrefStore takes ownership of the passed - // |provider|. - managed_prefs = new ConfigurationPolicyPrefStore( - CommandLine::ForCurrentProcess(), - managed_prefs_provider); - recommended_prefs = new ConfigurationPolicyPrefStore( - CommandLine::ForCurrentProcess(), - recommended_prefs_provider); -#endif - - // The PrefValueStore takes ownership of the PrefStores. - PrefValueStore* value_store = new PrefValueStore( - managed_prefs, - extension_prefs, - command_line_prefs, - local_prefs, - recommended_prefs); - - PrefService* pref_service = new PrefService(value_store); - // TODO(pamg): Uncomment when ExtensionPrefStore is reinstated. - // extension_prefs->SetPrefService(pref_service); - - return pref_service; -} - -// static -PrefService* PrefService::CreateUserPrefService( - const FilePath& pref_filename) { - PrefValueStore* value_store = new PrefValueStore( - NULL, /* no enforced prefs */ - NULL, /* no extension prefs */ - NULL, /* no command-line prefs */ -#ifdef ANDROID - NULL, /* no user prefs */ -#else - new JsonPrefStore( - pref_filename, - ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)), - /* user prefs */ -#endif - NULL /* no advised prefs */); - return new PrefService(value_store); -} - -PrefService::PrefService(PrefValueStore* pref_value_store) - : pref_value_store_(pref_value_store) { - InitFromStorage(); -} - -PrefService::~PrefService() { - DCHECK(CalledOnValidThread()); - - // Verify that there are no pref observers when we shut down. - for (PrefObserverMap::iterator it = pref_observers_.begin(); - it != pref_observers_.end(); ++it) { - NotificationObserverList::Iterator obs_iterator(*(it->second)); - if (obs_iterator.GetNext()) { - LOG(WARNING) << "pref observer found at shutdown " << it->first; - } - } - - STLDeleteContainerPointers(prefs_.begin(), prefs_.end()); - prefs_.clear(); - STLDeleteContainerPairSecondPointers(pref_observers_.begin(), - pref_observers_.end()); - pref_observers_.clear(); -} - -void PrefService::InitFromStorage() { -#ifdef ANDROID - // Don't use pref storage on Android. - // TODO: see if we can remove this entire class. -#else - PrefStore::PrefReadError error = LoadPersistentPrefs(); - if (error == PrefStore::PREF_READ_ERROR_NONE) - return; - // Failing to load prefs on startup is a bad thing(TM). See bug 38352 for - // an example problem that this can cause. - // Do some diagnosis and try to avoid losing data. - int message_id = 0; - if (error <= PrefStore::PREF_READ_ERROR_JSON_TYPE) { - message_id = IDS_PREFERENCES_CORRUPT_ERROR; - } else if (error != PrefStore::PREF_READ_ERROR_NO_FILE) { - message_id = IDS_PREFERENCES_UNREADABLE_ERROR; - } - if (message_id) { - ChromeThread::PostTask(ChromeThread::UI, FROM_HERE, - NewRunnableFunction(&NotifyReadError, this, message_id)); - } - UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error, 20); -#endif -} - -bool PrefService::ReloadPersistentPrefs() { - return (LoadPersistentPrefs() == PrefStore::PREF_READ_ERROR_NONE); -} - -PrefStore::PrefReadError PrefService::LoadPersistentPrefs() { - DCHECK(CalledOnValidThread()); - - PrefStore::PrefReadError pref_error = pref_value_store_->ReadPrefs(); - - for (PreferenceSet::iterator it = prefs_.begin(); - it != prefs_.end(); ++it) { - (*it)->pref_value_store_ = pref_value_store_.get(); - } - - return pref_error; -} - -bool PrefService::SavePersistentPrefs() { - DCHECK(CalledOnValidThread()); - - return pref_value_store_->WritePrefs(); -} - -void PrefService::ScheduleSavePersistentPrefs() { - DCHECK(CalledOnValidThread()); - - pref_value_store_->ScheduleWritePrefs(); -} - -void PrefService::RegisterBooleanPref(const wchar_t* path, - bool default_value) { - Preference* pref = new Preference(pref_value_store_.get(), path, - Value::CreateBooleanValue(default_value)); - RegisterPreference(pref); -} - -void PrefService::RegisterIntegerPref(const wchar_t* path, - int default_value) { - Preference* pref = new Preference(pref_value_store_.get(), path, - Value::CreateIntegerValue(default_value)); - RegisterPreference(pref); -} - -void PrefService::RegisterRealPref(const wchar_t* path, - double default_value) { - Preference* pref = new Preference(pref_value_store_.get(), path, - Value::CreateRealValue(default_value)); - RegisterPreference(pref); -} - -void PrefService::RegisterStringPref(const wchar_t* path, - const std::string& default_value) { - Preference* pref = new Preference(pref_value_store_.get(), path, - Value::CreateStringValue(default_value)); - RegisterPreference(pref); -} - -void PrefService::RegisterFilePathPref(const wchar_t* path, - const FilePath& default_value) { - Preference* pref = new Preference(pref_value_store_.get(), path, - Value::CreateStringValue(default_value.value())); - RegisterPreference(pref); -} - -void PrefService::RegisterListPref(const wchar_t* path) { - Preference* pref = new Preference(pref_value_store_.get(), path, - new ListValue); - RegisterPreference(pref); -} - -void PrefService::RegisterDictionaryPref(const wchar_t* path) { - Preference* pref = new Preference(pref_value_store_.get(), path, - new DictionaryValue()); - RegisterPreference(pref); -} - -void PrefService::RegisterLocalizedBooleanPref(const wchar_t* path, - int locale_default_message_id) { - Preference* pref = new Preference(pref_value_store_.get(), path, - CreateLocaleDefaultValue(Value::TYPE_BOOLEAN, locale_default_message_id)); - RegisterPreference(pref); -} - -void PrefService::RegisterLocalizedIntegerPref(const wchar_t* path, - int locale_default_message_id) { - Preference* pref = new Preference(pref_value_store_.get(), path, - CreateLocaleDefaultValue(Value::TYPE_INTEGER, locale_default_message_id)); - RegisterPreference(pref); -} - -void PrefService::RegisterLocalizedRealPref(const wchar_t* path, - int locale_default_message_id) { - Preference* pref = new Preference(pref_value_store_.get(), path, - CreateLocaleDefaultValue(Value::TYPE_REAL, locale_default_message_id)); - RegisterPreference(pref); -} - -void PrefService::RegisterLocalizedStringPref(const wchar_t* path, - int locale_default_message_id) { - Preference* pref = new Preference(pref_value_store_.get(), path, - CreateLocaleDefaultValue(Value::TYPE_STRING, locale_default_message_id)); - RegisterPreference(pref); -} - -bool PrefService::GetBoolean(const wchar_t* path) const { - DCHECK(CalledOnValidThread()); - - bool result = false; - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to read an unregistered pref: " << path; - return result; - } - bool rv = pref->GetValue()->GetAsBoolean(&result); - DCHECK(rv); - return result; -} - -int PrefService::GetInteger(const wchar_t* path) const { - DCHECK(CalledOnValidThread()); - - int result = 0; - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to read an unregistered pref: " << path; - return result; - } - bool rv = pref->GetValue()->GetAsInteger(&result); - DCHECK(rv); - return result; -} - -double PrefService::GetReal(const wchar_t* path) const { - DCHECK(CalledOnValidThread()); - - double result = 0.0; - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to read an unregistered pref: " << path; - return result; - } - bool rv = pref->GetValue()->GetAsReal(&result); - DCHECK(rv); - return result; -} - -std::string PrefService::GetString(const wchar_t* path) const { - DCHECK(CalledOnValidThread()); - - std::string result; - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to read an unregistered pref: " << path; - return result; - } - bool rv = pref->GetValue()->GetAsString(&result); - DCHECK(rv); - return result; -} - -FilePath PrefService::GetFilePath(const wchar_t* path) const { - DCHECK(CalledOnValidThread()); - - FilePath::StringType result; - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to read an unregistered pref: " << path; - return FilePath(result); - } - bool rv = pref->GetValue()->GetAsString(&result); - DCHECK(rv); -#if defined(OS_POSIX) - // We store filepaths as UTF8, so convert it back to the system type. - result = base::SysWideToNativeMB(UTF8ToWide(result)); -#endif - return FilePath(result); -} - -bool PrefService::HasPrefPath(const wchar_t* path) const { - return pref_value_store_->HasPrefPath(path); -} - -const PrefService::Preference* PrefService::FindPreference( - const wchar_t* pref_name) const { - DCHECK(CalledOnValidThread()); - Preference p(NULL, pref_name, NULL); - PreferenceSet::const_iterator it = prefs_.find(&p); - return it == prefs_.end() ? NULL : *it; -} - -bool PrefService::IsManagedPreference(const wchar_t* pref_name) const { - const Preference* pref = FindPreference(pref_name); - if (pref && pref->IsManaged()) { - return true; - } - return false; -} - -void PrefService::FireObserversIfChanged(const wchar_t* path, - const Value* old_value) { - if (PrefIsChanged(path, old_value)) - FireObservers(path); -} - -void PrefService::FireObservers(const wchar_t* path) { - DCHECK(CalledOnValidThread()); -#ifndef ANDROID - // Convert path to a std::wstring because the Details constructor requires a - // class. - std::wstring path_str(path); - PrefObserverMap::iterator observer_iterator = pref_observers_.find(path_str); - if (observer_iterator == pref_observers_.end()) - return; - - NotificationObserverList::Iterator it(*(observer_iterator->second)); - NotificationObserver* observer; - while ((observer = it.GetNext()) != NULL) { - observer->Observe(NotificationType::PREF_CHANGED, - Source<PrefService>(this), - Details<std::wstring>(&path_str)); - } -#endif -} - -bool PrefService::PrefIsChanged(const wchar_t* path, - const Value* old_value) { - Value* new_value = NULL; - pref_value_store_->GetValue(path, &new_value); - // Some unit tests have no values for certain prefs. - return (!new_value || !old_value->Equals(new_value)); -} - -const DictionaryValue* PrefService::GetDictionary(const wchar_t* path) const { - DCHECK(CalledOnValidThread()); - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to read an unregistered pref: " << path; - return NULL; - } - const Value* value = pref->GetValue(); - if (value->GetType() == Value::TYPE_NULL) - return NULL; - return static_cast<const DictionaryValue*>(value); -} - -const ListValue* PrefService::GetList(const wchar_t* path) const { - DCHECK(CalledOnValidThread()); - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to read an unregistered pref: " << path; - return NULL; - } - const Value* value = pref->GetValue(); - if (value->GetType() == Value::TYPE_NULL) - return NULL; - return static_cast<const ListValue*>(value); -} - -void PrefService::AddPrefObserver(const wchar_t* path, - NotificationObserver* obs) { - DCHECK(CalledOnValidThread()); - -#ifndef ANDROID - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to add an observer for an unregistered pref: " - << path; - return; - } - - // Get the pref observer list associated with the path. - NotificationObserverList* observer_list = NULL; - PrefObserverMap::iterator observer_iterator = pref_observers_.find(path); - if (observer_iterator == pref_observers_.end()) { - observer_list = new NotificationObserverList; - pref_observers_[path] = observer_list; - } else { - observer_list = observer_iterator->second; - } - - // Verify that this observer doesn't already exist. - NotificationObserverList::Iterator it(*observer_list); - NotificationObserver* existing_obs; - while ((existing_obs = it.GetNext()) != NULL) { - DCHECK(existing_obs != obs) << path << " observer already registered"; - if (existing_obs == obs) - return; - } - - // Ok, safe to add the pref observer. - observer_list->AddObserver(obs); -#endif -} - -void PrefService::RemovePrefObserver(const wchar_t* path, - NotificationObserver* obs) { - DCHECK(CalledOnValidThread()); - -#ifndef ANDROID - PrefObserverMap::iterator observer_iterator = pref_observers_.find(path); - if (observer_iterator == pref_observers_.end()) { - return; - } - - NotificationObserverList* observer_list = observer_iterator->second; - observer_list->RemoveObserver(obs); -#endif -} - -void PrefService::RegisterPreference(Preference* pref) { - DCHECK(CalledOnValidThread()); - - if (FindPreference(pref->name().c_str())) { - NOTREACHED() << "Tried to register duplicate pref " << pref->name(); - delete pref; - return; - } - prefs_.insert(pref); -} - -void PrefService::ClearPref(const wchar_t* path) { - DCHECK(CalledOnValidThread()); - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to clear an unregistered pref: " << path; - return; - } - Value* value; - bool has_old_value = pref_value_store_->GetValue(path, &value); - pref_value_store_->RemoveUserPrefValue(path); - - if (has_old_value) - FireObservers(path); -} - -void PrefService::Set(const wchar_t* path, const Value& value) { - DCHECK(CalledOnValidThread()); - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to write an unregistered pref: " << path; - return; - } - - // Allow dictionary and list types to be set to null. - if (value.GetType() == Value::TYPE_NULL && - (pref->type() == Value::TYPE_DICTIONARY || - pref->type() == Value::TYPE_LIST)) { - scoped_ptr<Value> old_value(GetPrefCopy(path)); - if (!old_value->Equals(&value)) { - pref_value_store_->RemoveUserPrefValue(path); - FireObservers(path); - } - return; - } - - if (pref->type() != value.GetType()) { - NOTREACHED() << "Wrong type for Set: " << path; - } - - scoped_ptr<Value> old_value(GetPrefCopy(path)); - pref_value_store_->SetUserPrefValue(path, value.DeepCopy()); - - FireObserversIfChanged(path, old_value.get()); -} - -void PrefService::SetBoolean(const wchar_t* path, bool value) { - DCHECK(CalledOnValidThread()); - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to write an unregistered pref: " << path; - return; - } - if (pref->IsManaged()) { - NOTREACHED() << "Preference is managed: " << path; - return; - } - if (pref->type() != Value::TYPE_BOOLEAN) { - NOTREACHED() << "Wrong type for SetBoolean: " << path; - return; - } - - scoped_ptr<Value> old_value(GetPrefCopy(path)); - Value* new_value = Value::CreateBooleanValue(value); - pref_value_store_->SetUserPrefValue(path, new_value); - - FireObserversIfChanged(path, old_value.get()); -} - -void PrefService::SetInteger(const wchar_t* path, int value) { - DCHECK(CalledOnValidThread()); - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to write an unregistered pref: " << path; - return; - } - if (pref->IsManaged()) { - NOTREACHED() << "Preference is managed: " << path; - return; - } - if (pref->type() != Value::TYPE_INTEGER) { - NOTREACHED() << "Wrong type for SetInteger: " << path; - return; - } - - scoped_ptr<Value> old_value(GetPrefCopy(path)); - Value* new_value = Value::CreateIntegerValue(value); - pref_value_store_->SetUserPrefValue(path, new_value); - - FireObserversIfChanged(path, old_value.get()); -} - -void PrefService::SetReal(const wchar_t* path, double value) { - DCHECK(CalledOnValidThread()); - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to write an unregistered pref: " << path; - return; - } - if (pref->IsManaged()) { - NOTREACHED() << "Preference is managed: " << path; - return; - } - if (pref->type() != Value::TYPE_REAL) { - NOTREACHED() << "Wrong type for SetReal: " << path; - return; - } - - scoped_ptr<Value> old_value(GetPrefCopy(path)); - Value* new_value = Value::CreateRealValue(value); - pref_value_store_->SetUserPrefValue(path, new_value); - - FireObserversIfChanged(path, old_value.get()); -} - -void PrefService::SetString(const wchar_t* path, const std::string& value) { - DCHECK(CalledOnValidThread()); - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to write an unregistered pref: " << path; - return; - } - if (pref->IsManaged()) { - NOTREACHED() << "Preference is managed: " << path; - return; - } - if (pref->type() != Value::TYPE_STRING) { - NOTREACHED() << "Wrong type for SetString: " << path; - return; - } - - scoped_ptr<Value> old_value(GetPrefCopy(path)); - Value* new_value = Value::CreateStringValue(value); - pref_value_store_->SetUserPrefValue(path, new_value); - - FireObserversIfChanged(path, old_value.get()); -} - -void PrefService::SetFilePath(const wchar_t* path, const FilePath& value) { - DCHECK(CalledOnValidThread()); - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to write an unregistered pref: " << path; - return; - } - if (pref->IsManaged()) { - NOTREACHED() << "Preference is managed: " << path; - return; - } - if (pref->type() != Value::TYPE_STRING) { - NOTREACHED() << "Wrong type for SetFilePath: " << path; - return; - } - - scoped_ptr<Value> old_value(GetPrefCopy(path)); -#if defined(OS_POSIX) - // Value::SetString only knows about UTF8 strings, so convert the path from - // the system native value to UTF8. - std::string path_utf8 = WideToUTF8(base::SysNativeMBToWide(value.value())); - Value* new_value = Value::CreateStringValue(path_utf8); - pref_value_store_->SetUserPrefValue(path, new_value); -#else - Value* new_value = Value::CreateStringValue(value.value()); - pref_value_store_->SetUserPrefValue(path, new_value); -#endif - - FireObserversIfChanged(path, old_value.get()); -} - -void PrefService::SetInt64(const wchar_t* path, int64 value) { - DCHECK(CalledOnValidThread()); - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to write an unregistered pref: " << path; - return; - } - if (pref->IsManaged()) { - NOTREACHED() << "Preference is managed: " << path; - return; - } - if (pref->type() != Value::TYPE_STRING) { - NOTREACHED() << "Wrong type for SetInt64: " << path; - return; - } - - scoped_ptr<Value> old_value(GetPrefCopy(path)); - Value* new_value = Value::CreateStringValue(Int64ToWString(value)); - pref_value_store_->SetUserPrefValue(path, new_value); - - FireObserversIfChanged(path, old_value.get()); -} - -int64 PrefService::GetInt64(const wchar_t* path) const { - DCHECK(CalledOnValidThread()); - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to read an unregistered pref: " << path; - return 0; - } - std::wstring result(L"0"); - bool rv = pref->GetValue()->GetAsString(&result); - DCHECK(rv); - return StringToInt64(WideToUTF16Hack(result)); -} - -void PrefService::RegisterInt64Pref(const wchar_t* path, int64 default_value) { - Preference* pref = new Preference(pref_value_store_.get(), path, - Value::CreateStringValue(Int64ToWString(default_value))); - RegisterPreference(pref); -} - -DictionaryValue* PrefService::GetMutableDictionary(const wchar_t* path) { - DCHECK(CalledOnValidThread()); - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to get an unregistered pref: " << path; - return NULL; - } - if (pref->type() != Value::TYPE_DICTIONARY) { - NOTREACHED() << "Wrong type for GetMutableDictionary: " << path; - return NULL; - } - - DictionaryValue* dict = NULL; - Value* tmp_value = NULL; - if (!pref_value_store_->GetValue(path, &tmp_value) || - !tmp_value->IsType(Value::TYPE_DICTIONARY)) { - dict = new DictionaryValue; - pref_value_store_->SetUserPrefValue(path, dict); - } else { - dict = static_cast<DictionaryValue*>(tmp_value); - } - return dict; -} - -ListValue* PrefService::GetMutableList(const wchar_t* path) { - DCHECK(CalledOnValidThread()); - - const Preference* pref = FindPreference(path); - if (!pref) { - NOTREACHED() << "Trying to get an unregistered pref: " << path; - return NULL; - } - if (pref->type() != Value::TYPE_LIST) { - NOTREACHED() << "Wrong type for GetMutableList: " << path; - return NULL; - } - - ListValue* list = NULL; - Value* tmp_value = NULL; - if (!pref_value_store_->GetValue(path, &tmp_value)) { - list = new ListValue; - pref_value_store_->SetUserPrefValue(path, list); - } else { - list = static_cast<ListValue*>(tmp_value); - } - return list; -} - -Value* PrefService::GetPrefCopy(const wchar_t* path) { - DCHECK(CalledOnValidThread()); - - const Preference* pref = FindPreference(path); - DCHECK(pref); - return pref->GetValue()->DeepCopy(); -} - -/////////////////////////////////////////////////////////////////////////////// -// PrefService::Preference - -PrefService::Preference::Preference(PrefValueStore* pref_value_store, - const wchar_t* name, - Value* default_value) - : type_(Value::TYPE_NULL), - name_(name), - default_value_(default_value), - pref_value_store_(pref_value_store) { - DCHECK(name); - - if (default_value) { - type_ = default_value->GetType(); - DCHECK(type_ != Value::TYPE_NULL && type_ != Value::TYPE_BINARY) << - "invalid preference type: " << type_; - } - - // We set the default value of lists and dictionaries to be null so it's - // easier for callers to check for empty list/dict prefs. - if (Value::TYPE_LIST == type_ || Value::TYPE_DICTIONARY == type_) - default_value_.reset(Value::CreateNullValue()); -} - -const Value* PrefService::Preference::GetValue() const { - DCHECK(NULL != pref_value_store_) << - "Must register pref before getting its value"; - - Value* temp_value = NULL; - if (pref_value_store_->GetValue(name_, &temp_value) && - temp_value->GetType() == type_) { - return temp_value; - } - - // Pref not found, just return the app default. - return default_value_.get(); -} - -bool PrefService::Preference::IsDefaultValue() const { - DCHECK(default_value_.get()); - return default_value_->Equals(GetValue()); -} - -bool PrefService::Preference::IsManaged() const { - return pref_value_store_->PrefValueInManagedStore(name_.c_str()); -} - -bool PrefService::Preference::HasExtensionSetting() const { - return pref_value_store_->PrefValueInExtensionStore(name_.c_str()); -} - -bool PrefService::Preference::HasUserSetting() const { - return pref_value_store_->PrefValueInUserStore(name_.c_str()); -} - -bool PrefService::Preference::IsExtensionControlled() const { - return pref_value_store_->PrefValueFromExtensionStore(name_.c_str()); -} - -bool PrefService::Preference::IsUserControlled() const { - return pref_value_store_->PrefValueFromUserStore(name_.c_str()); -} - -bool PrefService::Preference::IsUserModifiable() const { - return pref_value_store_->PrefValueUserModifiable(name_.c_str()); -} diff --git a/chrome/browser/pref_service.h b/chrome/browser/pref_service.h deleted file mode 100644 index 2d50747..0000000 --- a/chrome/browser/pref_service.h +++ /dev/null @@ -1,278 +0,0 @@ -// Copyright (c) 2010 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. - -// This provides a way to access the application's current preferences. - -#ifndef CHROME_BROWSER_PREF_SERVICE_H_ -#define CHROME_BROWSER_PREF_SERVICE_H_ - -#include <set> - -#include "base/file_path.h" -#include "base/hash_tables.h" -#include "base/non_thread_safe.h" -#include "base/observer_list.h" -#include "base/scoped_ptr.h" -#include "base/values.h" -#include "chrome/browser/pref_value_store.h" -#include "chrome/common/pref_store.h" - -class NotificationObserver; -class Preference; -class ScopedPrefUpdate; - -class PrefService : public NonThreadSafe { - public: - - // A helper class to store all the information associated with a preference. - class Preference { - public: - - // The type of the preference is determined by the type of |default_value|. - // Therefore, the type needs to be a boolean, integer, real, string, - // dictionary (a branch), or list. You shouldn't need to construct this on - // your own, use the PrefService::Register*Pref methods instead. - // |default_value| will be owned by the Preference object. - Preference(PrefValueStore* pref_value_store, - const wchar_t* name, - Value* default_value); - ~Preference() {} - - Value::ValueType type() const { return type_; } - - // Returns the name of the Preference (i.e., the key, e.g., - // browser.window_placement). - const std::wstring name() const { return name_; } - - // Returns the value of the Preference. If there is no user specified - // value, it returns the default value. - const Value* GetValue() const; - - // Returns true if the current value matches the default value. - bool IsDefaultValue() const; - - // Returns true if the Preference is managed, i.e. set by an admin policy. - // Since managed prefs have the highest priority, this also indicates - // whether the pref is actually being controlled by the policy setting. - bool IsManaged() const; - - // Returns true if the Preference has a value set by an extension, even if - // that value is being overridden by a higher-priority source. - bool HasExtensionSetting() const; - - // Returns true if the Preference has a user setting, even if that value is - // being overridden by a higher-priority source. - bool HasUserSetting() const; - - // Returns true if the Preference value is currently being controlled by an - // extension, and not by any higher-priority source. - bool IsExtensionControlled() const; - - // Returns true if the Preference value is currently being controlled by a - // user setting, and not by any higher-priority source. - bool IsUserControlled() const; - - // Returns true if the user can change the Preference value, which is the - // case if no higher-priority source than the user store controls the - // Preference. - bool IsUserModifiable() const; - - private: - friend class PrefService; - - Value::ValueType type_; - std::wstring name_; - scoped_ptr<Value> default_value_; - - // A reference to the pref service's pref_value_store_. - PrefValueStore* pref_value_store_; - - DISALLOW_COPY_AND_ASSIGN(Preference); - }; - - // Factory method that creates a new instance of a |PrefService| with - // all platform-applicable PrefStores (managed, extension, user, etc.). - // This is the usual way to create a new PrefService. - static PrefService* CreatePrefService(const FilePath& pref_filename); - - // Convenience factory method for use in unit tests. Creates a new - // PrefService that uses a PrefValueStore with user preferences at the given - // |pref_filename|, and no other PrefStores (i.e., no other types of - // preferences). - static PrefService* CreateUserPrefService(const FilePath& pref_filename); - - // This constructor is primarily used by tests. The |PrefValueStore| provides - // preference values. - explicit PrefService(PrefValueStore* pref_value_store); - -#ifdef ANDROID - // TODO: Upstream - virtual -#endif - ~PrefService(); - - // Reloads the data from file. This should only be called when the importer - // is running during first run, and the main process may not change pref - // values while the importer process is running. Returns true on success. - bool ReloadPersistentPrefs(); - - // Returns true if the preference for the given preference name is available - // and is managed. - bool IsManagedPreference(const wchar_t* pref_name) const; - - // Writes the data to disk. The return value only reflects whether - // serialization was successful; we don't know whether the data actually made - // it on disk (since it's on a different thread). This should only be used if - // we need to save immediately (basically, during shutdown). Otherwise, you - // should use ScheduleSavePersistentPrefs. - bool SavePersistentPrefs(); - - // Serializes the data and schedules save using ImportantFileWriter. - void ScheduleSavePersistentPrefs(); - - // Make the PrefService aware of a pref. - void RegisterBooleanPref(const wchar_t* path, - bool default_value); - void RegisterIntegerPref(const wchar_t* path, - int default_value); - void RegisterRealPref(const wchar_t* path, - double default_value); - void RegisterStringPref(const wchar_t* path, - const std::string& default_value); - void RegisterFilePathPref(const wchar_t* path, - const FilePath& default_value); - void RegisterListPref(const wchar_t* path); - void RegisterDictionaryPref(const wchar_t* path); - - // These varients use a default value from the locale dll instead. - void RegisterLocalizedBooleanPref(const wchar_t* path, - int locale_default_message_id); - void RegisterLocalizedIntegerPref(const wchar_t* path, - int locale_default_message_id); - void RegisterLocalizedRealPref(const wchar_t* path, - int locale_default_message_id); - void RegisterLocalizedStringPref(const wchar_t* path, - int locale_default_message_id); - - // If the path is valid and the value at the end of the path matches the type - // specified, it will return the specified value. Otherwise, the default - // value (set when the pref was registered) will be returned. - bool GetBoolean(const wchar_t* path) const; - int GetInteger(const wchar_t* path) const; - double GetReal(const wchar_t* path) const; - std::string GetString(const wchar_t* path) const; - FilePath GetFilePath(const wchar_t* path) const; - - // Returns the branch if it exists. If it's not a branch or the branch does - // not exist, returns NULL. - const DictionaryValue* GetDictionary(const wchar_t* path) const; - const ListValue* GetList(const wchar_t* path) const; - - // If the pref at the given path changes, we call the observer's Observe - // method with NOTIFY_PREF_CHANGED. - virtual void AddPrefObserver(const wchar_t* path, NotificationObserver* obs); - void RemovePrefObserver(const wchar_t* path, NotificationObserver* obs); - - // Removes a user pref and restores the pref to its default value. - void ClearPref(const wchar_t* path); - - // If the path is valid (i.e., registered), update the pref value. - void Set(const wchar_t* path, const Value& value); - void SetBoolean(const wchar_t* path, bool value); - void SetInteger(const wchar_t* path, int value); - void SetReal(const wchar_t* path, double value); - void SetString(const wchar_t* path, const std::string& value); - void SetFilePath(const wchar_t* path, const FilePath& value); - - // Int64 helper methods that actually store the given value as a string. - // Note that if obtaining the named value via GetDictionary or GetList, the - // Value type will be TYPE_STRING. - void SetInt64(const wchar_t* path, int64 value); - int64 GetInt64(const wchar_t* path) const; - void RegisterInt64Pref(const wchar_t* path, int64 default_value); - - // Used to set the value of dictionary or list values in the pref tree. This - // will create a dictionary or list if one does not exist in the pref tree. - // This method returns NULL only if you're requesting an unregistered pref or - // a non-dict/non-list pref. - // WARNING: Changes to the dictionary or list will not automatically notify - // pref observers. - // Use a ScopedPrefUpdate to update observers on changes. - DictionaryValue* GetMutableDictionary(const wchar_t* path); - ListValue* GetMutableList(const wchar_t* path); - - // Returns true if a value has been set for the specified path. - // NOTE: this is NOT the same as FindPreference. In particular - // FindPreference returns whether RegisterXXX has been invoked, where as - // this checks if a value exists for the path. - bool HasPrefPath(const wchar_t* path) const; - - class PreferencePathComparator { - public: - bool operator() (Preference* lhs, Preference* rhs) const { - return lhs->name() < rhs->name(); - } - }; - typedef std::set<Preference*, PreferencePathComparator> PreferenceSet; - const PreferenceSet& preference_set() const { return prefs_; } - - // A helper method to quickly look up a preference. Returns NULL if the - // preference is not registered. - const Preference* FindPreference(const wchar_t* pref_name) const; - - // For the given pref_name, fire any observer of the pref only if |old_value| - // is different from the current value. Virtual so it can be mocked for a - // unit test. - virtual void FireObserversIfChanged(const wchar_t* pref_name, - const Value* old_value); - - bool read_only() const { return pref_value_store_->ReadOnly(); } - - protected: - // For the given pref_name, fire any observer of the pref. - void FireObservers(const wchar_t* pref_name); - - // This should only be accessed by subclasses for unit-testing. - bool PrefIsChanged(const wchar_t* path, const Value* old_value); - - private: - // Add a preference to the PreferenceMap. If the pref already exists, return - // false. This method takes ownership of |pref|. - void RegisterPreference(Preference* pref); - - // Returns a copy of the current pref value. The caller is responsible for - // deleting the returned object. - Value* GetPrefCopy(const wchar_t* pref_name); - - // Load from disk. Returns a non-zero error code on failure. - PrefStore::PrefReadError LoadPersistentPrefs(); - - // Load preferences from storage, attempting to diagnose and handle errors. - // This should only be called from the constructor. - void InitFromStorage(); - - // The value of a Preference can be: - // managed, user defined, recommended or default. - // The PrefValueStore manages enforced, user defined and recommended values - // for Preferences. It returns the value of a Preference with the - // highest priority, and allows to set user defined values for preferences - // that are not managed. - scoped_ptr<PrefValueStore> pref_value_store_; - - // A set of all the registered Preference objects. - PreferenceSet prefs_; - - // A map from pref names to a list of observers. Observers get fired in the - // order they are added. - typedef ObserverList<NotificationObserver> NotificationObserverList; - typedef base::hash_map<std::wstring, NotificationObserverList*> - PrefObserverMap; - PrefObserverMap pref_observers_; - - friend class ScopedPrefUpdate; - - DISALLOW_COPY_AND_ASSIGN(PrefService); -}; - -#endif // CHROME_BROWSER_PREF_SERVICE_H_ diff --git a/chrome/browser/prefs/pref_service.cc b/chrome/browser/prefs/pref_service.cc index 0668ed4..faa91ba 100644 --- a/chrome/browser/prefs/pref_service.cc +++ b/chrome/browser/prefs/pref_service.cc @@ -7,8 +7,13 @@ #include <algorithm> #include <string> +#ifndef ANDROID +// FIXME: Do we need this on Android? #include "app/l10n_util.h" +#endif +#ifndef ANDROID #include "base/command_line.h" +#endif #include "base/file_path.h" #include "base/file_util.h" #include "base/histogram.h" @@ -22,9 +27,13 @@ #include "build/build_config.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/profile.h" +#ifndef ANDROID +// Notifications do not compile on Android and are the cause +// of most of the ANDROID guards in this file. #include "chrome/common/notification_service.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" +#endif namespace { @@ -32,6 +41,7 @@ namespace { // the string value in the locale dll. Because we control the values in a // locale dll, this should always return a Value of the appropriate type. Value* CreateLocaleDefaultValue(Value::ValueType type, int message_id) { +#ifndef ANDROID std::string resource_string = l10n_util::GetStringUTF8(message_id); DCHECK(!resource_string.empty()); switch (type) { @@ -64,6 +74,7 @@ Value* CreateLocaleDefaultValue(Value::ValueType type, int message_id) { "list and dictionary types cannot have default locale values"; } } +#endif NOTREACHED(); return Value::CreateNullValue(); } @@ -71,9 +82,11 @@ Value* CreateLocaleDefaultValue(Value::ValueType type, int message_id) { // Forwards a notification after a PostMessage so that we can wait for the // MessageLoop to run. void NotifyReadError(PrefService* pref, int message_id) { +#ifndef ANDROID Source<PrefService> source(pref); NotificationService::current()->Notify(NotificationType::PROFILE_ERROR, source, Details<int>(&message_id)); +#endif } } // namespace @@ -81,7 +94,7 @@ void NotifyReadError(PrefService* pref, int message_id) { // static PrefService* PrefService::CreatePrefService(const FilePath& pref_filename, Profile* profile) { -#if defined(OS_LINUX) +#if defined(OS_LINUX) && !defined(ANDROID) // We'd like to see what fraction of our users have the preferences // stored on a network file system, as we've had no end of troubles // with NFS/AFS. @@ -106,7 +119,9 @@ PrefService* PrefService::CreateUserPrefService(const FilePath& pref_filename) { PrefService::PrefService(PrefValueStore* pref_value_store) : pref_value_store_(pref_value_store) { +#ifndef ANDROID pref_notifier_.reset(new PrefNotifier(this, pref_value_store)); +#endif InitFromStorage(); } @@ -117,6 +132,7 @@ PrefService::~PrefService() { } void PrefService::InitFromStorage() { +#ifndef ANDROID PrefStore::PrefReadError error = LoadPersistentPrefs(); if (error == PrefStore::PREF_READ_ERROR_NONE) return; @@ -136,6 +152,7 @@ void PrefService::InitFromStorage() { NewRunnableFunction(&NotifyReadError, this, message_id)); } UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error, 20); +#endif } bool PrefService::ReloadPersistentPrefs() { @@ -353,6 +370,7 @@ const ListValue* PrefService::GetList(const char* path) const { return static_cast<const ListValue*>(value); } +#ifndef ANDROID void PrefService::AddPrefObserver(const char* path, NotificationObserver* obs) { pref_notifier_->AddPrefObserver(path, obs); @@ -362,6 +380,7 @@ void PrefService::RemovePrefObserver(const char* path, NotificationObserver* obs) { pref_notifier_->RemovePrefObserver(path, obs); } +#endif void PrefService::RegisterPreference(const char* path, Value* default_value) { DCHECK(CalledOnValidThread()); @@ -400,8 +419,10 @@ void PrefService::ClearPref(const char* path) { NOTREACHED() << "Trying to clear an unregistered pref: " << path; return; } +#ifndef ANDROID if (pref_value_store_->RemoveUserPrefValue(path)) pref_notifier_->OnUserPreferenceSet(path); +#endif } void PrefService::Set(const char* path, const Value& value) { @@ -427,9 +448,10 @@ void PrefService::Set(const char* path, const Value& value) { } else { value_changed = pref_value_store_->SetUserPrefValue(path, value.DeepCopy()); } - +#ifndef ANDROID if (value_changed) pref_notifier_->OnUserPreferenceSet(path); +#endif } void PrefService::SetBoolean(const char* path, bool value) { @@ -564,8 +586,10 @@ void PrefService::SetUserPrefValue(const char* path, Value* new_value) { return; } +#ifndef ANDROID if (pref_value_store_->SetUserPrefValue(path, new_value)) pref_notifier_->OnUserPreferenceSet(path); +#endif } /////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/prefs/pref_service.h b/chrome/browser/prefs/pref_service.h index 3e90db6..ddf551d 100644 --- a/chrome/browser/prefs/pref_service.h +++ b/chrome/browser/prefs/pref_service.h @@ -218,15 +218,19 @@ class PrefService : public NonThreadSafe { bool read_only() const { return pref_value_store_->ReadOnly(); } +#ifndef ANDROID PrefNotifier* pref_notifier() const { return pref_notifier_.get(); } +#endif PrefValueStore* pref_value_store() const { return pref_value_store_.get(); } +#ifndef ANDROID protected: // The PrefNotifier handles registering and notifying preference observers. // It is created and owned by this PrefService. Subclasses may access it for // unit testing. scoped_ptr<PrefNotifier> pref_notifier_; +#endif private: // Registration of pref change observers must be done using the @@ -238,12 +242,14 @@ class PrefService : public NonThreadSafe { friend class PrefChangeRegistrar; friend class subtle::PrefMemberBase; +#ifndef ANDROID // If the pref at the given path changes, we call the observer's Observe // method with PREF_CHANGED. Note that observers should not call these methods // directly but rather use a PrefChangeRegistrar to make sure the observer // gets cleaned up properly. virtual void AddPrefObserver(const char* path, NotificationObserver* obs); virtual void RemovePrefObserver(const char* path, NotificationObserver* obs); +#endif // Add a preference to the PreferenceMap. If the pref already exists, return // false. This method takes ownership of |default_value|. diff --git a/chrome/browser/prefs/pref_value_store.cc b/chrome/browser/prefs/pref_value_store.cc index 46c825d..301270d 100644 --- a/chrome/browser/prefs/pref_value_store.cc +++ b/chrome/browser/prefs/pref_value_store.cc @@ -4,13 +4,17 @@ #include "chrome/browser/prefs/pref_value_store.h" +#ifndef ANDROID #include "chrome/browser/chrome_thread.h" #include "chrome/browser/extensions/extension_pref_store.h" #include "chrome/browser/policy/configuration_policy_pref_store.h" #include "chrome/browser/prefs/command_line_pref_store.h" +#endif #include "chrome/browser/prefs/default_pref_store.h" +#ifndef ANDROID #include "chrome/common/json_pref_store.h" #include "chrome/common/notification_service.h" +#endif namespace { @@ -38,6 +42,9 @@ PrefValueStore* PrefValueStore::CreatePrefValueStore( const FilePath& pref_filename, Profile* profile, bool user_only) { +#ifdef ANDROID + return new PrefValueStore(NULL, NULL, NULL, NULL, NULL, new DefaultPrefStore()); +#else using policy::ConfigurationPolicyPrefStore; ConfigurationPolicyPrefStore* managed = NULL; ExtensionPrefStore* extension = NULL; @@ -58,6 +65,7 @@ PrefValueStore* PrefValueStore::CreatePrefValueStore( } return new PrefValueStore(managed, extension, command_line, user, recommended, default_store); +#endif } PrefValueStore::~PrefValueStore() {} @@ -239,6 +247,7 @@ bool PrefValueStore::PrefValueInStore(const char* name, return false; } +#ifndef ANDROID void PrefValueStore::RefreshPolicyPrefsCompletion( PrefStore* new_managed_pref_store, PrefStore* new_recommended_pref_store, @@ -323,6 +332,7 @@ void PrefValueStore::RefreshPolicyPrefs( new_recommended_pref_store, callback)); } +#endif // ANDROID PrefValueStore::PrefValueStore(PrefStore* managed_prefs, PrefStore* extension_prefs, diff --git a/chrome/browser/prefs/pref_value_store.h b/chrome/browser/prefs/pref_value_store.h index c361e07..bd1bc6d 100644 --- a/chrome/browser/prefs/pref_value_store.h +++ b/chrome/browser/prefs/pref_value_store.h @@ -16,7 +16,9 @@ #include "base/ref_counted.h" #include "base/scoped_ptr.h" #include "base/values.h" +#ifndef ANDROID #include "chrome/browser/chrome_thread.h" +#endif #include "chrome/browser/prefs/pref_notifier.h" #include "chrome/common/pref_store.h" @@ -47,6 +49,9 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { Profile* profile, bool user_only); +#ifdef ANDROID + virtual +#endif ~PrefValueStore(); // Gets the value for the given preference name that has a valid value type; @@ -147,6 +152,7 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { // lifecycle is managed in another thread. typedef Callback1<std::vector<std::string> >::Type AfterRefreshCallback; +#ifndef ANDROID // Called as a result of a notification of policy change. Triggers a // reload of managed preferences from policy. Caller must pass in // new, uninitialized managed and recommended PrefStores in @@ -159,6 +165,7 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { void RefreshPolicyPrefs(PrefStore* managed_pref_store, PrefStore* recommended_pref_store, AfterRefreshCallback* callback); +#endif protected: // In decreasing order of precedence: @@ -198,6 +205,7 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { bool PrefValueInStore(const char* name, PrefNotifier::PrefStoreType store) const; +#ifndef ANDROID // Called during policy refresh after ReadPrefs completes on the thread // that initiated the policy refresh. RefreshPolicyPrefsCompletion takes // ownership of the |callback| object. @@ -213,6 +221,7 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { PrefStore* new_managed_pref_store, PrefStore* new_recommended_pref_store, AfterRefreshCallback* callback); +#endif DISALLOW_COPY_AND_ASSIGN(PrefValueStore); }; |