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

Unified Diff: components/payments/core/payments_profile_comparator.cc

Issue 2897133002: Revert of [WebPayments] Adding FilterProfilesForShipping to profile comparator (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/payments/core/payments_profile_comparator.cc
diff --git a/components/payments/core/payments_profile_comparator.cc b/components/payments/core/payments_profile_comparator.cc
index e29576236aa5f4b7a986e4e464174059018ea043..832e005dd9d2494fcd28cba5033aa4daef1f8d73 100644
--- a/components/payments/core/payments_profile_comparator.cc
+++ b/components/payments/core/payments_profile_comparator.cc
@@ -118,6 +118,9 @@
int PaymentsProfileComparator::GetContactCompletenessScore(
const autofill::AutofillProfile* profile) const {
+ if (!profile)
+ return 0;
+
// Create a bitmask of the fields that are both present and required.
ProfileFields present =
~GetMissingProfileFields(profile) & GetRequiredProfileFieldsForContact();
@@ -134,40 +137,16 @@
GetRequiredProfileFieldsForContact());
}
+bool PaymentsProfileComparator::IsContactMoreComplete(
+ const autofill::AutofillProfile* p1,
+ const autofill::AutofillProfile* p2) const {
+ return GetContactCompletenessScore(p1) > GetContactCompletenessScore(p2);
+}
+
base::string16 PaymentsProfileComparator::GetStringForMissingContactFields(
const autofill::AutofillProfile& profile) const {
return GetStringForMissingFields(GetMissingProfileFields(&profile) &
GetRequiredProfileFieldsForContact());
-}
-
-std::vector<autofill::AutofillProfile*>
-PaymentsProfileComparator::FilterProfilesForShipping(
- const std::vector<autofill::AutofillProfile*>& profiles) const {
- // Since we'll be changing the order/contents of the const input vector,
- // we make a copy.
- std::vector<autofill::AutofillProfile*> processed = profiles;
-
- std::stable_sort(
- processed.begin(), processed.end(),
- std::bind(&PaymentsProfileComparator::IsShippingMoreComplete, this,
- std::placeholders::_1, std::placeholders::_2));
-
- // TODO(crbug.com/722949): Remove profiles with no relevant information, or
- // which are subsets of more-complete profiles.
-
- return processed;
-}
-
-int PaymentsProfileComparator::GetShippingCompletenessScore(
- const autofill::AutofillProfile* profile) const {
- // Create a bitmask of the fields that are both present and required.
- ProfileFields present =
- ~GetMissingProfileFields(profile) & GetRequiredProfileFieldsForShipping();
-
- // Count how many are set. The completeness of the address is weighted so as
- // to dominate the other fields.
- return !!(present & kName) + !!(present & kPhone) +
- (10 * !!(present & kAddress));
}
bool PaymentsProfileComparator::IsShippingComplete(
@@ -269,16 +248,4 @@
return autofill::addressinput::HasAllRequiredFields(*data);
}
-bool PaymentsProfileComparator::IsContactMoreComplete(
- const autofill::AutofillProfile* p1,
- const autofill::AutofillProfile* p2) const {
- return GetContactCompletenessScore(p1) > GetContactCompletenessScore(p2);
-}
-
-bool PaymentsProfileComparator::IsShippingMoreComplete(
- const autofill::AutofillProfile* p1,
- const autofill::AutofillProfile* p2) const {
- return GetShippingCompletenessScore(p1) > GetShippingCompletenessScore(p2);
-}
-
} // namespace payments

Powered by Google App Engine
This is Rietveld 408576698