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

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

Issue 2260503004: [Merge M-53] Enable closing while processing payment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 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.graphics.Bitmap; 8 import android.graphics.Bitmap;
9 import android.os.Handler; 9 import android.os.Handler;
10 import android.text.TextUtils; 10 import android.text.TextUtils;
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 mPaymentAppRunning = true; 835 mPaymentAppRunning = true;
836 instrument.getDetails(mMerchantName, mOrigin, mRawTotal, mRawLineItems, 836 instrument.getDetails(mMerchantName, mOrigin, mRawTotal, mRawLineItems,
837 mMethodData.get(instrument.getMethodName()), this); 837 mMethodData.get(instrument.getMethodName()), this);
838 recordSuccessFunnelHistograms("PayClicked"); 838 recordSuccessFunnelHistograms("PayClicked");
839 return !(instrument instanceof AutofillPaymentInstrument); 839 return !(instrument instanceof AutofillPaymentInstrument);
840 } 840 }
841 841
842 @Override 842 @Override
843 public void onDismiss() { 843 public void onDismiss() {
844 disconnectFromClientWithDebugMessage("Dialog dismissed"); 844 disconnectFromClientWithDebugMessage("Dialog dismissed");
845 closeUI(false); 845 closeUI(true);
846 recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_ABORTED_BY _USER); 846 recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_ABORTED_BY _USER);
847 } 847 }
848 848
849 private void disconnectFromClientWithDebugMessage(String debugMessage) { 849 private void disconnectFromClientWithDebugMessage(String debugMessage) {
850 disconnectFromClientWithDebugMessage(debugMessage, PaymentErrorReason.US ER_CANCEL); 850 disconnectFromClientWithDebugMessage(debugMessage, PaymentErrorReason.US ER_CANCEL);
851 } 851 }
852 852
853 private void disconnectFromClientWithDebugMessage(String debugMessage, int r eason) { 853 private void disconnectFromClientWithDebugMessage(String debugMessage, int r eason) {
854 Log.d(TAG, debugMessage); 854 Log.d(TAG, debugMessage);
855 if (mClient != null) mClient.onError(reason); 855 if (mClient != null) mClient.onError(reason);
856 closeClient(); 856 closeClient();
857 closeUI(false); 857 closeUI(true);
858 } 858 }
859 859
860 @Override 860 @Override
861 public boolean merchantNeedsShippingAddress() { 861 public boolean merchantNeedsShippingAddress() {
862 return mMerchantNeedsShippingAddress; 862 return mMerchantNeedsShippingAddress;
863 } 863 }
864 864
865 /** 865 /**
866 * Called by the merchant website to abort the payment. 866 * Called by the merchant website to abort the payment.
867 */ 867 */
868 @Override 868 @Override
869 public void abort() { 869 public void abort() {
870 if (mClient == null) return; 870 if (mClient == null) return;
871 mClient.onAbort(!mPaymentAppRunning); 871 mClient.onAbort(!mPaymentAppRunning);
872 if (mPaymentAppRunning) { 872 if (mPaymentAppRunning) {
873 if (sObserverForTest != null) sObserverForTest.onPaymentRequestServi ceUnableToAbort(); 873 if (sObserverForTest != null) sObserverForTest.onPaymentRequestServi ceUnableToAbort();
874 } else { 874 } else {
875 closeClient(); 875 closeClient();
876 closeUI(false); 876 closeUI(true);
877 recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_ABORTE D_BY_MERCHANT); 877 recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_ABORTE D_BY_MERCHANT);
878 } 878 }
879 } 879 }
880 880
881 /** 881 /**
882 * Called when the merchant website has processed the payment. 882 * Called when the merchant website has processed the payment.
883 */ 883 */
884 @Override 884 @Override
885 public void complete(int result) { 885 public void complete(int result) {
886 if (mClient == null) return; 886 if (mClient == null) return;
887 recordSuccessFunnelHistograms("Completed"); 887 recordSuccessFunnelHistograms("Completed");
888 closeUI(PaymentComplete.FAIL != result); 888 closeUI(PaymentComplete.FAIL != result);
889 } 889 }
890 890
891 /** 891 /**
892 * Called when the renderer closes the Mojo connection. 892 * Called when the renderer closes the Mojo connection.
893 */ 893 */
894 @Override 894 @Override
895 public void close() { 895 public void close() {
896 if (mClient == null) return; 896 if (mClient == null) return;
897 closeClient(); 897 closeClient();
898 closeUI(false); 898 closeUI(true);
899 recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_MOJO_RENDE RER_CLOSING); 899 recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_MOJO_RENDE RER_CLOSING);
900 } 900 }
901 901
902 /** 902 /**
903 * Called when the Mojo connection encounters an error. 903 * Called when the Mojo connection encounters an error.
904 */ 904 */
905 @Override 905 @Override
906 public void onConnectionError(MojoException e) { 906 public void onConnectionError(MojoException e) {
907 if (mClient == null) return; 907 if (mClient == null) return;
908 closeClient(); 908 closeClient();
909 closeUI(false); 909 closeUI(true);
910 recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_MOJO_CONNE CTION_ERROR); 910 recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_MOJO_CONNE CTION_ERROR);
911 } 911 }
912 912
913 /** 913 /**
914 * Called after retrieving the list of payment instruments in an app. 914 * Called after retrieving the list of payment instruments in an app.
915 */ 915 */
916 @Override 916 @Override
917 public void onInstrumentsReady(PaymentApp app, List<PaymentInstrument> instr uments) { 917 public void onInstrumentsReady(PaymentApp app, List<PaymentInstrument> instr uments) {
918 if (mClient == null) return; 918 if (mClient == null) return;
919 mPendingApps.remove(app); 919 mPendingApps.remove(app);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 * Called if unable to retrieve instrument details. 1058 * Called if unable to retrieve instrument details.
1059 */ 1059 */
1060 @Override 1060 @Override
1061 public void onInstrumentDetailsError() { 1061 public void onInstrumentDetailsError() {
1062 mUI.onPayButtonProcessingCancelled(); 1062 mUI.onPayButtonProcessingCancelled();
1063 mPaymentAppRunning = false; 1063 mPaymentAppRunning = false;
1064 } 1064 }
1065 1065
1066 /** 1066 /**
1067 * Closes the UI. If the client is still connected, then it's notified of UI hiding. 1067 * Closes the UI. If the client is still connected, then it's notified of UI hiding.
1068 *
1069 * @param immediateClose If true, then UI immediately closes. If false, the UI shows the error
1070 * message "There was an error processing your order." This message
1071 * implies that the merchant attempted to process the order, failed, and
1072 * called complete("fail") to notify the user. Therefo re, this parameter
1073 * may be "false" only when called from
1074 * PaymentRequestImpl.complete(int result) method. All other callers
1075 * should always pass "true."
1068 */ 1076 */
1069 private void closeUI(boolean immediateClose) { 1077 private void closeUI(boolean immediateClose) {
1070 if (mUI != null) { 1078 if (mUI != null) {
1071 mUI.close(immediateClose, new Runnable() { 1079 mUI.close(immediateClose, new Runnable() {
1072 @Override 1080 @Override
1073 public void run() { 1081 public void run() {
1074 if (mClient != null) mClient.onComplete(); 1082 if (mClient != null) mClient.onComplete();
1075 closeClient(); 1083 closeClient();
1076 } 1084 }
1077 }); 1085 });
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 private void recordAbortReasonHistogram(int abortReason) { 1122 private void recordAbortReasonHistogram(int abortReason) {
1115 assert abortReason < PaymentRequestMetrics.ABORT_REASON_MAX; 1123 assert abortReason < PaymentRequestMetrics.ABORT_REASON_MAX;
1116 if (mHasRecordedAbortReason) return; 1124 if (mHasRecordedAbortReason) return;
1117 1125
1118 mHasRecordedAbortReason = true; 1126 mHasRecordedAbortReason = true;
1119 RecordHistogram.recordEnumeratedHistogram( 1127 RecordHistogram.recordEnumeratedHistogram(
1120 "PaymentRequest.CheckoutFunnel.Aborted", abortReason, 1128 "PaymentRequest.CheckoutFunnel.Aborted", abortReason,
1121 PaymentRequestMetrics.ABORT_REASON_MAX); 1129 PaymentRequestMetrics.ABORT_REASON_MAX);
1122 } 1130 }
1123 } 1131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698