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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillPaymentInstrument.java

Issue 2436883002: Make PaymentOption store a Drawable instead of id (Closed)
Patch Set: Try to fix test compilation 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.payments; 5 package org.chromium.chrome.browser.payments;
6 6
7 import android.content.Context;
7 import android.text.TextUtils; 8 import android.text.TextUtils;
8 import android.util.JsonWriter; 9 import android.util.JsonWriter;
9 10
11 import org.json.JSONObject;
12
13 import org.chromium.base.ApiCompatibilityUtils;
10 import org.chromium.chrome.browser.autofill.PersonalDataManager; 14 import org.chromium.chrome.browser.autofill.PersonalDataManager;
11 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; 15 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
12 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; 16 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
13 import org.chromium.chrome.browser.autofill.PersonalDataManager.FullCardRequestD elegate; 17 import org.chromium.chrome.browser.autofill.PersonalDataManager.FullCardRequestD elegate;
14 import org.chromium.content_public.browser.WebContents; 18 import org.chromium.content_public.browser.WebContents;
15 import org.chromium.payments.mojom.PaymentItem; 19 import org.chromium.payments.mojom.PaymentItem;
16 20
17 import org.json.JSONObject;
18
19 import java.io.IOException; 21 import java.io.IOException;
20 import java.io.StringWriter; 22 import java.io.StringWriter;
21 import java.util.List; 23 import java.util.List;
22 24
23 import javax.annotation.Nullable; 25 import javax.annotation.Nullable;
24 26
25 /** 27 /**
26 * The locally stored credit card payment instrument. 28 * The locally stored credit card payment instrument.
27 */ 29 */
28 public class AutofillPaymentInstrument 30 public class AutofillPaymentInstrument
29 extends PaymentInstrument implements FullCardRequestDelegate { 31 extends PaymentInstrument implements FullCardRequestDelegate {
32 private final Context mContext;
30 private final WebContents mWebContents; 33 private final WebContents mWebContents;
31 private CreditCard mCard; 34 private CreditCard mCard;
32 private boolean mIsComplete; 35 private boolean mIsComplete;
33 @Nullable private AutofillProfile mBillingAddress; 36 @Nullable private AutofillProfile mBillingAddress;
34 @Nullable private DetailsCallback mCallback; 37 @Nullable private DetailsCallback mCallback;
35 38
36 /** 39 /**
37 * Builds a payment instrument for the given credit card. 40 * Builds a payment instrument for the given credit card.
38 * 41 *
39 * @param webContents The web contents where PaymentRequest was invoked. 42 * @param webContents The web contents where PaymentRequest was invoked.
40 * @param card The autofill card that can be used for payment. 43 * @param card The autofill card that can be used for payment.
41 * @param billingAddress The billing address for the card. 44 * @param billingAddress The billing address for the card.
42 */ 45 */
43 public AutofillPaymentInstrument( 46 public AutofillPaymentInstrument(Context context, WebContents webContents, C reditCard card,
44 WebContents webContents, CreditCard card, @Nullable AutofillProfile billingAddress) { 47 @Nullable AutofillProfile billingAddress) {
45 super(card.getGUID(), card.getObfuscatedNumber(), card.getName(), 48 super(card.getGUID(), card.getObfuscatedNumber(), card.getName(),
46 card.getIssuerIconDrawableId()); 49 card.getIssuerIconDrawableId() < 1
please use gerrit instead 2016/10/20 15:22:18 "== 0" should be sufficient instead of "< 1". http
50 ? null
51 : ApiCompatibilityUtils.getDrawable(
52 context.getResources(), card.getIssuerIconDrawableId())) ;
53 mContext = context;
47 mWebContents = webContents; 54 mWebContents = webContents;
48 mCard = card; 55 mCard = card;
49 mIsComplete = false; 56 mIsComplete = false;
50 mBillingAddress = billingAddress; 57 mBillingAddress = billingAddress;
51 } 58 }
52 59
53 @Override 60 @Override
54 public String getMethodName() { 61 public String getMethodName() {
55 return mCard.getBasicCardPaymentType(); 62 return mCard.getBasicCardPaymentType();
56 } 63 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 * instrument. 148 * instrument.
142 * 149 *
143 * @param card The new credit card to use. The GUID should not cha nge. 150 * @param card The new credit card to use. The GUID should not cha nge.
144 * @param billingAddress The billing address for the card. The GUID should m atch the billing 151 * @param billingAddress The billing address for the card. The GUID should m atch the billing
145 * address ID of the new card to use. 152 * address ID of the new card to use.
146 */ 153 */
147 public void completeInstrument(CreditCard card, AutofillProfile billingAddre ss) { 154 public void completeInstrument(CreditCard card, AutofillProfile billingAddre ss) {
148 assert card != null; 155 assert card != null;
149 assert billingAddress != null; 156 assert billingAddress != null;
150 assert card.getBillingAddressId() != null; 157 assert card.getBillingAddressId() != null;
151 assert card.getBillingAddressId().equals(billingAddress.getGUID()); 158 assert card.getBillingAddressId().equals(billingAddress.getGUID());
please use gerrit instead 2016/10/20 15:22:18 Please add this line: assert card.getIssuerIconDr
152 159
153 mCard = card; 160 mCard = card;
154 mBillingAddress = billingAddress; 161 mBillingAddress = billingAddress;
155 mIsComplete = true; 162 mIsComplete = true;
156 updateIdentifierLabelsAndIcon(card.getGUID(), card.getObfuscatedNumber() , card.getName(), 163 updateIdentifierLabelsAndIcon(card.getGUID(), card.getObfuscatedNumber() , card.getName(),
157 null, card.getIssuerIconDrawableId()); 164 null, ApiCompatibilityUtils.getDrawable(
165 mContext.getResources(), card.getIssuerIconDrawabl eId()));
158 } 166 }
159 167
160 /** @return The credit card represented by this payment instrument. */ 168 /** @return The credit card represented by this payment instrument. */
161 public CreditCard getCard() { 169 public CreditCard getCard() {
162 return mCard; 170 return mCard;
163 } 171 }
164 } 172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698