1 // Copyright 2013 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.
5 package org.chromium.chrome.browser.autofill;
7 import org.chromium.base.CalledByNative;
8 import org.chromium.base.JNINamespace;
11 * Java-side result of a non-cancelled AutofillDialog invocation, and
12 * JNI glue for C++ AutofillDialogResult used by AutofillDialogControllerAndroid.
14 @JNINamespace("autofill")
15 public class AutofillDialogResult {
17 * Information about the credit card in the dialog result.
19 public static class ResultCard {
20 private final int mExpirationMonth;
21 private final int mExpirationYear;
22 private final String mPan;
23 private final String mCvn;
26 * Creates a ResultCard.
27 * @param expirationMonth Expiration month
28 * @param expirationYear Expiration year
29 * @param pan Credit card number
30 * @param cvn Credit card verification number
32 public ResultCard(int expirationMonth, int expirationYear, String pan, String cvn) {
33 mExpirationMonth = expirationMonth;
34 mExpirationYear = expirationYear;
40 * @return Expiration month
42 @CalledByNative("ResultCard")
43 public int getExpirationMonth() {
44 return mExpirationMonth;
48 * @return Expiration year
50 @CalledByNative("ResultCard")
51 public int getExpirationYear() {
52 return mExpirationYear;
56 * @return Credit card number
58 @CalledByNative("ResultCard")
59 public String getPan() {
64 * @return Credit card verification number
66 @CalledByNative("ResultCard")
67 public String getCvn() {
73 * Information about an address in the dialog result.
75 public static class ResultAddress {
76 private final String mName;
77 private final String mPhoneNumber;
78 private final String mAddress1;
79 private final String mAddress2;
80 private final String mCity;
81 private final String mState;
82 private final String mPostalCode;
83 private final String mCountryCode;
86 * Creates a ResultAddress.
87 * Any parameter can be empty or null.
88 * @param name Full name
89 * @param phoneNumber Phone number
90 * @param address1 Address line 1
91 * @param address2 Address line 2
94 * @param postalCode Postal code
95 * @param countryCode Country code
98 String name, String phoneNumber,
99 String address1, String address2,
100 String city, String state, String postalCode,
101 String countryCode) {
103 mPhoneNumber = phoneNumber;
104 mAddress1 = address1;
105 mAddress2 = address2;
108 mPostalCode = postalCode;
109 mCountryCode = countryCode;
115 @CalledByNative("ResultAddress")
116 public String getName() {
121 * @return Phone number
123 @CalledByNative("ResultAddress")
124 public String getPhoneNumber() {
129 * @return Address line 1
131 @CalledByNative("ResultAddress")
132 public String getAddress1() {
137 * @return Address line 2
139 @CalledByNative("ResultAddress")
140 public String getAddress2() {
147 @CalledByNative("ResultAddress")
148 public String getCity() {
155 @CalledByNative("ResultAddress")
156 public String getState() {
161 * @return Postal code
163 @CalledByNative("ResultAddress")
164 public String getPostalCode() {
169 * @return Country code
171 @CalledByNative("ResultAddress")
172 public String getCountryCode() {
178 * A response from the dialog.
180 public static class ResultWallet {
181 private final String mEmail;
182 private final String mGoogleTransactionId;
183 private final ResultCard mCard;
184 private final ResultAddress mBillingAddress;
185 private final ResultAddress mShippingAddress;
188 * Creates a ResultWallet.
189 * Any fields could be empty or null.
190 * @param email Email address
191 * @param googleTransactionId Google transaction ID if any
192 * @param card Information about the credit card
193 * @param billingAddress Information about the billing address
194 * @param shippingAddress Information about the shipping address
197 String email, String googleTransactionId,
198 ResultCard card, ResultAddress billingAddress, ResultAddress shippingAddress) {
200 mGoogleTransactionId = googleTransactionId;
202 mBillingAddress = billingAddress;
203 mShippingAddress = shippingAddress;
207 * @return Email address
209 @CalledByNative("ResultWallet")
210 public String getEmail() {
215 * @return Google transaction ID if any
217 @CalledByNative("ResultWallet")
218 public String getGoogleTransactionId() {
219 return mGoogleTransactionId;
223 * @return Credit card information, or null
225 @CalledByNative("ResultWallet")
226 public ResultCard getCard() {
231 * @return Billing address information, or null
233 @CalledByNative("ResultWallet")
234 public ResultAddress getBillingAddress() {
235 return mBillingAddress;
239 * @return Shipping address information, or null
241 @CalledByNative("ResultWallet")
242 public ResultAddress getShippingAddress() {
243 return mShippingAddress;