Chromium Code Reviews| 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..807802c67831d8e15cc85225867b7379a6e3f75c 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,64 @@ 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. |
|
tmartino
2016/06/27 17:56:46
Can you add a brief description to these docs of t
Roger McFarlane (Chromium)
2016/06/28 17:26:47
Done.
|
| + bool MergeNames(const AutofillProfile& p1, |
| + const AutofillProfile& p2, |
| + NameInfo* name_info) const; |
| + |
| + // Populates |email_info| with the result of merging the email addresses in |
| + // |p1| and |p2|. Returns true if successful. Expects that |p1| and |p2| have |
| + // already been found to be mergeable. |
| + bool MergeEmailAddresses(const AutofillProfile& p1, |
| + const AutofillProfile& p2, |
| + EmailInfo* email_info) const; |
| + |
| + // Populates |company_info| with the result of merging the company names in |
| + // |p1| and |p2|. Returns true if successful. Expects that |p1| and |p2| have |
| + // already been found to be mergeable. |
| + bool MergeCompanyNames(const AutofillProfile& p1, |
| + const AutofillProfile& p2, |
| + CompanyInfo* company_info) const; |
| + |
| + // Populates |phone_number| with the result of merging the phone numbers in |
| + // |p1| and |p2|. Returns true if successful. Expects that |p1| and |p2| have |
| + // already been found to be mergeable. |
| + bool MergePhoneNumbers(const AutofillProfile& p1, |
| + const AutofillProfile& p2, |
| + PhoneNumber* phone_number) 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); |
| + |
| + // Returns the value of |t| from |p1| or |p2| depending on which is non-empty. |
| + // This method expects that the value is either the same in |p1| or |p2| or |
|
tmartino
2016/06/27 17:56:46
nit: Should this read "either the same in |p1| AND
Roger McFarlane (Chromium)
2016/06/28 17:26:47
Done.
|
| + // empty in one of them. |
| + base::string16 GetNonEmptyOf(const AutofillProfile& p1, |
| + const AutofillProfile& p2, |
| + AutofillType t) const; |
| // 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 |