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

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

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

Powered by Google App Engine
This is Rietveld 408576698