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

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

Issue 2088443002: Expand autofill profile merge logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/autofill_profile_comparator.h
diff --git a/components/autofill/core/browser/autofill_profile_comparator.h b/components/autofill/core/browser/autofill_profile_comparator.h
index cdb1533552e4ec23a29f21d6698f6a31f0c6a718..7cf069e0e1bbca8fe22b236b964e30c48366dc2e 100644
--- a/components/autofill/core/browser/autofill_profile_comparator.h
+++ b/components/autofill/core/browser/autofill_profile_comparator.h
@@ -10,7 +10,9 @@
#include "base/strings/string16.h"
#include "base/strings/string_piece.h"
+#include "components/autofill/core/browser/address.h"
#include "components/autofill/core/browser/autofill_profile.h"
+#include "components/autofill/core/browser/contact_info.h"
#include "components/autofill/core/common/autofill_l10n_util.h"
#include "third_party/icu/source/i18n/unicode/translit.h"
@@ -45,13 +47,36 @@ class AutofillProfileComparator {
// incorporate data from both profiles.
bool AreMergeable(const AutofillProfile& p1, const AutofillProfile& p2) const;
+ // Populates |name_info| with the result of merging the names in |p1| and
+ // |p2|. Returns true if successful. Expects that |p1| and |p2| have already
+ // been found to be mergeable.
+ bool MergeNames(const AutofillProfile& p1,
+ const AutofillProfile& p2,
+ NameInfo* name_info) const;
+
+ // Populates |address| with the result of merging the addresses in |p1| and
+ // |p2|. Returns true if successful. Expects that |p1| and |p2| have already
+ // been found to be mergeable.
+ bool MergeAddresses(const AutofillProfile& p1,
+ const AutofillProfile& p2,
+ Address* address) const;
+
protected:
+ // The result type returned by CompareTokens.
+ enum CompareTokensResult {
+ DIFFERENT_TOKENS,
+ SAME_TOKENS,
+ S1_CONTAINS_S2,
+ S2_CONTAINS_S1,
+ };
+
// Returns the set of unique tokens in |s|. Note that the string data backing
// |s| is expected to have a lifetime which exceeds the call to UniqueTokens.
static std::set<base::StringPiece16> UniqueTokens(base::StringPiece16 s);
- // Returns true if all of the tokens in |s1| are in |s2| or vice versa.
- static bool HaveSameTokens(base::StringPiece16 s1, base::StringPiece16 s2);
+ // Compares the unique tokens in s1 and s2.
+ static CompareTokensResult CompareTokens(base::StringPiece16 s1,
+ base::StringPiece16 s2);
// Generate the set of full/initial variants for |name_part|, where
// |name_part| is the user's first or middle name. For example, given "jean

Powered by Google App Engine
This is Rietveld 408576698