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
......@@ -510,8 +510,8 @@ public class PaymentRequestImpl
if (isMinimalUiApplicable()) {
if (mPaymentUIsManager.triggerMinimalUI(chromeActivity, mSpec.getRawTotal(),
this::onMinimalUIReady, this::onMinimalUiConfirmed,
this::onMinimalUiDismissed)) {
this::onMinimalUIReady, this::onMinimalUiConfirmed,
/*dismissObserver=*/this::onDismiss)) {
mDidRecordShowEvent = true;
mJourneyLogger.setEventOccurred(Event.SHOWN);
} else {
......@@ -566,21 +566,14 @@ public class PaymentRequestImpl
onPayClicked(null /* selectedShippingAddress */, null /* selectedShippingOption */, app);
}
private void onMinimalUiDismissed() {
onDismiss();
}
private void onMinimalUiErroredAndClosed() {
close();
}
private void onMinimalUiCompletedAndClosed() {
if (mComponentPaymentRequestImpl == null) return;
mComponentPaymentRequestImpl.onComplete();
close();
}
private void onPaymentRequestCompleteForNonMinimalUI() {
/** Called after the non-minimal UI has handled {@link #complete}. */
private void onNonMinimalUiHandledComplete() {
if (ComponentPaymentRequestImpl.getNativeObserverForTest() != null) {
ComponentPaymentRequestImpl.getNativeObserverForTest().onCompleteCalled();
}
......@@ -1220,8 +1213,9 @@ public class PaymentRequestImpl
mSpec.getRawTotal().amount.value, true /*completed*/);
}
mPaymentUIsManager.onPaymentRequestComplete(result, this::onMinimalUiErroredAndClosed,
this::onMinimalUiCompletedAndClosed, this::onPaymentRequestCompleteForNonMinimalUI);
mPaymentUIsManager.onPaymentRequestComplete(result,
/*onMinimalUiErroredAndClosed=*/this::close, this::onMinimalUiCompletedAndClosed,
this::onNonMinimalUiHandledComplete);
}
// Implement BrowserPaymentRequest:
......@@ -1768,7 +1762,7 @@ public class PaymentRequestImpl
if (mPaymentUIsManager.getMinimalUI() != null) {
mJourneyLogger.setAborted(AbortReason.ABORTED_BY_USER);
mPaymentUIsManager.getMinimalUI().showErrorAndClose(
this::onMinimalUiErroredAndClosed, R.string.payments_error_message);
/*observer=*/this::close, R.string.payments_error_message);
return;
}
......
......@@ -155,16 +155,15 @@ public class MinimalUICoordinator {
/**
* Runs when the payment request is closed.
* @param result The status of PaymentComplete.
* @param onMinimalUiErroredAndClosed The function called when MinimalUI errors and closes.
* @param onMinimalUiCompletedAndClosed The function called when MinimalUI completes and closes.
* @param onErroredAndClosed The function called when the UI errors and closes.
* @param onCompletedAndClosed The function called when the UI completes and closes.
*/
public void onPaymentRequestComplete(int result,
ErrorAndCloseObserver onMinimalUiErroredAndClosed,
CompleteAndCloseObserver onMinimalUiCompletedAndClosed) {
public void onPaymentRequestComplete(int result, ErrorAndCloseObserver onErroredAndClosed,
CompleteAndCloseObserver onCompletedAndClosed) {
if (result == PaymentComplete.FAIL) {
showErrorAndClose(onMinimalUiErroredAndClosed, R.string.payments_error_message);
showErrorAndClose(onErroredAndClosed, R.string.payments_error_message);
} 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