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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java

Issue 2748093003: PaymentRequest: Introduce PaymentDetailsInit and PaymentDetailsUpdate. (Closed)
Patch Set: PaymentRequest: Introduce PaymentDetailsInit and PaymentDetailsUpdate. Created 3 years, 9 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/PaymentRequestImpl.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
index ca53cbcf63dd9f831990019556b106b7a20b6b33..81a1029dfa3fb0b2ab5545448c9778f12236fc92 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
@@ -420,6 +420,13 @@ public class PaymentRequestImpl
if (!parseAndValidateDetailsOrDisconnectFromClient(details)) return;
+ if (mRawTotal == null) {
+ disconnectFromClientWithDebugMessage("Missing total");
+ recordAbortReasonHistogram(
+ PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERER);
+ return;
+ }
+
PaymentAppFactory.getInstance().create(mWebContents,
Collections.unmodifiableSet(mMethodData.keySet()), this /* callback */);
@@ -735,15 +742,20 @@ public class PaymentRequestImpl
details.total.amount.currencySystem, Locale.getDefault());
}
- // Total is never pending.
- LineItem uiTotal = new LineItem(details.total.label,
- mCurrencyFormatter.getFormattedCurrencyCode(),
- mCurrencyFormatter.format(details.total.amount.value), /* isPending */ false);
+ if (details.total != null) {
+ mRawTotal = details.total;
+ }
+
+ if (mRawTotal != null) {
+ // Total is never pending.
+ LineItem uiTotal = new LineItem(mRawTotal.label,
+ mCurrencyFormatter.getFormattedCurrencyCode(),
+ mCurrencyFormatter.format(mRawTotal.amount.value), /* isPending */ false);
- List<LineItem> uiLineItems = getLineItems(details.displayItems, mCurrencyFormatter);
+ List<LineItem> uiLineItems = getLineItems(details.displayItems, mCurrencyFormatter);
- mUiShoppingCart = new ShoppingCart(uiTotal, uiLineItems);
- mRawTotal = details.total;
+ mUiShoppingCart = new ShoppingCart(uiTotal, uiLineItems);
+ }
mRawLineItems = Collections.unmodifiableList(Arrays.asList(details.displayItems));
mUiShippingOptions = getShippingOptions(details.shippingOptions, mCurrencyFormatter);

Powered by Google App Engine
This is Rietveld 408576698