OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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_PAYMENTS_CORE_PAYMENTS_PROFILE_COMPARATOR_H_ | 5 #ifndef COMPONENTS_PAYMENTS_CORE_PAYMENTS_PROFILE_COMPARATOR_H_ |
6 #define COMPONENTS_PAYMENTS_CORE_PAYMENTS_PROFILE_COMPARATOR_H_ | 6 #define COMPONENTS_PAYMENTS_CORE_PAYMENTS_PROFILE_COMPARATOR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 | 69 |
70 // Returns true iff every contact field requested in |options| is nonempty in | 70 // Returns true iff every contact field requested in |options| is nonempty in |
71 // |profile|. | 71 // |profile|. |
72 bool IsContactInfoComplete(const autofill::AutofillProfile* profile) const; | 72 bool IsContactInfoComplete(const autofill::AutofillProfile* profile) const; |
73 | 73 |
74 // Comparison function suitable for sorting profiles by contact completeness | 74 // Comparison function suitable for sorting profiles by contact completeness |
75 // score with std::sort. | 75 // score with std::sort. |
76 bool IsContactMoreComplete(const autofill::AutofillProfile* p1, | 76 bool IsContactMoreComplete(const autofill::AutofillProfile* p1, |
77 const autofill::AutofillProfile* p2) const; | 77 const autofill::AutofillProfile* p2) const; |
78 | 78 |
79 // Returns profiles for shipping, ordered by completeness. |profiles| should | |
80 // be passed in order of frecency, and this order will be preserved among | |
81 // equally-complete profiles. | |
82 std::vector<autofill::AutofillProfile*> FilterProfilesForShipping( | |
83 const std::vector<autofill::AutofillProfile*>& profiles) const; | |
84 | |
85 int GetShippingCompletenessScore( | |
Mathieu
2017/05/16 20:16:51
can some of these functions be private?
tmartino
2017/05/18 20:49:37
FilterProfilesForShipping: used by State
GetShippi
| |
86 const autofill::AutofillProfile* profile) const; | |
87 | |
88 // Returns true iff every field needed to use |profile| as a shipping address | |
89 // is populated. | |
90 bool IsShippingComplete(const autofill::AutofillProfile* profile) const; | |
91 | |
92 bool IsShippingMoreComplete(const autofill::AutofillProfile* p1, | |
93 const autofill::AutofillProfile* p2) const; | |
94 | |
79 // Returns a localized string to be displayed in UI indicating what action, | 95 // Returns a localized string to be displayed in UI indicating what action, |
80 // if any, must be taken for the given profile to be used as contact info. | 96 // if any, must be taken for the given profile to be used as contact info. |
81 base::string16 GetStringForMissingContactFields( | 97 base::string16 GetStringForMissingContactFields( |
82 const autofill::AutofillProfile& profile) const; | 98 const autofill::AutofillProfile& profile) const; |
83 | 99 |
84 // Returns true iff every field needed to use |profile| as a shipping address | |
85 // is populated. | |
86 bool IsShippingComplete(const autofill::AutofillProfile* profile) const; | |
87 | |
88 // Returns a localized string to be displayed in UI indicating what action, | 100 // Returns a localized string to be displayed in UI indicating what action, |
89 // if any, must be taken for the given profile to be used as a shipping | 101 // if any, must be taken for the given profile to be used as a shipping |
90 // address. | 102 // address. |
91 base::string16 GetStringForMissingShippingFields( | 103 base::string16 GetStringForMissingShippingFields( |
92 const autofill::AutofillProfile& profile) const; | 104 const autofill::AutofillProfile& profile) const; |
93 | 105 |
94 // Clears the cached evaluation result for |profile|. Must be called when a | 106 // Clears the cached evaluation result for |profile|. Must be called when a |
95 // profile is modified and saved during the course of a PaymentRequest. | 107 // profile is modified and saved during the course of a PaymentRequest. |
96 void Invalidate(const autofill::AutofillProfile& profile); | 108 void Invalidate(const autofill::AutofillProfile& profile); |
97 | 109 |
98 private: | 110 private: |
99 ProfileFields ComputeMissingFields( | 111 ProfileFields ComputeMissingFields( |
100 const autofill::AutofillProfile& profile) const; | 112 const autofill::AutofillProfile& profile) const; |
101 ProfileFields GetRequiredProfileFieldsForContact() const; | 113 ProfileFields GetRequiredProfileFieldsForContact() const; |
102 ProfileFields GetRequiredProfileFieldsForShipping() const; | 114 ProfileFields GetRequiredProfileFieldsForShipping() const; |
103 base::string16 GetStringForMissingFields(ProfileFields fields) const; | 115 base::string16 GetStringForMissingFields(ProfileFields fields) const; |
104 bool AreRequiredAddressFieldsPresent( | 116 bool AreRequiredAddressFieldsPresent( |
105 const autofill::AutofillProfile& profile) const; | 117 const autofill::AutofillProfile& profile) const; |
106 mutable std::map<std::string, ProfileFields> cache_; | 118 mutable std::map<std::string, ProfileFields> cache_; |
107 const PaymentOptionsProvider& options_; | 119 const PaymentOptionsProvider& options_; |
108 }; | 120 }; |
109 | 121 |
110 } // namespace payments | 122 } // namespace payments |
111 | 123 |
112 #endif // COMPONENTS_PAYMENTS_CORE_PAYMENTS_PROFILE_COMPARATOR_H_ | 124 #endif // COMPONENTS_PAYMENTS_CORE_PAYMENTS_PROFILE_COMPARATOR_H_ |
OLD | NEW |