Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillContact.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillContact.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillContact.java |
| index 980230785ffb196281c86663141d3ebc5d4dc36a..0a8f5c119cd439c62098185492a74562993e50c9 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillContact.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillContact.java |
| @@ -6,44 +6,100 @@ package org.chromium.chrome.browser.payments; |
| import android.text.TextUtils; |
| +import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
| import org.chromium.chrome.browser.payments.ui.PaymentOption; |
| /** |
| * The locally stored contact details. |
| */ |
| public class AutofillContact extends PaymentOption { |
| - private final String mPayerEmail; |
| - private final String mPayerPhone; |
| + private final AutofillProfile mProfile; |
| + private String mPayerEmail; |
| + private String mPayerPhone; |
| + private boolean mIsComplete; |
| /** |
| * Builds contact details. |
| * |
| - * @param email Email address. |
| - * @param phone Phone number. |
| + * @param profile The autofill profile where this contact data lives. |
| + * @param email Email address. |
| + * @param phone Phone number. |
| + * @param isComplete Whether the data in this contact can be sent to the merchant as-is. If |
| + * false, user needs to add more information here. |
| */ |
| - public AutofillContact(String email, String phone) { |
| - super(null, TextUtils.isEmpty(phone) ? email : phone, |
| + public AutofillContact( |
| + AutofillProfile profile, String email, String phone, boolean isComplete) { |
| + super(profile.getGUID(), TextUtils.isEmpty(phone) ? email : phone, |
| TextUtils.isEmpty(phone) ? null : email, PaymentOption.NO_ICON); |
| + mProfile = profile; |
| mPayerEmail = TextUtils.isEmpty(email) ? null : email; |
| mPayerPhone = TextUtils.isEmpty(phone) ? null : phone; |
| + mIsComplete = isComplete; |
| assert mPayerEmail != null || mPayerPhone != null; |
| } |
| /** |
| - * Returns the email address for mojo. |
| + * Returns the email address for the merchant. |
| * |
| - * @return Email address. Null if merchant did not request it. |
| + * @return Email address. Null if the merchant did not request it. |
| */ |
| public String getPayerEmail() { |
| return mPayerEmail; |
| } |
| /** |
| - * Returns the phone number for mojo. |
| + * Updates the email address. This influences the label and sublabel. |
|
gone
2016/06/21 06:04:38
nit: Say more specifically that the phone number i
please use gerrit instead
2016/06/22 02:12:29
Done.
|
| * |
| - * @return Phone number. Null if merchant did not request it. |
| + * @param email The new email address to use. |
| + */ |
| + public void setPayerEmail(String email) { |
| + mPayerEmail = email; |
| + setLabel(TextUtils.isEmpty(mPayerPhone) ? mPayerEmail : mPayerPhone); |
|
gone
2016/06/21 06:04:38
Pull this out into an updateLabels() function and
please use gerrit instead
2016/06/22 02:12:29
Done.
|
| + setSublabel(TextUtils.isEmpty(mPayerPhone) ? null : mPayerEmail); |
| + } |
| + |
| + /** |
| + * Returns the phone number for the merchant. |
| + * |
| + * @return Phone number. Null if the merchant did not request it. |
| */ |
| public String getPayerPhone() { |
| return mPayerPhone; |
| } |
| + |
| + /** |
| + * Updates the phone number. This influences the label and sublabel. |
| + * |
| + * @param phone The new phone number to use. |
| + */ |
| + public void setPayerPhone(String phone) { |
| + mPayerPhone = phone; |
| + setLabel(TextUtils.isEmpty(mPayerPhone) ? mPayerEmail : mPayerPhone); |
| + setSublabel(TextUtils.isEmpty(mPayerPhone) ? null : mPayerEmail); |
| + } |
| + |
| + /** |
| + * Returns true if the data in this contact is complete and can be sent to the merchant as-is. |
| + * |
| + * @return Whether the data in this contact is complete. |
| + */ |
| + public boolean isComplete() { |
| + return mIsComplete; |
| + } |
| + |
| + /** |
| + * Marks the data in this contact complete. It can be sent to the merchant as-is. |
| + */ |
| + public void setComplete() { |
|
gone
2016/06/21 06:04:38
nit: setIsComplete?
please use gerrit instead
2016/06/22 02:12:29
Done.
|
| + mIsComplete = true; |
| + } |
| + |
| + /** |
| + * Returns the autofill profile where this contact data lives. |
| + * |
| + * @return The autofill profile where this contact data lives. |
| + */ |
| + public AutofillProfile getProfile() { |
| + return mProfile; |
| + } |
| } |