| Index: chrome/browser/prefs/pref_service.cc
|
| diff --git a/chrome/browser/prefs/pref_service.cc b/chrome/browser/prefs/pref_service.cc
|
| index 0f193164cac5a03cf3a9f7b3be512ab144494d24..8d097c5eca189321af52b9ba2fd0ba0da8dd2212 100644
|
| --- a/chrome/browser/prefs/pref_service.cc
|
| +++ b/chrome/browser/prefs/pref_service.cc
|
| @@ -87,53 +87,25 @@ class ReadErrorHandler : public PersistentPrefStore::ReadErrorDelegate {
|
|
|
| } // namespace
|
|
|
| -PrefService* PrefService::CreateIncognitoPrefService(
|
| - PrefStore* incognito_extension_prefs) {
|
| - pref_service_forked_ = true;
|
| - PrefNotifierImpl* pref_notifier = new PrefNotifierImpl();
|
| - OverlayUserPrefStore* incognito_pref_store =
|
| - new OverlayUserPrefStore(user_pref_store_.get());
|
| - PrefsTabHelper::InitIncognitoUserPrefStore(incognito_pref_store);
|
| - return new PrefService(
|
| - pref_notifier,
|
| - pref_value_store_->CloneAndSpecialize(
|
| - NULL, // managed
|
| - incognito_extension_prefs,
|
| - NULL, // command_line_prefs
|
| - incognito_pref_store,
|
| - NULL, // recommended
|
| - default_store_.get(),
|
| - NULL, // pref_sync_associator
|
| - pref_notifier),
|
| - incognito_pref_store,
|
| - default_store_.get(),
|
| - NULL,
|
| - get_localized_string_method_,
|
| - read_error_callback_,
|
| - false);
|
| +PrefService::PrefService() {
|
| }
|
|
|
| -PrefService::PrefService(
|
| +void PrefService::Initialize(
|
| PrefNotifierImpl* pref_notifier,
|
| PrefValueStore* pref_value_store,
|
| PersistentPrefStore* user_prefs,
|
| DefaultPrefStore* default_store,
|
| - PrefModelAssociator* pref_sync_associator,
|
| base::Callback<std::string(int)> get_localized_string_method,
|
| base::Callback<void(PersistentPrefStore::PrefReadError)>
|
| read_error_callback,
|
| - bool async)
|
| - : pref_notifier_(pref_notifier),
|
| - pref_value_store_(pref_value_store),
|
| - user_pref_store_(user_prefs),
|
| - default_store_(default_store),
|
| - pref_sync_associator_(pref_sync_associator),
|
| - get_localized_string_method_(get_localized_string_method),
|
| - read_error_callback_(read_error_callback),
|
| - pref_service_forked_(false) {
|
| + bool async) {
|
| + pref_notifier_.reset(pref_notifier);
|
| + pref_value_store_.reset(pref_value_store);
|
| + user_pref_store_ = user_prefs;
|
| + default_store_ = default_store;
|
| + get_localized_string_method_ = get_localized_string_method;
|
| + read_error_callback_ = read_error_callback;
|
| pref_notifier_->SetPrefService(this);
|
| - if (pref_sync_associator_.get())
|
| - pref_sync_associator_->SetPrefService(this);
|
| InitFromStorage(async);
|
| }
|
|
|
| @@ -144,7 +116,6 @@ PrefService::~PrefService() {
|
| pref_value_store_.reset();
|
| user_pref_store_ = NULL;
|
| default_store_ = NULL;
|
| - pref_sync_associator_.reset();
|
| pref_notifier_.reset();
|
| }
|
|
|
| @@ -171,330 +142,6 @@ void PrefService::CommitPendingWrite() {
|
| user_pref_store_->CommitPendingWrite();
|
| }
|
|
|
| -void PrefService::AddObserver(PrefServiceObserver* observer) {
|
| - observer_list_.AddObserver(observer);
|
| -}
|
| -
|
| -void PrefService::RemoveObserver(PrefServiceObserver* observer) {
|
| - observer_list_.RemoveObserver(observer);
|
| -}
|
| -
|
| -bool PrefService::IsSyncing() {
|
| - return pref_sync_associator_.get() &&
|
| - pref_sync_associator_->models_associated();
|
| -}
|
| -
|
| -void PrefService::OnIsSyncingChanged() {
|
| - FOR_EACH_OBSERVER(PrefServiceObserver, observer_list_, OnIsSyncingChanged());
|
| -}
|
| -
|
| -namespace {
|
| -
|
| -// If there's no g_browser_process or no local state, return true (for testing).
|
| -bool IsLocalStatePrefService(PrefService* prefs) {
|
| - return (!g_browser_process ||
|
| - !g_browser_process->local_state() ||
|
| - g_browser_process->local_state() == prefs);
|
| -}
|
| -
|
| -// If there's no g_browser_process, return true (for testing).
|
| -bool IsProfilePrefService(PrefService* prefs) {
|
| - // TODO(zea): uncomment this once all preferences are only ever registered
|
| - // with either the local_state's pref service or the profile's pref service.
|
| - // return (!g_browser_process || g_browser_process->local_state() != prefs);
|
| - return true;
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| -// Local State prefs.
|
| -void PrefService::RegisterBooleanPref(const char* path,
|
| - bool default_value) {
|
| - // If this fails, the pref service in use is a profile pref service, so the
|
| - // sync status must be provided (see profile pref registration calls below).
|
| - DCHECK(IsLocalStatePrefService(this));
|
| - RegisterPreference(path,
|
| - Value::CreateBooleanValue(default_value),
|
| - UNSYNCABLE_PREF);
|
| -}
|
| -
|
| -void PrefService::RegisterIntegerPref(const char* path, int default_value) {
|
| - // If this fails, the pref service in use is a profile pref service, so the
|
| - // sync status must be provided (see profile pref registration calls below).
|
| - DCHECK(IsLocalStatePrefService(this));
|
| - RegisterPreference(path,
|
| - Value::CreateIntegerValue(default_value),
|
| - UNSYNCABLE_PREF);
|
| -}
|
| -
|
| -void PrefService::RegisterDoublePref(const char* path, double default_value) {
|
| - // If this fails, the pref service in use is a profile pref service, so the
|
| - // sync status must be provided (see profile pref registration calls below).
|
| - DCHECK(IsLocalStatePrefService(this));
|
| - RegisterPreference(path,
|
| - Value::CreateDoubleValue(default_value),
|
| - UNSYNCABLE_PREF);
|
| -}
|
| -
|
| -void PrefService::RegisterStringPref(const char* path,
|
| - const std::string& default_value) {
|
| - // If this fails, the pref service in use is a profile pref service, so the
|
| - // sync status must be provided (see profile pref registration calls below).
|
| - DCHECK(IsLocalStatePrefService(this));
|
| - RegisterPreference(path,
|
| - Value::CreateStringValue(default_value),
|
| - UNSYNCABLE_PREF);
|
| -}
|
| -
|
| -void PrefService::RegisterFilePathPref(const char* path,
|
| - const FilePath& default_value) {
|
| - // If this fails, the pref service in use is a profile pref service, so the
|
| - // sync status must be provided (see profile pref registration calls below).
|
| - DCHECK(IsLocalStatePrefService(this));
|
| - RegisterPreference(path,
|
| - Value::CreateStringValue(default_value.value()),
|
| - UNSYNCABLE_PREF);
|
| -}
|
| -
|
| -void PrefService::RegisterListPref(const char* path) {
|
| - // If this fails, the pref service in use is a profile pref service, so the
|
| - // sync status must be provided (see profile pref registration calls below).
|
| - DCHECK(IsLocalStatePrefService(this));
|
| - RegisterPreference(path,
|
| - new ListValue(),
|
| - UNSYNCABLE_PREF);
|
| -}
|
| -
|
| -void PrefService::RegisterListPref(const char* path, ListValue* default_value) {
|
| - // If this fails, the pref service in use is a profile pref service, so the
|
| - // sync status must be provided (see profile pref registration calls below).
|
| - DCHECK(IsLocalStatePrefService(this));
|
| - RegisterPreference(path,
|
| - default_value,
|
| - UNSYNCABLE_PREF);
|
| -}
|
| -
|
| -void PrefService::RegisterDictionaryPref(const char* path) {
|
| - // If this fails, the pref service in use is a profile pref service, so the
|
| - // sync status must be provided (see profile pref registration calls below).
|
| - DCHECK(IsLocalStatePrefService(this));
|
| - RegisterPreference(path,
|
| - new DictionaryValue(),
|
| - UNSYNCABLE_PREF);
|
| -}
|
| -
|
| -void PrefService::RegisterDictionaryPref(const char* path,
|
| - DictionaryValue* default_value) {
|
| - // If this fails, the pref service in use is a profile pref service, so the
|
| - // sync status must be provided (see profile pref registration calls below).
|
| - DCHECK(IsLocalStatePrefService(this));
|
| - RegisterPreference(path,
|
| - default_value,
|
| - UNSYNCABLE_PREF);
|
| -}
|
| -
|
| -void PrefService::RegisterLocalizedBooleanPref(const char* path,
|
| - int locale_default_message_id) {
|
| - // If this fails, the pref service in use is a profile pref service, so the
|
| - // sync status must be provided (see profile pref registration calls below).
|
| - DCHECK(IsLocalStatePrefService(this));
|
| - RegisterPreference(
|
| - path,
|
| - CreateLocaleDefaultValue(
|
| - Value::TYPE_BOOLEAN,
|
| - get_localized_string_method_.Run(locale_default_message_id)),
|
| - UNSYNCABLE_PREF);
|
| -}
|
| -
|
| -void PrefService::RegisterLocalizedIntegerPref(const char* path,
|
| - int locale_default_message_id) {
|
| - // If this fails, the pref service in use is a profile pref service, so the
|
| - // sync status must be provided (see profile pref registration calls below).
|
| - DCHECK(IsLocalStatePrefService(this));
|
| - RegisterPreference(
|
| - path,
|
| - CreateLocaleDefaultValue(
|
| - Value::TYPE_INTEGER,
|
| - get_localized_string_method_.Run(locale_default_message_id)),
|
| - UNSYNCABLE_PREF);
|
| -}
|
| -
|
| -void PrefService::RegisterLocalizedDoublePref(const char* path,
|
| - int locale_default_message_id) {
|
| - // If this fails, the pref service in use is a profile pref service, so the
|
| - // sync status must be provided (see profile pref registration calls below).
|
| - DCHECK(IsLocalStatePrefService(this));
|
| - RegisterPreference(
|
| - path,
|
| - CreateLocaleDefaultValue(
|
| - Value::TYPE_DOUBLE,
|
| - get_localized_string_method_.Run(locale_default_message_id)),
|
| - UNSYNCABLE_PREF);
|
| -}
|
| -
|
| -void PrefService::RegisterLocalizedStringPref(const char* path,
|
| - int locale_default_message_id) {
|
| - // If this fails, the pref service in use is a profile pref service, so the
|
| - // sync status must be provided (see profile pref registration calls below).
|
| - DCHECK(IsLocalStatePrefService(this));
|
| - RegisterPreference(
|
| - path,
|
| - CreateLocaleDefaultValue(
|
| - Value::TYPE_STRING,
|
| - get_localized_string_method_.Run(locale_default_message_id)),
|
| - UNSYNCABLE_PREF);
|
| -}
|
| -
|
| -void PrefService::RegisterInt64Pref(const char* path, int64 default_value) {
|
| - // If this fails, the pref service in use is a profile pref service, so the
|
| - // sync status must be provided (see profile pref registration calls below).
|
| - DCHECK(IsLocalStatePrefService(this));
|
| - RegisterPreference(
|
| - path,
|
| - Value::CreateStringValue(base::Int64ToString(default_value)),
|
| - UNSYNCABLE_PREF);
|
| -}
|
| -
|
| -// Profile prefs (must use the sync_status variable).
|
| -void PrefService::RegisterBooleanPref(const char* path,
|
| - bool default_value,
|
| - PrefSyncStatus sync_status) {
|
| - DCHECK(IsProfilePrefService(this));
|
| - RegisterPreference(path,
|
| - Value::CreateBooleanValue(default_value),
|
| - sync_status);
|
| -}
|
| -
|
| -void PrefService::RegisterIntegerPref(const char* path,
|
| - int default_value,
|
| - PrefSyncStatus sync_status) {
|
| - DCHECK(IsProfilePrefService(this));
|
| - RegisterPreference(path,
|
| - Value::CreateIntegerValue(default_value),
|
| - sync_status);
|
| -}
|
| -
|
| -void PrefService::RegisterDoublePref(const char* path,
|
| - double default_value,
|
| - PrefSyncStatus sync_status) {
|
| - DCHECK(IsProfilePrefService(this));
|
| - RegisterPreference(path,
|
| - Value::CreateDoubleValue(default_value),
|
| - sync_status);
|
| -}
|
| -
|
| -void PrefService::RegisterStringPref(const char* path,
|
| - const std::string& default_value,
|
| - PrefSyncStatus sync_status) {
|
| - DCHECK(IsProfilePrefService(this));
|
| - RegisterPreference(path,
|
| - Value::CreateStringValue(default_value),
|
| - sync_status);
|
| -}
|
| -
|
| -void PrefService::RegisterFilePathPref(const char* path,
|
| - const FilePath& default_value,
|
| - PrefSyncStatus sync_status) {
|
| - DCHECK(IsProfilePrefService(this));
|
| - RegisterPreference(path,
|
| - Value::CreateStringValue(default_value.value()),
|
| - sync_status);
|
| -}
|
| -
|
| -void PrefService::RegisterListPref(const char* path,
|
| - PrefSyncStatus sync_status) {
|
| - DCHECK(IsProfilePrefService(this));
|
| - RegisterPreference(path, new ListValue(), sync_status);
|
| -}
|
| -
|
| -void PrefService::RegisterListPref(const char* path,
|
| - ListValue* default_value,
|
| - PrefSyncStatus sync_status) {
|
| - DCHECK(IsProfilePrefService(this));
|
| - RegisterPreference(path, default_value, sync_status);
|
| -}
|
| -
|
| -void PrefService::RegisterDictionaryPref(const char* path,
|
| - PrefSyncStatus sync_status) {
|
| - DCHECK(IsProfilePrefService(this));
|
| - RegisterPreference(path, new DictionaryValue(), sync_status);
|
| -}
|
| -
|
| -void PrefService::RegisterDictionaryPref(const char* path,
|
| - DictionaryValue* default_value,
|
| - PrefSyncStatus sync_status) {
|
| - DCHECK(IsProfilePrefService(this));
|
| - RegisterPreference(path, default_value, sync_status);
|
| -}
|
| -
|
| -void PrefService::RegisterLocalizedBooleanPref(const char* path,
|
| - int locale_default_message_id,
|
| - PrefSyncStatus sync_status) {
|
| - DCHECK(IsProfilePrefService(this));
|
| - RegisterPreference(
|
| - path,
|
| - CreateLocaleDefaultValue(
|
| - Value::TYPE_BOOLEAN,
|
| - get_localized_string_method_.Run(locale_default_message_id)),
|
| - sync_status);
|
| -}
|
| -
|
| -void PrefService::RegisterLocalizedIntegerPref(const char* path,
|
| - int locale_default_message_id,
|
| - PrefSyncStatus sync_status) {
|
| - DCHECK(IsProfilePrefService(this));
|
| - RegisterPreference(
|
| - path,
|
| - CreateLocaleDefaultValue(
|
| - Value::TYPE_INTEGER,
|
| - get_localized_string_method_.Run(locale_default_message_id)),
|
| - sync_status);
|
| -}
|
| -
|
| -void PrefService::RegisterLocalizedDoublePref(const char* path,
|
| - int locale_default_message_id,
|
| - PrefSyncStatus sync_status) {
|
| - DCHECK(IsProfilePrefService(this));
|
| - RegisterPreference(
|
| - path,
|
| - CreateLocaleDefaultValue(
|
| - Value::TYPE_DOUBLE,
|
| - get_localized_string_method_.Run(locale_default_message_id)),
|
| - sync_status);
|
| -}
|
| -
|
| -void PrefService::RegisterLocalizedStringPref(const char* path,
|
| - int locale_default_message_id,
|
| - PrefSyncStatus sync_status) {
|
| - DCHECK(IsProfilePrefService(this));
|
| - RegisterPreference(
|
| - path,
|
| - CreateLocaleDefaultValue(
|
| - Value::TYPE_STRING,
|
| - get_localized_string_method_.Run(locale_default_message_id)),
|
| - sync_status);
|
| -}
|
| -
|
| -void PrefService::RegisterInt64Pref(const char* path,
|
| - int64 default_value,
|
| - PrefSyncStatus sync_status) {
|
| - DCHECK(IsProfilePrefService(this));
|
| - RegisterPreference(
|
| - path,
|
| - Value::CreateStringValue(base::Int64ToString(default_value)),
|
| - sync_status);
|
| -}
|
| -
|
| -void PrefService::RegisterUint64Pref(const char* path,
|
| - uint64 default_value,
|
| - PrefSyncStatus sync_status) {
|
| - DCHECK(IsProfilePrefService(this));
|
| - RegisterPreference(
|
| - path,
|
| - Value::CreateStringValue(base::Uint64ToString(default_value)),
|
| - sync_status);
|
| -}
|
| -
|
| bool PrefService::GetBoolean(const char* path) const {
|
| DCHECK(CalledOnValidThread());
|
|
|
| @@ -707,8 +354,7 @@ void PrefService::AddPrefInitObserver(base::Callback<void(bool)> obs) {
|
| }
|
|
|
| void PrefService::RegisterPreference(const char* path,
|
| - Value* default_value,
|
| - PrefSyncStatus sync_status) {
|
| + Value* default_value) {
|
| DCHECK(CalledOnValidThread());
|
|
|
| // The main code path takes ownership, but most don't. We'll be safe.
|
| @@ -739,10 +385,6 @@ void PrefService::RegisterPreference(const char* path,
|
|
|
| // Hand off ownership.
|
| default_store_->SetDefaultValue(path, scoped_value.release());
|
| -
|
| - // Register with sync if necessary.
|
| - if (sync_status == SYNCABLE_PREF && pref_sync_associator_.get())
|
| - pref_sync_associator_->RegisterPref(path);
|
| }
|
|
|
| void PrefService::UnregisterPreference(const char* path) {
|
| @@ -754,10 +396,6 @@ void PrefService::UnregisterPreference(const char* path) {
|
|
|
| prefs_map_.erase(it);
|
| default_store_->RemoveDefaultValue(path);
|
| - if (pref_sync_associator_.get() &&
|
| - pref_sync_associator_->IsPrefRegistered(path)) {
|
| - pref_sync_associator_->UnregisterPref(path);
|
| - }
|
| }
|
|
|
| void PrefService::ClearPref(const char* path) {
|
| @@ -892,14 +530,7 @@ void PrefService::SetUserPrefValue(const char* path, Value* new_value) {
|
| user_pref_store_->SetValue(path, owned_value.release());
|
| }
|
|
|
| -syncer::SyncableService* PrefService::GetSyncableService() {
|
| - return pref_sync_associator_.get();
|
| -}
|
| -
|
| void PrefService::UpdateCommandLinePrefStore(CommandLine* command_line) {
|
| - // If |pref_service_forked_| is true, then this PrefService and the forked
|
| - // copies will be out of sync.
|
| - DCHECK(!pref_service_forked_);
|
| pref_value_store_->UpdateCommandLinePrefStore(
|
| new CommandLinePrefStore(command_line));
|
| }
|
| @@ -997,3 +628,356 @@ const base::Value* PrefService::GetPreferenceValue(
|
| NOTREACHED() << "no valid value found for registered pref " << path;
|
| return NULL;
|
| }
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +void PrefServiceSimple::RegisterBooleanPref(const char* path,
|
| + bool default_value) {
|
| + RegisterPreference(path, Value::CreateBooleanValue(default_value));
|
| +}
|
| +
|
| +void PrefServiceSimple::RegisterIntegerPref(const char* path,
|
| + int default_value) {
|
| + RegisterPreference(path, Value::CreateIntegerValue(default_value));
|
| +}
|
| +
|
| +void PrefServiceSimple::RegisterDoublePref(const char* path,
|
| + double default_value) {
|
| + RegisterPreference(path, Value::CreateDoubleValue(default_value));
|
| +}
|
| +
|
| +void PrefServiceSimple::RegisterStringPref(const char* path,
|
| + const std::string& default_value) {
|
| + RegisterPreference(path, Value::CreateStringValue(default_value));
|
| +}
|
| +
|
| +void PrefServiceSimple::RegisterFilePathPref(const char* path,
|
| + const FilePath& default_value) {
|
| + RegisterPreference(path, Value::CreateStringValue(default_value.value()));
|
| +}
|
| +
|
| +void PrefServiceSimple::RegisterListPref(const char* path) {
|
| + RegisterPreference(path, new ListValue());
|
| +}
|
| +
|
| +void PrefServiceSimple::RegisterListPref(const char* path,
|
| + ListValue* default_value) {
|
| + RegisterPreference(path, default_value);
|
| +}
|
| +
|
| +void PrefServiceSimple::RegisterDictionaryPref(const char* path) {
|
| + RegisterPreference(path, new DictionaryValue());
|
| +}
|
| +
|
| +void PrefServiceSimple::RegisterDictionaryPref(const char* path,
|
| + DictionaryValue* default_value) {
|
| + RegisterPreference(path, default_value);
|
| +}
|
| +
|
| +void PrefServiceSimple::RegisterLocalizedBooleanPref(
|
| + const char* path, int locale_default_message_id) {
|
| + RegisterPreference(
|
| + path,
|
| + CreateLocaleDefaultValue(
|
| + Value::TYPE_BOOLEAN,
|
| + get_localized_string_method_.Run(locale_default_message_id)));
|
| +}
|
| +
|
| +void PrefServiceSimple::RegisterLocalizedIntegerPref(
|
| + const char* path, int locale_default_message_id) {
|
| + RegisterPreference(
|
| + path,
|
| + CreateLocaleDefaultValue(
|
| + Value::TYPE_INTEGER,
|
| + get_localized_string_method_.Run(locale_default_message_id)));
|
| +}
|
| +
|
| +void PrefServiceSimple::RegisterLocalizedDoublePref(
|
| + const char* path, int locale_default_message_id) {
|
| + RegisterPreference(
|
| + path,
|
| + CreateLocaleDefaultValue(
|
| + Value::TYPE_DOUBLE,
|
| + get_localized_string_method_.Run(locale_default_message_id)));
|
| +}
|
| +
|
| +void PrefServiceSimple::RegisterLocalizedStringPref(
|
| + const char* path, int locale_default_message_id) {
|
| + RegisterPreference(
|
| + path,
|
| + CreateLocaleDefaultValue(
|
| + Value::TYPE_STRING,
|
| + get_localized_string_method_.Run(locale_default_message_id)));
|
| +}
|
| +
|
| +void PrefServiceSimple::RegisterInt64Pref(const char* path,
|
| + int64 default_value) {
|
| + RegisterPreference(
|
| + path, Value::CreateStringValue(base::Int64ToString(default_value)));
|
| +}
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +PrefServiceSyncable::PrefServiceSyncable() {
|
| + pref_sync_associator_.SetPrefService(this);
|
| +}
|
| +
|
| +void PrefServiceSyncable::Initialize(
|
| + PrefNotifierImpl* pref_notifier,
|
| + PrefValueStore* pref_value_store,
|
| + PersistentPrefStore* user_prefs,
|
| + DefaultPrefStore* default_store,
|
| + base::Callback<std::string(int)> get_localized_string_method,
|
| + base::Callback<void(PersistentPrefStore::PrefReadError)>
|
| + read_error_callback,
|
| + bool async) {
|
| + PrefService::Initialize(pref_notifier,
|
| + pref_value_store,
|
| + user_prefs,
|
| + default_store,
|
| + get_localized_string_method,
|
| + read_error_callback,
|
| + async);
|
| +
|
| + pref_value_store->set_sync_associator(&pref_sync_associator_);
|
| +}
|
| +
|
| +PrefServiceSyncable::~PrefServiceSyncable() {
|
| +}
|
| +
|
| +PrefServiceSyncable* PrefServiceSyncable::CreateIncognitoPrefService(
|
| + PrefStore* incognito_extension_prefs) {
|
| + pref_service_forked_ = true;
|
| + PrefNotifierImpl* pref_notifier = new PrefNotifierImpl();
|
| + OverlayUserPrefStore* incognito_pref_store =
|
| + new OverlayUserPrefStore(user_pref_store_.get());
|
| + PrefsTabHelper::InitIncognitoUserPrefStore(incognito_pref_store);
|
| + PrefServiceSyncable* incognito_service = new PrefServiceSyncable();
|
| + incognito_service->Initialize(
|
| + pref_notifier,
|
| + pref_value_store_->CloneAndSpecialize(
|
| + NULL, // managed
|
| + incognito_extension_prefs,
|
| + NULL, // command_line_prefs
|
| + incognito_pref_store,
|
| + NULL, // recommended
|
| + default_store_.get(),
|
| + pref_notifier),
|
| + incognito_pref_store,
|
| + default_store_.get(),
|
| + get_localized_string_method_,
|
| + read_error_callback_,
|
| + false);
|
| + return incognito_service;
|
| +}
|
| +
|
| +bool PrefServiceSyncable::IsSyncing() {
|
| + return pref_sync_associator_.models_associated();
|
| +}
|
| +
|
| +void PrefServiceSyncable::AddObserver(PrefServiceObserver* observer) {
|
| + observer_list_.AddObserver(observer);
|
| +}
|
| +
|
| +void PrefServiceSyncable::RemoveObserver(PrefServiceObserver* observer) {
|
| + observer_list_.RemoveObserver(observer);
|
| +}
|
| +
|
| +void PrefServiceSyncable::UnregisterPreference(const char* path) {
|
| + PrefService::UnregisterPreference(path);
|
| + if (pref_sync_associator_.IsPrefRegistered(path)) {
|
| + pref_sync_associator_.UnregisterPref(path);
|
| + }
|
| +}
|
| +
|
| +void PrefServiceSyncable::RegisterBooleanPref(const char* path,
|
| + bool default_value,
|
| + PrefSyncStatus sync_status) {
|
| + RegisterSyncablePreference(path,
|
| + Value::CreateBooleanValue(default_value),
|
| + sync_status);
|
| +}
|
| +
|
| +void PrefServiceSyncable::RegisterIntegerPref(const char* path,
|
| + int default_value,
|
| + PrefSyncStatus sync_status) {
|
| + RegisterSyncablePreference(path,
|
| + Value::CreateIntegerValue(default_value),
|
| + sync_status);
|
| +}
|
| +
|
| +void PrefServiceSyncable::RegisterDoublePref(const char* path,
|
| + double default_value,
|
| + PrefSyncStatus sync_status) {
|
| + RegisterSyncablePreference(path,
|
| + Value::CreateDoubleValue(default_value),
|
| + sync_status);
|
| +}
|
| +
|
| +void PrefServiceSyncable::RegisterStringPref(const char* path,
|
| + const std::string& default_value,
|
| + PrefSyncStatus sync_status) {
|
| + RegisterSyncablePreference(path,
|
| + Value::CreateStringValue(default_value),
|
| + sync_status);
|
| +}
|
| +
|
| +void PrefServiceSyncable::RegisterFilePathPref(const char* path,
|
| + const FilePath& default_value,
|
| + PrefSyncStatus sync_status) {
|
| + RegisterSyncablePreference(path,
|
| + Value::CreateStringValue(default_value.value()),
|
| + sync_status);
|
| +}
|
| +
|
| +void PrefServiceSyncable::RegisterListPref(const char* path,
|
| + PrefSyncStatus sync_status) {
|
| + RegisterSyncablePreference(path, new ListValue(), sync_status);
|
| +}
|
| +
|
| +void PrefServiceSyncable::RegisterListPref(const char* path,
|
| + ListValue* default_value,
|
| + PrefSyncStatus sync_status) {
|
| + RegisterSyncablePreference(path, default_value, sync_status);
|
| +}
|
| +
|
| +void PrefServiceSyncable::RegisterDictionaryPref(const char* path,
|
| + PrefSyncStatus sync_status) {
|
| + RegisterSyncablePreference(path, new DictionaryValue(), sync_status);
|
| +}
|
| +
|
| +void PrefServiceSyncable::RegisterDictionaryPref(const char* path,
|
| + DictionaryValue* default_value,
|
| + PrefSyncStatus sync_status) {
|
| + RegisterSyncablePreference(path, default_value, sync_status);
|
| +}
|
| +
|
| +void PrefServiceSyncable::RegisterLocalizedBooleanPref(
|
| + const char* path,
|
| + int locale_default_message_id,
|
| + PrefSyncStatus sync_status) {
|
| + RegisterSyncablePreference(
|
| + path,
|
| + CreateLocaleDefaultValue(
|
| + Value::TYPE_BOOLEAN,
|
| + get_localized_string_method_.Run(locale_default_message_id)),
|
| + sync_status);
|
| +}
|
| +
|
| +void PrefServiceSyncable::RegisterLocalizedIntegerPref(
|
| + const char* path,
|
| + int locale_default_message_id,
|
| + PrefSyncStatus sync_status) {
|
| + RegisterSyncablePreference(
|
| + path,
|
| + CreateLocaleDefaultValue(
|
| + Value::TYPE_INTEGER,
|
| + get_localized_string_method_.Run(locale_default_message_id)),
|
| + sync_status);
|
| +}
|
| +
|
| +void PrefServiceSyncable::RegisterLocalizedDoublePref(
|
| + const char* path,
|
| + int locale_default_message_id,
|
| + PrefSyncStatus sync_status) {
|
| + RegisterSyncablePreference(
|
| + path,
|
| + CreateLocaleDefaultValue(
|
| + Value::TYPE_DOUBLE,
|
| + get_localized_string_method_.Run(locale_default_message_id)),
|
| + sync_status);
|
| +}
|
| +
|
| +void PrefServiceSyncable::RegisterLocalizedStringPref(
|
| + const char* path,
|
| + int locale_default_message_id,
|
| + PrefSyncStatus sync_status) {
|
| + RegisterSyncablePreference(
|
| + path,
|
| + CreateLocaleDefaultValue(
|
| + Value::TYPE_STRING,
|
| + get_localized_string_method_.Run(locale_default_message_id)),
|
| + sync_status);
|
| +}
|
| +
|
| +void PrefServiceSyncable::RegisterInt64Pref(
|
| + const char* path,
|
| + int64 default_value,
|
| + PrefSyncStatus sync_status) {
|
| + RegisterSyncablePreference(
|
| + path,
|
| + Value::CreateStringValue(base::Int64ToString(default_value)),
|
| + sync_status);
|
| +}
|
| +
|
| +void PrefServiceSyncable::RegisterUint64Pref(
|
| + const char* path,
|
| + uint64 default_value,
|
| + PrefSyncStatus sync_status) {
|
| + RegisterSyncablePreference(
|
| + path,
|
| + Value::CreateStringValue(base::Uint64ToString(default_value)),
|
| + sync_status);
|
| +}
|
| +
|
| +syncer::SyncableService* PrefServiceSyncable::GetSyncableService() {
|
| + return &pref_sync_associator_;
|
| +}
|
| +
|
| +void PrefServiceSyncable::UpdateCommandLinePrefStore(
|
| + CommandLine* command_line) {
|
| + // If |pref_service_forked_| is true, then this PrefService and the forked
|
| + // copies will be out of sync.
|
| + DCHECK(!pref_service_forked_);
|
| + PrefService::UpdateCommandLinePrefStore(command_line);
|
| +}
|
| +
|
| +void PrefServiceSyncable::OnIsSyncingChanged() {
|
| + FOR_EACH_OBSERVER(PrefServiceObserver, observer_list_, OnIsSyncingChanged());
|
| +}
|
| +
|
| +void PrefServiceSyncable::RegisterSyncablePreference(
|
| + const char* path, Value* default_value, PrefSyncStatus sync_status) {
|
| + PrefService::RegisterPreference(path, default_value);
|
| + // Register with sync if necessary.
|
| + if (sync_status == SYNCABLE_PREF)
|
| + pref_sync_associator_.RegisterPref(path);
|
| +}
|
|
|