Commit a630b5b2 authored by Liquan (Max) Gu's avatar Liquan (Max) Gu Committed by Commit Bot

[PRImpl] Clean-up MinimalUI refactoring

Change:
* Inline onMinimalUiDismissed() and onMinimalUiErroredAndClosed() as
they are just one-liners,

Bug: 1108099

Change-Id: I77097396926519566dd4e2ac778818f4d6ba990d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2404752
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarSahel Sharify <sahel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806661}
parent b5590351
...@@ -511,7 +511,7 @@ public class PaymentRequestImpl ...@@ -511,7 +511,7 @@ public class PaymentRequestImpl
if (isMinimalUiApplicable()) { if (isMinimalUiApplicable()) {
if (mPaymentUIsManager.triggerMinimalUI(chromeActivity, mSpec.getRawTotal(), if (mPaymentUIsManager.triggerMinimalUI(chromeActivity, mSpec.getRawTotal(),
this::onMinimalUIReady, this::onMinimalUiConfirmed, this::onMinimalUIReady, this::onMinimalUiConfirmed,
this::onMinimalUiDismissed)) { /*dismissObserver=*/this::onDismiss)) {
mDidRecordShowEvent = true; mDidRecordShowEvent = true;
mJourneyLogger.setEventOccurred(Event.SHOWN); mJourneyLogger.setEventOccurred(Event.SHOWN);
} else { } else {
...@@ -566,21 +566,14 @@ public class PaymentRequestImpl ...@@ -566,21 +566,14 @@ public class PaymentRequestImpl
onPayClicked(null /* selectedShippingAddress */, null /* selectedShippingOption */, app); onPayClicked(null /* selectedShippingAddress */, null /* selectedShippingOption */, app);
} }
private void onMinimalUiDismissed() {
onDismiss();
}
private void onMinimalUiErroredAndClosed() {
close();
}
private void onMinimalUiCompletedAndClosed() { private void onMinimalUiCompletedAndClosed() {
if (mComponentPaymentRequestImpl == null) return; if (mComponentPaymentRequestImpl == null) return;
mComponentPaymentRequestImpl.onComplete(); mComponentPaymentRequestImpl.onComplete();
close(); close();
} }
private void onPaymentRequestCompleteForNonMinimalUI() { /** Called after the non-minimal UI has handled {@link #complete}. */
private void onNonMinimalUiHandledComplete() {
if (ComponentPaymentRequestImpl.getNativeObserverForTest() != null) { if (ComponentPaymentRequestImpl.getNativeObserverForTest() != null) {
ComponentPaymentRequestImpl.getNativeObserverForTest().onCompleteCalled(); ComponentPaymentRequestImpl.getNativeObserverForTest().onCompleteCalled();
} }
...@@ -1220,8 +1213,9 @@ public class PaymentRequestImpl ...@@ -1220,8 +1213,9 @@ public class PaymentRequestImpl
mSpec.getRawTotal().amount.value, true /*completed*/); mSpec.getRawTotal().amount.value, true /*completed*/);
} }
mPaymentUIsManager.onPaymentRequestComplete(result, this::onMinimalUiErroredAndClosed, mPaymentUIsManager.onPaymentRequestComplete(result,
this::onMinimalUiCompletedAndClosed, this::onPaymentRequestCompleteForNonMinimalUI); /*onMinimalUiErroredAndClosed=*/this::close, this::onMinimalUiCompletedAndClosed,
this::onNonMinimalUiHandledComplete);
} }
// Implement BrowserPaymentRequest: // Implement BrowserPaymentRequest:
...@@ -1768,7 +1762,7 @@ public class PaymentRequestImpl ...@@ -1768,7 +1762,7 @@ public class PaymentRequestImpl
if (mPaymentUIsManager.getMinimalUI() != null) { if (mPaymentUIsManager.getMinimalUI() != null) {
mJourneyLogger.setAborted(AbortReason.ABORTED_BY_USER); mJourneyLogger.setAborted(AbortReason.ABORTED_BY_USER);
mPaymentUIsManager.getMinimalUI().showErrorAndClose( mPaymentUIsManager.getMinimalUI().showErrorAndClose(
this::onMinimalUiErroredAndClosed, R.string.payments_error_message); /*observer=*/this::close, R.string.payments_error_message);
return; return;
} }
......
...@@ -155,16 +155,15 @@ public class MinimalUICoordinator { ...@@ -155,16 +155,15 @@ public class MinimalUICoordinator {
/** /**
* Runs when the payment request is closed. * Runs when the payment request is closed.
* @param result The status of PaymentComplete. * @param result The status of PaymentComplete.
* @param onMinimalUiErroredAndClosed The function called when MinimalUI errors and closes. * @param onErroredAndClosed The function called when the UI errors and closes.
* @param onMinimalUiCompletedAndClosed The function called when MinimalUI completes and closes. * @param onCompletedAndClosed The function called when the UI completes and closes.
*/ */
public void onPaymentRequestComplete(int result, public void onPaymentRequestComplete(int result, ErrorAndCloseObserver onErroredAndClosed,
ErrorAndCloseObserver onMinimalUiErroredAndClosed, CompleteAndCloseObserver onCompletedAndClosed) {
CompleteAndCloseObserver onMinimalUiCompletedAndClosed) {
if (result == PaymentComplete.FAIL) { if (result == PaymentComplete.FAIL) {
showErrorAndClose(onMinimalUiErroredAndClosed, R.string.payments_error_message); showErrorAndClose(onErroredAndClosed, R.string.payments_error_message);
} else { } else {
showCompleteAndClose(onMinimalUiCompletedAndClosed); showCompleteAndClose(onCompletedAndClosed);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment