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

Unified 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: Fix presubmit warning 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillPaymentInstrument.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillPaymentInstrument.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillPaymentInstrument.java
index 62ee4cffa1fa44ede450a96efa8e00bfed5e7d77..1f281f30cfb22792a603b36420894fd79d4c5fe8 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillPaymentInstrument.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillPaymentInstrument.java
@@ -4,9 +4,13 @@
package org.chromium.chrome.browser.payments;
+import android.content.Context;
import android.text.TextUtils;
import android.util.JsonWriter;
+import org.json.JSONObject;
+
+import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.browser.autofill.PersonalDataManager;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
@@ -14,8 +18,6 @@ import org.chromium.chrome.browser.autofill.PersonalDataManager.FullCardRequestD
import org.chromium.content_public.browser.WebContents;
import org.chromium.payments.mojom.PaymentItem;
-import org.json.JSONObject;
-
import java.io.IOException;
import java.io.StringWriter;
import java.util.List;
@@ -27,6 +29,7 @@ import javax.annotation.Nullable;
*/
public class AutofillPaymentInstrument
extends PaymentInstrument implements FullCardRequestDelegate {
+ private final Context mContext;
private final WebContents mWebContents;
private CreditCard mCard;
private boolean mIsComplete;
@@ -40,10 +43,14 @@ public class AutofillPaymentInstrument
* @param card The autofill card that can be used for payment.
* @param billingAddress The billing address for the card.
*/
- public AutofillPaymentInstrument(
- WebContents webContents, CreditCard card, @Nullable AutofillProfile billingAddress) {
+ public AutofillPaymentInstrument(Context context, WebContents webContents, CreditCard card,
+ @Nullable AutofillProfile billingAddress) {
super(card.getGUID(), card.getObfuscatedNumber(), card.getName(),
- card.getIssuerIconDrawableId());
+ card.getIssuerIconDrawableId() == 0
+ ? null
+ : ApiCompatibilityUtils.getDrawable(
+ context.getResources(), card.getIssuerIconDrawableId()));
+ mContext = context;
mWebContents = webContents;
mCard = card;
mIsComplete = false;
@@ -149,12 +156,14 @@ public class AutofillPaymentInstrument
assert billingAddress != null;
assert card.getBillingAddressId() != null;
assert card.getBillingAddressId().equals(billingAddress.getGUID());
+ assert card.getIssuerIconDrawableId() != 0;
mCard = card;
mBillingAddress = billingAddress;
mIsComplete = true;
updateIdentifierLabelsAndIcon(card.getGUID(), card.getObfuscatedNumber(), card.getName(),
- null, card.getIssuerIconDrawableId());
+ null, ApiCompatibilityUtils.getDrawable(
+ mContext.getResources(), card.getIssuerIconDrawableId()));
}
/** @return The credit card represented by this payment instrument. */

Powered by Google App Engine
This is Rietveld 408576698