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

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

Issue 2640743005: PaymentApp: Implement invokePaymentApp for Android (Closed)
Patch Set: Fix unittest compilation Created 3 years, 11 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.app.Activity; 7 import android.app.Activity;
8 import android.content.Intent; 8 import android.content.Intent;
9 import android.graphics.Bitmap; 9 import android.graphics.Bitmap;
10 import android.os.Handler; 10 import android.os.Handler;
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 mCurrencyFormatter.format(details.total.amount.value), /* isPend ing */ false); 614 mCurrencyFormatter.format(details.total.amount.value), /* isPend ing */ false);
615 615
616 List<LineItem> uiLineItems = getLineItems(details.displayItems, mCurrenc yFormatter); 616 List<LineItem> uiLineItems = getLineItems(details.displayItems, mCurrenc yFormatter);
617 617
618 mUiShoppingCart = new ShoppingCart(uiTotal, uiLineItems); 618 mUiShoppingCart = new ShoppingCart(uiTotal, uiLineItems);
619 mRawTotal = details.total; 619 mRawTotal = details.total;
620 mRawLineItems = Collections.unmodifiableList(Arrays.asList(details.displ ayItems)); 620 mRawLineItems = Collections.unmodifiableList(Arrays.asList(details.displ ayItems));
621 621
622 mUiShippingOptions = getShippingOptions(details.shippingOptions, mCurren cyFormatter); 622 mUiShippingOptions = getShippingOptions(details.shippingOptions, mCurren cyFormatter);
623 623
624 mModifiers = new ArrayMap<>();
624 for (int i = 0; i < details.modifiers.length; i++) { 625 for (int i = 0; i < details.modifiers.length; i++) {
625 PaymentDetailsModifier modifier = details.modifiers[i]; 626 PaymentDetailsModifier modifier = details.modifiers[i];
626 String[] methods = modifier.methodData.supportedMethods; 627 String[] methods = modifier.methodData.supportedMethods;
627 for (int j = 0; j < methods.length; j++) { 628 for (int j = 0; j < methods.length; j++) {
628 if (mModifiers == null) mModifiers = new ArrayMap<>();
please use gerrit instead 2017/01/19 16:45:04 I would prefer to keep null ArrayMap if the mercha
tommyt 2017/01/20 09:33:29 Done.
629 mModifiers.put(methods[j], modifier); 629 mModifiers.put(methods[j], modifier);
630 } 630 }
631 } 631 }
632 632
633 updateInstrumentModifiedTotals(); 633 updateInstrumentModifiedTotals();
634 634
635 return true; 635 return true;
636 } 636 }
637 637
638 /** Updates the modifiers for payment instruments and order summary. */ 638 /** Updates the modifiers for payment instruments and order summary. */
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 PaymentOption selectedShippingOption, PaymentOption selectedPaymentM ethod) { 1027 PaymentOption selectedShippingOption, PaymentOption selectedPaymentM ethod) {
1028 assert selectedPaymentMethod instanceof PaymentInstrument; 1028 assert selectedPaymentMethod instanceof PaymentInstrument;
1029 PaymentInstrument instrument = (PaymentInstrument) selectedPaymentMethod ; 1029 PaymentInstrument instrument = (PaymentInstrument) selectedPaymentMethod ;
1030 mPaymentAppRunning = true; 1030 mPaymentAppRunning = true;
1031 1031
1032 PaymentOption selectedContact = mContactSection != null ? mContactSectio n.getSelectedItem() 1032 PaymentOption selectedContact = mContactSection != null ? mContactSectio n.getSelectedItem()
1033 : null; 1033 : null;
1034 mPaymentResponseHelper = new PaymentResponseHelper( 1034 mPaymentResponseHelper = new PaymentResponseHelper(
1035 selectedShippingAddress, selectedShippingOption, selectedContact , this); 1035 selectedShippingAddress, selectedShippingOption, selectedContact , this);
1036 1036
1037 // Create a map that is the subset of mMethodData that contains the 1037 // Create maps that are subsets of mMethodData and mModifiers, that cont ain
1038 // payment methods supported by the selected payment instrument. If this 1038 // the payment methods supported by the selected payment instrument. If the
1039 // intersection contains more than one payment method, the payment app i s 1039 // intersection of method data contains more than one payment method, th e
1040 // at liberty to choose (or have the user choose) one of the methods. 1040 // payment app is at liberty to choose (or have the user choose) one of the
1041 // methods.
1041 Map<String, PaymentMethodData> methodData = new HashMap<>(); 1042 Map<String, PaymentMethodData> methodData = new HashMap<>();
1043 Map<String, PaymentDetailsModifier> modifiers = new HashMap<>();
1042 for (String instrumentMethodName : instrument.getInstrumentMethodNames() ) { 1044 for (String instrumentMethodName : instrument.getInstrumentMethodNames() ) {
1043 if (mMethodData.containsKey(instrumentMethodName)) { 1045 if (mMethodData.containsKey(instrumentMethodName)) {
1044 methodData.put(instrumentMethodName, mMethodData.get(instrumentM ethodName)); 1046 methodData.put(instrumentMethodName, mMethodData.get(instrumentM ethodName));
1045 } 1047 }
1048 if (mModifiers.containsKey(instrumentMethodName)) {
please use gerrit instead 2017/01/19 16:45:04 You can check mModifiers != null here, if you keep
tommyt 2017/01/20 09:33:29 Done.
1049 modifiers.put(instrumentMethodName, mModifiers.get(instrumentMet hodName));
1050 }
1046 } 1051 }
1047 1052
1048 instrument.invokePaymentApp(mMerchantName, mOrigin, mRawTotal, mRawLineI tems, 1053 instrument.invokePaymentApp(mMerchantName, mOrigin, Collections.unmodifi ableMap(methodData),
1049 Collections.unmodifiableMap(methodData), this); 1054 mRawTotal, mRawLineItems, Collections.unmodifiableMap(modifiers) , this);
please use gerrit instead 2017/01/19 16:45:04 Might be a good idea to make mRawLineItems unmodif
tommyt 2017/01/20 09:33:29 It should already be unmodifiable. It is assigned
1055
1050 recordSuccessFunnelHistograms("PayClicked"); 1056 recordSuccessFunnelHistograms("PayClicked");
1051 return !(instrument instanceof AutofillPaymentInstrument); 1057 return !(instrument instanceof AutofillPaymentInstrument);
1052 } 1058 }
1053 1059
1054 @Override 1060 @Override
1055 public void onDismiss() { 1061 public void onDismiss() {
1056 disconnectFromClientWithDebugMessage("Dialog dismissed"); 1062 disconnectFromClientWithDebugMessage("Dialog dismissed");
1057 recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_ABORTED_BY _USER); 1063 recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_ABORTED_BY _USER);
1058 } 1064 }
1059 1065
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 "PaymentRequest.CheckoutFunnel.Aborted", abortReason, 1473 "PaymentRequest.CheckoutFunnel.Aborted", abortReason,
1468 PaymentRequestMetrics.ABORT_REASON_MAX); 1474 PaymentRequestMetrics.ABORT_REASON_MAX);
1469 1475
1470 if (abortReason == PaymentRequestMetrics.ABORT_REASON_ABORTED_BY_USER) { 1476 if (abortReason == PaymentRequestMetrics.ABORT_REASON_ABORTED_BY_USER) {
1471 mJourneyLogger.recordJourneyStatsHistograms("UserAborted"); 1477 mJourneyLogger.recordJourneyStatsHistograms("UserAborted");
1472 } else { 1478 } else {
1473 mJourneyLogger.recordJourneyStatsHistograms("OtherAborted"); 1479 mJourneyLogger.recordJourneyStatsHistograms("OtherAborted");
1474 } 1480 }
1475 } 1481 }
1476 } 1482 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698