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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.payments;
6
7 import android.text.TextUtils;
8
9 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
10 import org.chromium.chrome.browser.payments.ui.PaymentOption;
11
12 import javax.annotation.Nullable;
13
14 /**
15 * The locally stored payer information details.
16 */
17 public class AutofillPayerInfo extends PaymentOption {
18 private final AutofillProfile mProfile;
19 @Nullable private String mPayerName;
20 @Nullable private String mPayerPhone;
21 @Nullable private String mPayerEmail;
22
23 /**
24 * Builds payer information details.
25 *
26 * @param profile The autofill profile where this payer information data lives.
27 * @param name The payer name. If not empty, this will be the primary label.
28 * @param phone The phone number. If name is empty, this will be the pr imary label.
29 * @param email The email address. If name and phone is empty, this wil l be the primary
30 * label.
31 * @param isComplete Whether the data in this payer information can be sent to the merchant
32 * as-is. If false, user needs to add more information her e.
33 */
34 public AutofillPayerInfo(AutofillProfile profile, @Nullable String name, @Nu llable String phone,
35 @Nullable String email, boolean isComplete) {
36 super(profile.getGUID(), null, null, PaymentOption.NO_ICON);
37 mProfile = profile;
38 mIsComplete = isComplete;
39 setGuidAndPayerInfo(profile.getGUID(), name, phone, email);
40 }
41
42 /** @return Payer name. Null if the merchant did not request it or data is i ncomplete. */
43 @Nullable public String getPayerName() {
44 return mPayerName;
45 }
46
47 /** @return Email address. Null if the merchant did not request it or data i s incomplete. */
48 @Nullable public String getPayerEmail() {
49 return mPayerEmail;
50 }
51
52 /** @return Phone number. Null if the merchant did not request it or data is incomplete. */
53 @Nullable public String getPayerPhone() {
54 return mPayerPhone;
55 }
56
57 /** @return The autofill profile where this payer information data lives. */
58 public AutofillProfile getProfile() {
59 return mProfile;
60 }
61
62 /**
63 * Updates the profile guid, payer name, email address, and phone number and marks this
64 * information "complete." Called after the user has edited this payer infor mation.
65 * Updates the identifier, label, and sublabel.
66 *
67 * @param guid The new identifier to use. Should not be null or empty.
68 * @param name The new payer name to use. If not empty, this will be the pr imary label.
69 * @param phone The new phone number to use. If name is empty, this will be the primary label.
70 * @param email The new email address to use. If name and phone is empty, th is will be the
71 * primary label.
72 */
73 public void completePayerInfo(
74 String guid, @Nullable String name, @Nullable String phone, @Nullabl e String email) {
75 mIsComplete = true;
76 setGuidAndPayerInfo(guid, name, phone, email);
77 }
78
79 private void setGuidAndPayerInfo(
80 String guid, @Nullable String name, @Nullable String phone, @Nullabl e String email) {
81 mPayerName = TextUtils.isEmpty(name) ? null : name;
82 mPayerPhone = TextUtils.isEmpty(phone) ? null : phone;
83 mPayerEmail = TextUtils.isEmpty(email) ? null : email;
84
85 if (mPayerName == null) {
86 updateIdentifierAndLabels(guid, mPayerPhone == null ? mPayerEmail : mPayerPhone,
87 mPayerPhone == null ? null : mPayerEmail);
88 } else {
89 updateIdentifierAndLabels(guid, mPayerName,
90 mPayerPhone == null ? mPayerEmail : mPayerPhone,
91 mPayerPhone == null ? null : mPayerEmail);
92 }
93 }
94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698