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

Side by Side Diff: components/payments/content/profile_util.h

Issue 2775553004: [WebPayments] Implementing Profile filter and dedupe (Closed)
Patch Set: Adding omitted files Created 3 years, 9 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 #ifndef COMPONENTS_PAYMENTS_CONTENT_PROFILE_UTIL_H_
5 #define COMPONENTS_PAYMENTS_CONTENT_PROFILE_UTIL_H_
6
7 #include <string>
8 #include <vector>
9
10 #include "components/autofill/core/browser/autofill_profile_comparator.h"
11 #include "components/payments/content/payment_request_spec.h"
12
13 // Utility functions used for processing and filtering profiles.
14 // TODO(tmartino): Remove dependency on PaymentRequestSpec and move to core.
Mathieu 2017/03/24 16:16:02 If it's just for the three requestPayer* bool, I w
tmartino 2017/03/24 16:28:52 One thing anthonyvd and I discussed was potentiall
Mathieu 2017/03/24 16:37:27 I would use the booleans for now and re-evaluate l
tmartino 2017/04/03 16:42:55 Looking at iOS, and talking to mahmadi@, actually
15
16 namespace autofill {
17 class AutofillProfile;
18 } // namespace autofill
19
20 namespace payments {
21 namespace profile_util {
22
23 // Returns profiles for contact info, ordered by completeness and deduplicated.
24 // |profiles| should be passed in order of frecency, and this order will be
25 // preserved among equally-complete profiles. Deduplication here means that
26 // profiles returned are excluded if they are a subset of a more complete or
27 // more frecent profile. Completeness here refers only to the presence of the
28 // fields requested per the request_payer_* fields in |spec|.
29 std::vector<autofill::AutofillProfile*> FilterProfilesForContact(
30 const std::vector<autofill::AutofillProfile*>& profiles,
31 const std::string& app_locale,
32 PaymentRequestSpec* spec);
33
34 // Helper class which evaluates profiles for similarity and completeness.
35 class PaymentsProfileComparator : public autofill::AutofillProfileComparator {
36 public:
37 PaymentsProfileComparator(const std::string& app_locale,
38 PaymentRequestSpec* spec);
39 ~PaymentsProfileComparator();
40
41 // Returns true iff all of the contact info in |sub| also appears in |super|.
42 // Only operates on fields requested in |spec|.
43 bool IsContactEqualOrSuperset(autofill::AutofillProfile* super,
44 autofill::AutofillProfile* sub);
45
46 // Returns the number of contact fields requested in |spec| which are nonempty
47 // in |profile|.
48 int GetContactCompletenessScore(autofill::AutofillProfile* profile);
49
50 // Returns true every contact field requested in |spec| is nonempty in
51 // |profile|.
52 bool IsContactInfoComplete(autofill::AutofillProfile* profile);
53
54 // Comparison function suitable for sorting profiles by contact completeness
55 // score with std::sort.
56 bool CompareContactCompleteness(autofill::AutofillProfile* p1,
Roger McFarlane (Chromium) 2017/03/24 18:23:16 nit: this name doesn't really suggest a boolean re
tmartino 2017/04/03 16:42:54 Done.
57 autofill::AutofillProfile* p2);
58
59 private:
60 PaymentRequestSpec* spec_;
61 };
62
63 } // namespace profile_util
64 } // namespace payments
65
66 #endif // COMPONENTS_PAYMENTS_CONTENT_PROFILE_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698