| 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..33d21543d2cc26b1b9575dbf7d12cc6b12ee389b 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,74 @@ 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;
|
|
|
| +import javax.annotation.Nullable;
|
| +
|
| /**
|
| * The locally stored contact details.
|
| */
|
| public class AutofillContact extends PaymentOption {
|
| - private final String mPayerEmail;
|
| - private final String mPayerPhone;
|
| + private final AutofillProfile mProfile;
|
| + private boolean mIsComplete;
|
| + @Nullable private String mPayerPhone;
|
| + @Nullable private String mPayerEmail;
|
|
|
| /**
|
| * Builds contact details.
|
| *
|
| - * @param email Email address.
|
| - * @param phone Phone number.
|
| + * @param profile The autofill profile where this contact data lives.
|
| + * @param phone The phone number. If not empty, this will be the primary label.
|
| + * @param email The email address. If phone is empty, this will be the primary label.
|
| + * @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,
|
| - TextUtils.isEmpty(phone) ? null : email, PaymentOption.NO_ICON);
|
| - mPayerEmail = TextUtils.isEmpty(email) ? null : email;
|
| - mPayerPhone = TextUtils.isEmpty(phone) ? null : phone;
|
| - assert mPayerEmail != null || mPayerPhone != null;
|
| + public AutofillContact(AutofillProfile profile, @Nullable String phone, @Nullable String email,
|
| + boolean isComplete) {
|
| + super(profile.getGUID(), null, null, PaymentOption.NO_ICON);
|
| + mProfile = profile;
|
| + mIsComplete = isComplete;
|
| + setPhoneEmail(phone, email);
|
| }
|
|
|
| - /**
|
| - * Returns the email address for mojo.
|
| - *
|
| - * @return Email address. Null if merchant did not request it.
|
| - */
|
| - public String getPayerEmail() {
|
| + /** @return Email address. Null if the merchant did not request it or data is incomplete. */
|
| + @Nullable public String getPayerEmail() {
|
| return mPayerEmail;
|
| }
|
|
|
| + /** @return Phone number. Null if the merchant did not request it or data is incomplete. */
|
| + @Nullable public String getPayerPhone() {
|
| + return mPayerPhone;
|
| + }
|
| +
|
| + /** @return Whether the data is complete and can be sent to the merchant as-is. */
|
| + public boolean isComplete() {
|
| + return mIsComplete;
|
| + }
|
| +
|
| + /** @return The autofill profile where this contact data lives. */
|
| + public AutofillProfile getProfile() {
|
| + return mProfile;
|
| + }
|
| +
|
| /**
|
| - * Returns the phone number for mojo.
|
| + * Updates the email address and phone number and marks this information "complete." Called
|
| + * after the user has edited this contact information. Updates the label and sublabel.
|
| *
|
| - * @return Phone number. Null if merchant did not request it.
|
| + * @param phone The new phone number to use. If not empty, this will be the primary label.
|
| + * @param email The new email address to use. If phone is empty, this will be the primary label.
|
| */
|
| - public String getPayerPhone() {
|
| - return mPayerPhone;
|
| + public void completeContact(@Nullable String phone, @Nullable String email) {
|
| + mIsComplete = true;
|
| + setPhoneEmail(phone, email);
|
| + assert mPayerPhone != null || mPayerEmail != null;
|
| + }
|
| +
|
| + private void setPhoneEmail(@Nullable String phone, @Nullable String email) {
|
| + mPayerPhone = TextUtils.isEmpty(phone) ? null : phone;
|
| + mPayerEmail = TextUtils.isEmpty(email) ? null : email;
|
| + updateLabels(mPayerPhone == null ? mPayerEmail : mPayerPhone,
|
| + mPayerPhone == null ? null : mPayerEmail);
|
| }
|
| }
|
|
|