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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java

Issue 2122493003: [Payments] Dedupe contact info, and phone and email editor suggestions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed bauerb's comments Created 4 years, 5 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: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
index 2d331e7bd0fe027d18ea3ecfe0a6b3f4d7422d2d..360ab4ad67ee38eef702f31cb2ffa1f82a82e97e 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
@@ -46,6 +46,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
@@ -245,6 +246,7 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
}
if (requestPayerPhone || requestPayerEmail) {
+ Set<String> uniqueContactInfos = new HashSet<>();
mContactEditor = new ContactEditor(requestPayerPhone, requestPayerEmail);
List<AutofillContact> contacts = new ArrayList<>();
int firstCompleteContactIndex = SectionInformation.NO_SELECTION;
@@ -259,11 +261,19 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
mContactEditor.addEmailAddressIfValid(email);
if (phone != null || email != null) {
- boolean isComplete = mContactEditor.isContactInformationComplete(phone, email);
- contacts.add(new AutofillContact(profile, phone, email, isComplete));
- if (isComplete
- && firstCompleteContactIndex == SectionInformation.NO_SELECTION) {
- firstCompleteContactIndex = i;
+ // Different profiles can have identical contact info. Do not add the same
+ // contact info to the list twice.
+ String uniqueContactInfo = phone + email;
+ if (!uniqueContactInfos.contains(uniqueContactInfo)) {
+ uniqueContactInfos.add(uniqueContactInfo);
+
+ boolean isComplete =
+ mContactEditor.isContactInformationComplete(phone, email);
+ contacts.add(new AutofillContact(profile, phone, email, isComplete));
+ if (isComplete
+ && firstCompleteContactIndex == SectionInformation.NO_SELECTION) {
+ firstCompleteContactIndex = i;
+ }
}
}
}

Powered by Google App Engine
This is Rietveld 408576698