| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 const autofill::AutofillProfile& profile) const; | 90 const autofill::AutofillProfile& profile) const; |
| 91 | 91 |
| 92 // 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, |
| 93 // 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 |
| 94 // address. | 94 // address. |
| 95 base::string16 GetStringForMissingShippingFields( | 95 base::string16 GetStringForMissingShippingFields( |
| 96 const autofill::AutofillProfile& profile) const; | 96 const autofill::AutofillProfile& profile) const; |
| 97 | 97 |
| 98 // 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 |
| 99 // profile is modified and saved during the course of a PaymentRequest. | 99 // profile is modified and saved during the course of a PaymentRequest. |
| 100 void Invalidate(const autofill::AutofillProfile& profile); | 100 virtual void Invalidate(const autofill::AutofillProfile& profile); |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 ProfileFields ComputeMissingFields( | 103 ProfileFields ComputeMissingFields( |
| 104 const autofill::AutofillProfile& profile) const; | 104 const autofill::AutofillProfile& profile) const; |
| 105 ProfileFields GetRequiredProfileFieldsForContact() const; | 105 ProfileFields GetRequiredProfileFieldsForContact() const; |
| 106 ProfileFields GetRequiredProfileFieldsForShipping() const; | 106 ProfileFields GetRequiredProfileFieldsForShipping() const; |
| 107 base::string16 GetStringForMissingFields(ProfileFields fields) const; | 107 base::string16 GetStringForMissingFields(ProfileFields fields) const; |
| 108 bool AreRequiredAddressFieldsPresent( | 108 bool AreRequiredAddressFieldsPresent( |
| 109 const autofill::AutofillProfile& profile) const; | 109 const autofill::AutofillProfile& profile) const; |
| 110 | 110 |
| 111 // Comparison functions suitable for sorting profiles by completeness | 111 // Comparison functions suitable for sorting profiles by completeness |
| 112 // score with std::sort. | 112 // score with std::sort. |
| 113 bool IsContactMoreComplete(const autofill::AutofillProfile* p1, | 113 bool IsContactMoreComplete(const autofill::AutofillProfile* p1, |
| 114 const autofill::AutofillProfile* p2) const; | 114 const autofill::AutofillProfile* p2) const; |
| 115 bool IsShippingMoreComplete(const autofill::AutofillProfile* p1, | 115 bool IsShippingMoreComplete(const autofill::AutofillProfile* p1, |
| 116 const autofill::AutofillProfile* p2) const; | 116 const autofill::AutofillProfile* p2) const; |
| 117 | 117 |
| 118 mutable std::map<std::string, ProfileFields> cache_; | 118 mutable std::map<std::string, ProfileFields> cache_; |
| 119 const PaymentOptionsProvider& options_; | 119 const PaymentOptionsProvider& options_; |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 } // namespace payments | 122 } // namespace payments |
| 123 | 123 |
| 124 #endif // COMPONENTS_PAYMENTS_CORE_PAYMENTS_PROFILE_COMPARATOR_H_ | 124 #endif // COMPONENTS_PAYMENTS_CORE_PAYMENTS_PROFILE_COMPARATOR_H_ |
| OLD | NEW |