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

Unified Diff: components/autofill/core/browser/autofill_profile_comparator.cc

Issue 2130873002: Use AddressRewriter when merging autofill profile addresses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_profile_comparator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_profile_comparator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698