• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 package org.chromium.chrome.browser.autofill;
6 
7 import org.chromium.base.CalledByNative;
8 import org.chromium.base.JNINamespace;
9 
10 /**
11  * Java-side result of a non-cancelled AutofillDialog invocation, and
12  * JNI glue for C++ AutofillDialogResult used by AutofillDialogControllerAndroid.
13  */
14 @JNINamespace("autofill")
15 public class AutofillDialogResult {
16     /**
17      * Information about the credit card in the dialog result.
18      */
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;
24 
25         /**
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
31          */
ResultCard(int expirationMonth, int expirationYear, String pan, String cvn)32         public ResultCard(int expirationMonth, int expirationYear, String pan, String cvn) {
33             mExpirationMonth = expirationMonth;
34             mExpirationYear = expirationYear;
35             mPan = pan;
36             mCvn = cvn;
37         }
38 
39         /**
40          * @return Expiration month
41          */
42         @CalledByNative("ResultCard")
getExpirationMonth()43         public int getExpirationMonth() {
44             return mExpirationMonth;
45         }
46 
47         /**
48          * @return Expiration year
49          */
50         @CalledByNative("ResultCard")
getExpirationYear()51         public int getExpirationYear() {
52             return mExpirationYear;
53         }
54 
55         /**
56          * @return Credit card number
57          */
58         @CalledByNative("ResultCard")
getPan()59         public String getPan() {
60             return mPan;
61         }
62 
63         /**
64          * @return Credit card verification number
65          */
66         @CalledByNative("ResultCard")
getCvn()67         public String getCvn() {
68             return mCvn;
69         }
70     }
71 
72     /**
73      * Information about an address in the dialog result.
74      */
75     public static class ResultAddress {
76         private final String mName;
77         private final String mPhoneNumber;
78         private final String mStreetAddress;
79         private final String mLocality;
80         private final String mDependentLocality;
81         private final String mAdministrativeArea;
82         private final String mPostalCode;
83         private final String mSortingCode;
84         private final String mCountryCode;
85         private final String mLanguageCode;
86 
87         /**
88          * Creates a ResultAddress.
89          * Any parameter can be empty or null.
90          * @param name Full name
91          * @param phoneNumber Phone number
92          * @param streetAddress Street address
93          * @param locality Locality / City
94          * @param dependentLocality Inner-city district / Suburb / Dependent locality
95          * @param administrativeArea Region / State
96          * @param postalCode Postal code
97          * @param sortingCode Sorting code
98          * @param countryCode Country code
99          * @param languageCode Language code
100          */
ResultAddress( String name, String phoneNumber, String streetAddress, String locality, String dependentLocality, String administrativeArea, String postalCode, String sortingCode, String countryCode, String languageCode)101         public ResultAddress(
102                 String name, String phoneNumber,
103                 String streetAddress,
104                 String locality, String dependentLocality,
105                 String administrativeArea, String postalCode, String sortingCode,
106                 String countryCode, String languageCode) {
107             mName = name;
108             mPhoneNumber = phoneNumber;
109             mStreetAddress = streetAddress;
110             mLocality = locality;
111             mDependentLocality = dependentLocality;
112             mAdministrativeArea = administrativeArea;
113             mPostalCode = postalCode;
114             mSortingCode = sortingCode;
115             mCountryCode = countryCode;
116             mLanguageCode = languageCode;
117         }
118 
119         /**
120          * @return Full name
121          */
122         @CalledByNative("ResultAddress")
getName()123         public String getName() {
124             return mName;
125         }
126 
127         /**
128          * @return Phone number
129          */
130         @CalledByNative("ResultAddress")
getPhoneNumber()131         public String getPhoneNumber() {
132             return mPhoneNumber;
133         }
134 
135         /**
136          * @return Street address
137          */
138         @CalledByNative("ResultAddress")
getStreetAddress()139         public String getStreetAddress() {
140             return mStreetAddress;
141         }
142 
143         /**
144          * @return Locality (city)
145          */
146         @CalledByNative("ResultAddress")
getLocality()147         public String getLocality() {
148             return mLocality;
149         }
150 
151         /**
152          * @return Dependent locality (inner-city district / suburb)
153          */
154         @CalledByNative("ResultAddress")
getDependentLocality()155         public String getDependentLocality() {
156             return mDependentLocality;
157         }
158 
159         /**
160          * @return Administrative area (region / state)
161          */
162         @CalledByNative("ResultAddress")
getAdministrativeArea()163         public String getAdministrativeArea() {
164             return mAdministrativeArea;
165         }
166 
167         /**
168          * @return Postal code
169          */
170         @CalledByNative("ResultAddress")
getPostalCode()171         public String getPostalCode() {
172             return mPostalCode;
173         }
174 
175         /**
176          * @return Sorting code
177          */
178         @CalledByNative("ResultAddress")
getSortingCode()179         public String getSortingCode() {
180             return mSortingCode;
181         }
182 
183         /**
184          * @return Country code
185          */
186         @CalledByNative("ResultAddress")
getCountryCode()187         public String getCountryCode() {
188             return mCountryCode;
189         }
190 
191         /**
192          * @return Language code
193          */
194         @CalledByNative("ResultAddress")
getLanguageCode()195         public String getLanguageCode() {
196             return mLanguageCode;
197         }
198     }
199 
200     /**
201      * A response from the dialog.
202      */
203     public static class ResultWallet {
204         private final String mEmail;
205         private final String mGoogleTransactionId;
206         private final ResultCard mCard;
207         private final ResultAddress mBillingAddress;
208         private final ResultAddress mShippingAddress;
209 
210         /**
211          * Creates a ResultWallet.
212          * Any fields could be empty or null.
213          * @param email Email address
214          * @param googleTransactionId Google transaction ID if any
215          * @param card Information about the credit card
216          * @param billingAddress Information about the billing address
217          * @param shippingAddress Information about the shipping address
218          */
ResultWallet( String email, String googleTransactionId, ResultCard card, ResultAddress billingAddress, ResultAddress shippingAddress)219         public ResultWallet(
220                 String email, String googleTransactionId,
221                 ResultCard card, ResultAddress billingAddress, ResultAddress shippingAddress) {
222             mEmail = email;
223             mGoogleTransactionId = googleTransactionId;
224             mCard = card;
225             mBillingAddress = billingAddress;
226             mShippingAddress = shippingAddress;
227         }
228 
229         /**
230          * @return Email address
231          */
232         @CalledByNative("ResultWallet")
getEmail()233         public String getEmail() {
234             return mEmail;
235         }
236 
237         /**
238          * @return Google transaction ID if any
239          */
240         @CalledByNative("ResultWallet")
getGoogleTransactionId()241         public String getGoogleTransactionId() {
242             return mGoogleTransactionId;
243         }
244 
245         /**
246          * @return Credit card information, or null
247          */
248         @CalledByNative("ResultWallet")
getCard()249         public ResultCard getCard() {
250             return mCard;
251         }
252 
253         /**
254          * @return Billing address information, or null
255          */
256         @CalledByNative("ResultWallet")
getBillingAddress()257         public ResultAddress getBillingAddress() {
258             return mBillingAddress;
259         }
260 
261         /**
262          * @return Shipping address information, or null
263          */
264         @CalledByNative("ResultWallet")
getShippingAddress()265         public ResultAddress getShippingAddress() {
266             return mShippingAddress;
267         }
268     }
269 }
270