Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| 5 #ifndef COMPONENTS_PAYMENTS_CONTENT_PROFILE_UTIL_H_ | |
| 6 #define COMPONENTS_PAYMENTS_CONTENT_PROFILE_UTIL_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "components/autofill/core/browser/autofill_profile_comparator.h" | |
| 12 | |
| 13 // Utility functions used for processing and filtering profiles. | |
|
Mathieu
2017/04/03 19:11:53
*address profiles (AutofillProfile)
tmartino
2017/04/04 21:00:22
Done
| |
| 14 | |
| 15 namespace autofill { | |
| 16 class AutofillProfile; | |
| 17 } // namespace autofill | |
| 18 | |
| 19 namespace payments { | |
| 20 | |
| 21 class PaymentOptionsProvider; | |
| 22 | |
| 23 namespace profile_util { | |
| 24 | |
| 25 // Returns profiles for contact info, ordered by completeness and deduplicated. | |
| 26 // |profiles| should be passed in order of frecency, and this order will be | |
| 27 // preserved among equally-complete profiles. Deduplication here means that | |
| 28 // profiles returned are excluded if they are a subset of a more complete or | |
| 29 // more frecent profile. Completeness here refers only to the presence of the | |
| 30 // fields requested per the request_payer_* fields in |options|. | |
| 31 std::vector<autofill::AutofillProfile*> FilterProfilesForContact( | |
| 32 const std::vector<autofill::AutofillProfile*>& profiles, | |
| 33 const std::string& app_locale, | |
| 34 PaymentOptionsProvider* options); | |
|
Mathieu
2017/04/03 19:11:53
can this be const PaymentOptionsProvider& options?
tmartino
2017/04/04 21:00:22
I'm open to it. However, my search found lots of e
Mathieu
2017/04/05 13:43:10
The difference is that there are non-const methods
| |
| 35 | |
| 36 // Helper class which evaluates profiles for similarity and completeness. | |
| 37 class PaymentsProfileComparator : public autofill::AutofillProfileComparator { | |
| 38 public: | |
| 39 PaymentsProfileComparator(const std::string& app_locale, | |
| 40 PaymentOptionsProvider* options); | |
|
Mathieu
2017/04/03 19:11:53
same
| |
| 41 ~PaymentsProfileComparator(); | |
| 42 | |
| 43 // Returns true iff all of the contact info in |sub| also appears in |super|. | |
| 44 // Only operates on fields requested in |options|. | |
| 45 bool IsContactEqualOrSuperset(autofill::AutofillProfile* super, | |
| 46 autofill::AutofillProfile* sub); | |
| 47 | |
| 48 // Returns the number of contact fields requested in |options| which are | |
| 49 // nonempty in |profile|. | |
| 50 int GetContactCompletenessScore(autofill::AutofillProfile* profile); | |
| 51 | |
| 52 // Returns true every contact field requested in |options| is nonempty in | |
| 53 // |profile|. | |
| 54 bool IsContactInfoComplete(autofill::AutofillProfile* profile); | |
| 55 | |
| 56 // Comparison function suitable for sorting profiles by contact completeness | |
| 57 // score with std::sort. | |
| 58 bool IsContactMoreComplete(autofill::AutofillProfile* p1, | |
| 59 autofill::AutofillProfile* p2); | |
| 60 | |
| 61 private: | |
| 62 PaymentOptionsProvider* options_; | |
| 63 }; | |
| 64 | |
| 65 } // namespace profile_util | |
| 66 } // namespace payments | |
| 67 | |
| 68 #endif // COMPONENTS_PAYMENTS_CONTENT_PROFILE_UTIL_H_ | |
| OLD | NEW |