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

Unified Diff: components/autofill/core/browser/webdata/autofill_profile_syncable_service.cc

Issue 212873003: Store the language code for the address in autofill profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 6 years, 8 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: components/autofill/core/browser/webdata/autofill_profile_syncable_service.cc
diff --git a/components/autofill/core/browser/webdata/autofill_profile_syncable_service.cc b/components/autofill/core/browser/webdata/autofill_profile_syncable_service.cc
index 5baf5566b77c4b6ba794d4d7632f8b526076fdbf..ba1f3006a391b33de29fe335af28289491ef31d6 100644
--- a/components/autofill/core/browser/webdata/autofill_profile_syncable_service.cc
+++ b/components/autofill/core/browser/webdata/autofill_profile_syncable_service.cc
@@ -316,7 +316,7 @@ bool AutofillProfileSyncableService::OverwriteProfileWithServerData(
AutofillProfile* profile,
const std::string& app_locale) {
bool diff = false;
- if (profile->origin() != specifics.origin()) {
+ if (specifics.has_origin() && profile->origin() != specifics.origin()) {
bool was_verified = profile->IsVerified();
profile->set_origin(specifics.origin());
diff = true;
@@ -374,6 +374,15 @@ bool AutofillProfileSyncableService::OverwriteProfileWithServerData(
diff = UpdateField(ADDRESS_HOME_LINE2,
specifics.address_home_line2(), profile) || diff;
}
+
+ // Update the BCP 47 language code that can be used to format the address for
+ // display.
+ if (specifics.has_address_home_language_code() &&
+ specifics.address_home_language_code() != profile->language_code()) {
+ profile->set_language_code(specifics.address_home_language_code());
+ diff = true;
+ }
+
return diff;
}
@@ -431,6 +440,7 @@ void AutofillProfileSyncableService::WriteAutofillProfile(
specifics->set_address_home_dependent_locality(
LimitData(
UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY))));
+ specifics->set_address_home_language_code(LimitData(profile.language_code()));
profile.GetRawMultiInfo(EMAIL_ADDRESS, &values);
for (size_t i = 0; i < values.size(); ++i) {
@@ -486,12 +496,12 @@ AutofillProfileSyncableService::CreateOrUpdateProfile(
autofill_specifics.guid(), autofill_specifics.origin());
OverwriteProfileWithServerData(autofill_specifics, new_profile, app_locale_);
- // Check if profile appears under a different guid.
+ // Check if profile appears under a different guid or with a different origin.
// Unverified profiles should never overwrite verified ones.
for (GUIDToProfileMap::iterator it = profile_map->begin();
it != profile_map->end(); ++it) {
AutofillProfile* local_profile = it->second;
- if (local_profile->Compare(*new_profile) == 0) {
+ if (local_profile->EqualsSansGuidAndOrigin(*new_profile)) {
Ilya Sherman 2014/04/09 23:17:49 Hmm, I think this probably should still be Compare
please use gerrit instead 2014/04/09 23:43:58 True. We wouldn't want multiple profiles for the s
// Ensure that a verified profile can never revert back to an unverified
// one.
if (local_profile->IsVerified() && !new_profile->IsVerified()) {
@@ -625,9 +635,10 @@ bool AutofillProfileSyncableService::MergeProfile(
const AutofillProfile& merge_from,
AutofillProfile* merge_into,
const std::string& app_locale) {
+ // Overwrites all single values and adds to mutli-values. Does not overwrite
+ // GUID.
merge_into->OverwriteWithOrAddTo(merge_from, app_locale);
- return (merge_into->Compare(merge_from) != 0 ||
- merge_into->origin() != merge_from.origin());
+ return !merge_into->EqualsSansGuid(merge_from);
}
AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const {

Powered by Google App Engine
This is Rietveld 408576698