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

Side by Side Diff: components/autofill/core/browser/autofill_profile_comparator.h

Issue 2864483005: Uses AutofillProfileComparator to compare profile names. (Closed)
Patch Set: Reorder method definitions to match declaration order. Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_COMPARATOR_H_ 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_COMPARATOR_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_COMPARATOR_H_ 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_COMPARATOR_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // been found to be mergeable. 52 // been found to be mergeable.
53 // 53 //
54 // Heuristic: If one name is empty, select the other; othwerwise, attempt to 54 // Heuristic: If one name is empty, select the other; othwerwise, attempt to
55 // parse the names in each profile and determine if one name can be derived 55 // parse the names in each profile and determine if one name can be derived
56 // from the other. For example, J Smith can be derived from John Smith, so 56 // from the other. For example, J Smith can be derived from John Smith, so
57 // prefer the latter. 57 // prefer the latter.
58 bool MergeNames(const AutofillProfile& p1, 58 bool MergeNames(const AutofillProfile& p1,
59 const AutofillProfile& p2, 59 const AutofillProfile& p2,
60 NameInfo* name_info) const; 60 NameInfo* name_info) const;
61 61
62 // Returns true if |full_name_2| is a variant of |full_name_1|.
63 //
64 // This function generates all variations of |full_name_1| and returns true if
65 // one of these variants is equal to |full_name_2|. For example, this function
66 // will return true if |full_name_2| is "john q public" and |full_name_1| is
67 // "john quincy public" because |full_name_2| can be derived from
68 // |full_name_1| by using the middle initial. Note that the reverse is not
69 // true, "john quincy public" is not a name variant of "john q public".
70 //
71 // Note: Expects that |full_name| is already normalized for comparison.
72 bool IsNameVariantOf(const base::string16& full_name_1,
73 const base::string16& full_name_2) const;
74
62 // Populates |email_info| with the result of merging the email addresses in 75 // Populates |email_info| with the result of merging the email addresses in
63 // |p1| and |p2|. Returns true if successful. Expects that |p1| and |p2| have 76 // |p1| and |p2|. Returns true if successful. Expects that |p1| and |p2| have
64 // already been found to be mergeable. 77 // already been found to be mergeable.
65 // 78 //
66 // Heuristic: If one email address is empty, use the other; otherwise, prefer 79 // Heuristic: If one email address is empty, use the other; otherwise, prefer
67 // the most recently used version of the email address. 80 // the most recently used version of the email address.
68 bool MergeEmailAddresses(const AutofillProfile& p1, 81 bool MergeEmailAddresses(const AutofillProfile& p1,
69 const AutofillProfile& p2, 82 const AutofillProfile& p2,
70 EmailInfo* email_info) const; 83 EmailInfo* email_info) const;
71 84
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // function returns the set: 143 // function returns the set:
131 // 144 //
132 // { "", "f", "francois, 145 // { "", "f", "francois,
133 // "j", "j f", "j francois", 146 // "j", "j f", "j francois",
134 // "jean", "jean f", "jean francois", "jf" } 147 // "jean", "jean f", "jean francois", "jf" }
135 // 148 //
136 // Note: Expects that |name| is already normalized for comparison. 149 // Note: Expects that |name| is already normalized for comparison.
137 static std::set<base::string16> GetNamePartVariants( 150 static std::set<base::string16> GetNamePartVariants(
138 const base::string16& name_part); 151 const base::string16& name_part);
139 152
140 // Returns true if |full_name_2| is a variant of |full_name_1|.
141 //
142 // This function generates all variations of |full_name_1| and returns true if
143 // one of these variants is equal to |full_name_2|. For example, this function
144 // will return true if |full_name_2| is "john q public" and |full_name_1| is
145 // "john quincy public" because |full_name_2| can be derived from
146 // |full_name_1| by using the middle initial. Note that the reverse is not
147 // true, "john quincy public" is not a name variant of "john q public".
148 //
149 // Note: Expects that |full_name| is already normalized for comparison.
150 bool IsNameVariantOf(const base::string16& full_name_1,
151 const base::string16& full_name_2) const;
152
153 // Returns true if |p1| and |p2| have names which are equivalent for the 153 // Returns true if |p1| and |p2| have names which are equivalent for the
154 // purposes of merging the two profiles. This means one of the names is 154 // purposes of merging the two profiles. This means one of the names is
155 // empty, the names are the same, or one name is a variation of the other. 155 // empty, the names are the same, or one name is a variation of the other.
156 // The name comparison is insensitive to case, punctuation and diacritics. 156 // The name comparison is insensitive to case, punctuation and diacritics.
157 // 157 //
158 // Note that this method does not provide any guidance on actually merging 158 // Note that this method does not provide any guidance on actually merging
159 // the names. 159 // the names.
160 bool HaveMergeableNames(const AutofillProfile& p1, 160 bool HaveMergeableNames(const AutofillProfile& p1,
161 const AutofillProfile& p2) const; 161 const AutofillProfile& p2) const;
162 162
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 l10n::CaseInsensitiveCompare case_insensitive_compare_; 221 l10n::CaseInsensitiveCompare case_insensitive_compare_;
222 std::unique_ptr<icu::Transliterator> transliterator_; 222 std::unique_ptr<icu::Transliterator> transliterator_;
223 const std::string app_locale_; 223 const std::string app_locale_;
224 224
225 DISALLOW_COPY_AND_ASSIGN(AutofillProfileComparator); 225 DISALLOW_COPY_AND_ASSIGN(AutofillProfileComparator);
226 }; 226 };
227 227
228 } // namespace autofill 228 } // namespace autofill
229 229
230 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_COMPARATOR_H_ 230 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_COMPARATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698