| Index: components/autofill/core/browser/autofill_profile_comparator.cc
|
| diff --git a/components/autofill/core/browser/autofill_profile_comparator.cc b/components/autofill/core/browser/autofill_profile_comparator.cc
|
| index ee70468ff2c802adaaa5478a8cc746842a74e409..d4c500308a85a77b669e972a8e9d4aae67e4b97c 100644
|
| --- a/components/autofill/core/browser/autofill_profile_comparator.cc
|
| +++ b/components/autofill/core/browser/autofill_profile_comparator.cc
|
| @@ -364,6 +364,8 @@ bool AutofillProfileComparator::MergeAddresses(const AutofillProfile& p1,
|
| app_locale_);
|
| }
|
|
|
| + AddressRewriter rewriter = AddressRewriter::ForCountryCode(country_code);
|
| +
|
| // One of the cities is empty or one of the cities has a subset of tokens from
|
| // the other. Pick the city name with more tokens; this is usually the most
|
| // explicit one.
|
| @@ -375,9 +377,11 @@ bool AutofillProfileComparator::MergeAddresses(const AutofillProfile& p1,
|
| } else if (city2.empty()) {
|
| address->SetInfo(kCity, city1, app_locale_);
|
| } else {
|
| - // Prefer the one with more tokens.
|
| - CompareTokensResult result = CompareTokens(NormalizeForComparison(city1),
|
| - NormalizeForComparison(city2));
|
| + // Prefer the one with more tokens, making sure to apply address
|
| + // normalization and rewriting before doing the comparison.
|
| + CompareTokensResult result =
|
| + CompareTokens(rewriter.Rewrite(NormalizeForComparison(city1)),
|
| + rewriter.Rewrite(NormalizeForComparison(city2)));
|
| switch (result) {
|
| case SAME_TOKENS:
|
| // They have the same set of unique tokens. Let's pick the more recently
|
| @@ -422,9 +426,11 @@ bool AutofillProfileComparator::MergeAddresses(const AutofillProfile& p1,
|
| address->SetInfo(kStreetAddress, address2, app_locale_);
|
| } else {
|
| // Prefer the one with more tokens if they're both single-line or both
|
| - // multi-line addresses.
|
| - CompareTokensResult result = CompareTokens(
|
| - NormalizeForComparison(address1), NormalizeForComparison(address2));
|
| + // multi-line addresses, making sure to apply address normalization and
|
| + // rewriting before doing the comparison.
|
| + CompareTokensResult result =
|
| + CompareTokens(rewriter.Rewrite(NormalizeForComparison(address1)),
|
| + rewriter.Rewrite(NormalizeForComparison(address2)));
|
| switch (result) {
|
| case SAME_TOKENS:
|
| // They have the same set of unique tokens. Let's pick the one that's
|
|
|