Home | History | Annotate | Download | only in autofill
      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          */
     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")
     43         public int getExpirationMonth() {
     44             return mExpirationMonth;
     45         }
     46 
     47         /**
     48          * @return Expiration year
     49          */
     50         @CalledByNative("ResultCard")
     51         public int getExpirationYear() {
     52             return mExpirationYear;
     53         }
     54 
     55         /**
     56          * @return Credit card number
     57          */
     58         @CalledByNative("ResultCard")
     59         public String getPan() {
     60             return mPan;
     61         }
     62 
     63         /**
     64          * @return Credit card verification number
     65          */
     66         @CalledByNative("ResultCard")
     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 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;
     84 
     85         /**
     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
     92          * @param city City
     93          * @param state State
     94          * @param postalCode Postal code
     95          * @param countryCode Country code
     96          */
     97         public ResultAddress(
     98                 String name, String phoneNumber,
     99                 String address1, String address2,
    100                 String city, String state, String postalCode,
    101                 String countryCode) {
    102             mName = name;
    103             mPhoneNumber = phoneNumber;
    104             mAddress1 = address1;
    105             mAddress2 = address2;
    106             mCity = city;
    107             mState = state;
    108             mPostalCode = postalCode;
    109             mCountryCode = countryCode;
    110         }
    111 
    112         /**
    113          * @return Full name
    114          */
    115         @CalledByNative("ResultAddress")
    116         public String getName() {
    117             return mName;
    118         }
    119 
    120         /**
    121          * @return Phone number
    122          */
    123         @CalledByNative("ResultAddress")
    124         public String getPhoneNumber() {
    125             return mPhoneNumber;
    126         }
    127 
    128         /**
    129          * @return Address line 1
    130          */
    131         @CalledByNative("ResultAddress")
    132         public String getAddress1() {
    133             return mAddress1;
    134         }
    135 
    136         /**
    137          * @return Address line 2
    138          */
    139         @CalledByNative("ResultAddress")
    140         public String getAddress2() {
    141             return mAddress2;
    142         }
    143 
    144         /**
    145          * @return City
    146          */
    147         @CalledByNative("ResultAddress")
    148         public String getCity() {
    149             return mCity;
    150         }
    151 
    152         /**
    153          * @return State
    154          */
    155         @CalledByNative("ResultAddress")
    156         public String getState() {
    157             return mState;
    158         }
    159 
    160         /**
    161          * @return Postal code
    162          */
    163         @CalledByNative("ResultAddress")
    164         public String getPostalCode() {
    165             return mPostalCode;
    166         }
    167 
    168         /**
    169          * @return Country code
    170          */
    171         @CalledByNative("ResultAddress")
    172         public String getCountryCode() {
    173             return mCountryCode;
    174         }
    175     }
    176 
    177     /**
    178      * A response from the dialog.
    179      */
    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;
    186 
    187         /**
    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
    195          */
    196         public ResultWallet(
    197                 String email, String googleTransactionId,
    198                 ResultCard card, ResultAddress billingAddress, ResultAddress shippingAddress) {
    199             mEmail = email;
    200             mGoogleTransactionId = googleTransactionId;
    201             mCard = card;
    202             mBillingAddress = billingAddress;
    203             mShippingAddress = shippingAddress;
    204         }
    205 
    206         /**
    207          * @return Email address
    208          */
    209         @CalledByNative("ResultWallet")
    210         public String getEmail() {
    211             return mEmail;
    212         }
    213 
    214         /**
    215          * @return Google transaction ID if any
    216          */
    217         @CalledByNative("ResultWallet")
    218         public String getGoogleTransactionId() {
    219             return mGoogleTransactionId;
    220         }
    221 
    222         /**
    223          * @return Credit card information, or null
    224          */
    225         @CalledByNative("ResultWallet")
    226         public ResultCard getCard() {
    227             return mCard;
    228         }
    229 
    230         /**
    231          * @return Billing address information, or null
    232          */
    233         @CalledByNative("ResultWallet")
    234         public ResultAddress getBillingAddress() {
    235             return mBillingAddress;
    236         }
    237 
    238         /**
    239          * @return Shipping address information, or null
    240          */
    241         @CalledByNative("ResultWallet")
    242         public ResultAddress getShippingAddress() {
    243             return mShippingAddress;
    244         }
    245     }
    246 }
    247