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

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

Issue 2110563002: Use AutofillProfileComparator in place of ad-hoc merge logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@merge
Patch Set: Rebase Created 4 years, 6 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/address.cc
diff --git a/components/autofill/core/browser/address.cc b/components/autofill/core/browser/address.cc
index ef76286ca461e2053716ec99fa77f9eb9d826e4f..813d61556914a761913f715715e3ee06bed498b5 100644
--- a/components/autofill/core/browser/address.cc
+++ b/components/autofill/core/browser/address.cc
@@ -14,6 +14,7 @@
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/autofill_profile.h"
+#include "components/autofill/core/browser/autofill_profile_comparator.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/country_names.h"
#include "components/autofill/core/browser/state_names.h"
@@ -43,6 +44,16 @@ Address& Address::operator=(const Address& address) {
return *this;
}
+bool Address::operator==(const Address& other) const {
+ if (this == &other)
+ return true;
+ return street_address_ == other.street_address_ &&
+ dependent_locality_ == other.dependent_locality_ &&
+ city_ == other.city_ && state_ == other.state_ &&
+ zip_code_ == other.zip_code_ && sorting_code_ == other.sorting_code_ &&
+ country_code_ == other.country_code_;
+}
+
base::string16 Address::GetRawInfo(ServerFieldType type) const {
DCHECK_EQ(ADDRESS_HOME, AutofillType(type).group());
switch (type) {
@@ -76,8 +87,11 @@ base::string16 Address::GetRawInfo(ServerFieldType type) const {
case ADDRESS_HOME_STREET_ADDRESS:
return base::JoinString(street_address_, base::ASCIIToUTF16("\n"));
+ case ADDRESS_HOME_APT_NUM:
+ return base::string16();
+
default:
- NOTREACHED();
+ NOTREACHED() << "Unrecognized type: " << type;
return base::string16();
}
}
@@ -202,9 +216,10 @@ void Address::GetMatchingTypes(const base::string16& text,
if (!country_code.empty() && country_code_ == country_code)
matching_types->insert(ADDRESS_HOME_COUNTRY);
+ AutofillProfileComparator comparator(app_locale);
// Check to see if the |text| could be the full name or abbreviation of a
// state.
- base::string16 canon_text = AutofillProfile::CanonicalizeProfileString(text);
+ base::string16 canon_text = comparator.NormalizeForComparison(text);
base::string16 state_name;
base::string16 state_abbreviation;
state_names::GetNameAndAbbreviation(canon_text, &state_name,
@@ -212,7 +227,7 @@ void Address::GetMatchingTypes(const base::string16& text,
if (!state_name.empty() || !state_abbreviation.empty()) {
l10n::CaseInsensitiveCompare compare;
base::string16 canon_profile_state =
- AutofillProfile::CanonicalizeProfileString(
+ comparator.NormalizeForComparison(
GetInfo(AutofillType(ADDRESS_HOME_STATE), app_locale));
if ((!state_name.empty() &&
compare.StringsEqual(state_name, canon_profile_state)) ||
« no previous file with comments | « components/autofill/core/browser/address.h ('k') | components/autofill/core/browser/autofill_merge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698