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

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

Issue 2393113003: test:
Patch Set: test: Created 4 years, 2 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/AutofillPayerInfo.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillPayerInfo.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillPayerInfo.java
new file mode 100644
index 0000000000000000000000000000000000000000..a33507c667d1e0d179ddebcacc34d2e104328ff8
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillPayerInfo.java
@@ -0,0 +1,94 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+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 payer information details.
+ */
+public class AutofillPayerInfo extends PaymentOption {
+ private final AutofillProfile mProfile;
+ @Nullable private String mPayerName;
+ @Nullable private String mPayerPhone;
+ @Nullable private String mPayerEmail;
+
+ /**
+ * Builds payer information details.
+ *
+ * @param profile The autofill profile where this payer information data lives.
+ * @param name The payer name. If not empty, this will be the primary label.
+ * @param phone The phone number. If name is empty, this will be the primary label.
+ * @param email The email address. If name and phone is empty, this will be the primary
+ * label.
+ * @param isComplete Whether the data in this payer information can be sent to the merchant
+ * as-is. If false, user needs to add more information here.
+ */
+ public AutofillPayerInfo(AutofillProfile profile, @Nullable String name, @Nullable String phone,
+ @Nullable String email, boolean isComplete) {
+ super(profile.getGUID(), null, null, PaymentOption.NO_ICON);
+ mProfile = profile;
+ mIsComplete = isComplete;
+ setGuidAndPayerInfo(profile.getGUID(), name, phone, email);
+ }
+
+ /** @return Payer name. Null if the merchant did not request it or data is incomplete. */
+ @Nullable public String getPayerName() {
+ return mPayerName;
+ }
+
+ /** @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 The autofill profile where this payer information data lives. */
+ public AutofillProfile getProfile() {
+ return mProfile;
+ }
+
+ /**
+ * Updates the profile guid, payer name, email address, and phone number and marks this
+ * information "complete." Called after the user has edited this payer information.
+ * Updates the identifier, label, and sublabel.
+ *
+ * @param guid The new identifier to use. Should not be null or empty.
+ * @param name The new payer name to use. If not empty, this will be the primary label.
+ * @param phone The new phone number to use. If name is empty, this will be the primary label.
+ * @param email The new email address to use. If name and phone is empty, this will be the
+ * primary label.
+ */
+ public void completePayerInfo(
+ String guid, @Nullable String name, @Nullable String phone, @Nullable String email) {
+ mIsComplete = true;
+ setGuidAndPayerInfo(guid, name, phone, email);
+ }
+
+ private void setGuidAndPayerInfo(
+ String guid, @Nullable String name, @Nullable String phone, @Nullable String email) {
+ mPayerName = TextUtils.isEmpty(name) ? null : name;
+ mPayerPhone = TextUtils.isEmpty(phone) ? null : phone;
+ mPayerEmail = TextUtils.isEmpty(email) ? null : email;
+
+ if (mPayerName == null) {
+ updateIdentifierAndLabels(guid, mPayerPhone == null ? mPayerEmail : mPayerPhone,
+ mPayerPhone == null ? null : mPayerEmail);
+ } else {
+ updateIdentifierAndLabels(guid, mPayerName,
+ mPayerPhone == null ? mPayerEmail : mPayerPhone,
+ mPayerPhone == null ? null : mPayerEmail);
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698