| Index: chrome/browser/webdata/autofill_profile_syncable_service.cc
|
| diff --git a/chrome/browser/webdata/autofill_profile_syncable_service.cc b/chrome/browser/webdata/autofill_profile_syncable_service.cc
|
| index 60b73b5b522327ea3c75dc94d6e64c98279188f4..9e573745b7da75e7897701fb51ea03b5858c7282 100644
|
| --- a/chrome/browser/webdata/autofill_profile_syncable_service.cc
|
| +++ b/chrome/browser/webdata/autofill_profile_syncable_service.cc
|
| @@ -319,6 +319,15 @@ bool AutofillProfileSyncableService::OverwriteProfileWithServerData(
|
| AutofillProfile* profile,
|
| const std::string& app_locale) {
|
| bool diff = false;
|
| + if (profile->origin() != specifics.origin()) {
|
| + bool was_verified = profile->IsVerified();
|
| + profile->set_origin(specifics.origin());
|
| + diff = true;
|
| +
|
| + // Verified profiles should never be overwritten by unverified ones.
|
| + DCHECK(!was_verified || profile->IsVerified());
|
| + }
|
| +
|
| diff = UpdateMultivaluedField(autofill::NAME_FIRST,
|
| specifics.name_first(), profile) || diff;
|
| diff = UpdateMultivaluedField(autofill::NAME_MIDDLE,
|
| @@ -368,6 +377,8 @@ void AutofillProfileSyncableService::WriteAutofillProfile(
|
| specifics->clear_phone_home_whole_number();
|
|
|
| specifics->set_guid(profile.guid());
|
| + specifics->set_origin(profile.origin());
|
| +
|
| std::vector<string16> values;
|
| profile.GetRawMultiInfo(autofill::NAME_FIRST, &values);
|
| for (size_t i = 0; i < values.size(); ++i) {
|
| @@ -445,16 +456,23 @@ AutofillProfileSyncableService::CreateOrUpdateProfile(
|
| }
|
| } else {
|
| // New profile synced.
|
| - // TODO(isherman): Read the origin from |autofill_specifics|.
|
| - AutofillProfile* new_profile(
|
| - new AutofillProfile(autofill_specifics.guid(), std::string()));
|
| + AutofillProfile* new_profile = new AutofillProfile(
|
| + autofill_specifics.guid(), autofill_specifics.origin());
|
| OverwriteProfileWithServerData(
|
| autofill_specifics, new_profile, app_locale_);
|
|
|
| // Check if profile appears under a different guid.
|
| + // Unverified profiles should never overwrite verified ones.
|
| for (GUIDToProfileMap::iterator i = profile_map->begin();
|
| i != profile_map->end(); ++i) {
|
| if (i->second->Compare(*new_profile) == 0) {
|
| + // Ensure that a verified profile can never revert back to an unverified
|
| + // one.
|
| + if (i->second->IsVerified() && !new_profile->IsVerified()) {
|
| + new_profile->set_origin(i->second->origin());
|
| + bundle->profiles_to_sync_back.push_back(new_profile);
|
| + }
|
| +
|
| bundle->profiles_to_delete.push_back(i->second->guid());
|
| DVLOG(2) << "[AUTOFILL SYNC]"
|
| << "Found in sync db but with a different guid: "
|
| @@ -464,7 +482,9 @@ AutofillProfileSyncableService::CreateOrUpdateProfile(
|
| << ". Profile to be deleted " << i->second->guid();
|
| profile_map->erase(i);
|
| break;
|
| - } else if (!i->second->PrimaryValue().empty() &&
|
| + } else if (!i->second->IsVerified() &&
|
| + !new_profile->IsVerified() &&
|
| + !i->second->PrimaryValue().empty() &&
|
| i->second->PrimaryValue() == new_profile->PrimaryValue()) {
|
| // Add it to candidates for merge - if there is no profile with this
|
| // guid we will merge them.
|
| @@ -581,8 +601,11 @@ bool AutofillProfileSyncableService::MergeProfile(
|
| const AutofillProfile& merge_from,
|
| AutofillProfile* merge_into,
|
| const std::string& app_locale) {
|
| + DCHECK(!merge_into->IsVerified() || merge_from.IsVerified());
|
| + merge_into->set_origin(merge_from.origin());
|
| merge_into->OverwriteWithOrAddTo(merge_from, app_locale);
|
| - return (merge_into->Compare(merge_from) != 0);
|
| + return (merge_into->Compare(merge_from) != 0 ||
|
| + merge_into->origin() != merge_from.origin());
|
| }
|
|
|
| AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const {
|
|
|