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

Side by Side Diff: components/payments/core/payments_profile_comparator.h

Issue 2884393002: [WebPayments] Adding FilterProfilesForShipping to profile comparator (Closed)
Patch Set: rebase Created 3 years, 6 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 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 // Returns the number of contact fields requested in |options| which are 65 // Returns the number of contact fields requested in |options| which are
66 // nonempty in |profile|. 66 // nonempty in |profile|.
67 int GetContactCompletenessScore( 67 int GetContactCompletenessScore(
68 const autofill::AutofillProfile* profile) const; 68 const autofill::AutofillProfile* profile) const;
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 // Returns profiles for shipping, ordered by completeness. |profiles| should
75 // score with std::sort. 75 // be passed in order of frecency, and this order will be preserved among
76 bool IsContactMoreComplete(const autofill::AutofillProfile* p1, 76 // equally-complete profiles.
77 const autofill::AutofillProfile* p2) const; 77 std::vector<autofill::AutofillProfile*> FilterProfilesForShipping(
78 const std::vector<autofill::AutofillProfile*>& profiles) const;
79
80 int GetShippingCompletenessScore(
81 const autofill::AutofillProfile* profile) const;
82
83 // Returns true iff every field needed to use |profile| as a shipping address
84 // is populated.
85 bool IsShippingComplete(const autofill::AutofillProfile* profile) const;
78 86
79 // Returns a localized string to be displayed in UI indicating what action, 87 // 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. 88 // if any, must be taken for the given profile to be used as contact info.
81 base::string16 GetStringForMissingContactFields( 89 base::string16 GetStringForMissingContactFields(
82 const autofill::AutofillProfile& profile) const; 90 const autofill::AutofillProfile& profile) const;
83 91
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, 92 // 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 93 // if any, must be taken for the given profile to be used as a shipping
90 // address. 94 // address.
91 base::string16 GetStringForMissingShippingFields( 95 base::string16 GetStringForMissingShippingFields(
92 const autofill::AutofillProfile& profile) const; 96 const autofill::AutofillProfile& profile) const;
93 97
94 // Clears the cached evaluation result for |profile|. Must be called when a 98 // Clears the cached evaluation result for |profile|. Must be called when a
95 // profile is modified and saved during the course of a PaymentRequest. 99 // profile is modified and saved during the course of a PaymentRequest.
96 void Invalidate(const autofill::AutofillProfile& profile); 100 void Invalidate(const autofill::AutofillProfile& profile);
97 101
98 private: 102 private:
99 ProfileFields ComputeMissingFields( 103 ProfileFields ComputeMissingFields(
100 const autofill::AutofillProfile& profile) const; 104 const autofill::AutofillProfile& profile) const;
101 ProfileFields GetRequiredProfileFieldsForContact() const; 105 ProfileFields GetRequiredProfileFieldsForContact() const;
102 ProfileFields GetRequiredProfileFieldsForShipping() const; 106 ProfileFields GetRequiredProfileFieldsForShipping() const;
103 base::string16 GetStringForMissingFields(ProfileFields fields) const; 107 base::string16 GetStringForMissingFields(ProfileFields fields) const;
104 bool AreRequiredAddressFieldsPresent( 108 bool AreRequiredAddressFieldsPresent(
105 const autofill::AutofillProfile& profile) const; 109 const autofill::AutofillProfile& profile) const;
110
111 // Comparison functions suitable for sorting profiles by completeness
112 // score with std::sort.
113 bool IsContactMoreComplete(const autofill::AutofillProfile* p1,
114 const autofill::AutofillProfile* p2) const;
115 bool IsShippingMoreComplete(const autofill::AutofillProfile* p1,
116 const autofill::AutofillProfile* p2) const;
117
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_
OLDNEW
« no previous file with comments | « components/payments/content/payment_request_state.cc ('k') | components/payments/core/payments_profile_comparator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698