Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4164)

Unified Diff: chrome/browser/prefs/pref_model_associator.cc

Issue 444763005: Clear a preference when sync tries to delete a preference (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/prefs/pref_model_associator.cc
diff --git a/chrome/browser/prefs/pref_model_associator.cc b/chrome/browser/prefs/pref_model_associator.cc
index bcf87eae3940054d6e437bfa7e327325cb99a16c..5ddbf1fbb937b8b7a3451b0e7255c7e144ec9b23 100644
--- a/chrome/browser/prefs/pref_model_associator.cc
+++ b/chrome/browser/prefs/pref_model_associator.cc
@@ -471,26 +471,10 @@ syncer::SyncError PrefModelAssociator::ProcessSyncChanges(
for (iter = change_list.begin(); iter != change_list.end(); ++iter) {
DCHECK_EQ(type_, iter->sync_data().GetDataType());
- std::string name;
const sync_pb::PreferenceSpecifics& pref_specifics =
GetSpecifics(iter->sync_data());
- scoped_ptr<base::Value> value(ReadPreferenceSpecifics(pref_specifics,
- &name));
-
- if (iter->change_type() == syncer::SyncChange::ACTION_DELETE) {
- // We never delete preferences.
- NOTREACHED() << "Attempted to process sync delete change for " << name
- << ". Skipping.";
- continue;
- }
-
- // Skip values we can't deserialize.
- // TODO(zea): consider taking some further action such as erasing the bad
- // data.
- if (!value.get())
- continue;
-
+ std::string name = pref_specifics.name();
// It is possible that we may receive a change to a preference we do not
// want to sync. For example if the user is syncing a Mac client and a
// Windows client, the Windows client does not support
@@ -506,9 +490,18 @@ syncer::SyncError PrefModelAssociator::ProcessSyncChanges(
if (!IsPrefRegistered(pref_name))
continue;
- const PrefService::Preference* pref =
- pref_service_->FindPreference(pref_name);
- DCHECK(pref);
+ if (iter->change_type() == syncer::SyncChange::ACTION_DELETE) {
+ pref_service_->ClearPref(pref_name);
+ continue;
+ }
+
+ scoped_ptr<base::Value> value(ReadPreferenceSpecifics(pref_specifics));
+ if (!value.get()) {
+ // Skip values we can't deserialize.
+ // TODO(zea): consider taking some further action such as erasing the bad
+ // data.
+ continue;
+ }
// This will only modify the user controlled value store, which takes
// priority over the default value but is ignored if the preference is
@@ -526,8 +519,7 @@ syncer::SyncError PrefModelAssociator::ProcessSyncChanges(
}
base::Value* PrefModelAssociator::ReadPreferenceSpecifics(
- const sync_pb::PreferenceSpecifics& preference,
- std::string* name) {
+ const sync_pb::PreferenceSpecifics& preference) {
base::JSONReader reader;
scoped_ptr<base::Value> value(reader.ReadToValue(preference.value()));
if (!value.get()) {
@@ -536,7 +528,6 @@ base::Value* PrefModelAssociator::ReadPreferenceSpecifics(
LOG(ERROR) << err;
return NULL;
}
- *name = preference.name();
return value.release();
}
« no previous file with comments | « chrome/browser/prefs/pref_model_associator.h ('k') | chrome/browser/prefs/prefs_syncable_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698