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

[WebLayer] Invokes test callbacks for minimal UI's completion

Before the CL, only the non-minimal UIs invokes the "onCompleteCalled"
"onCompleteReplied" callbacks on the test observers. Since the callback
names indicate that they are agnostic to minimal UI, they should be
applied to all UIs.

After the CL, the minimal UIs also invokes these callbacks.

This CL also cleans up the PaymentUiService#onPaymentRequestComplete
javadoc.

Bug: 1131059

Change-Id: Ic0b1a381083f9ad024c4bd84eb85e8500c034617
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2535872
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827421}
parent 3846b220
......@@ -407,14 +407,7 @@ public class ChromePaymentRequestService implements BrowserPaymentRequest,
null /* selectedShippingAddress */, null /* selectedShippingOption */, app);
}
private void onMinimalUiCompletedAndClosed() {
if (mPaymentRequestService == null) return;
mPaymentRequestService.onComplete();
close();
}
/** Called after the non-minimal UI has handled {@link #complete}. */
private void onNonMinimalUiHandledComplete() {
private void onUiCompleted() {
if (PaymentRequestService.getNativeObserverForTest() != null) {
PaymentRequestService.getNativeObserverForTest().onCompleteCalled();
}
......@@ -669,8 +662,7 @@ public class ChromePaymentRequestService implements BrowserPaymentRequest,
}
mPaymentUiService.onPaymentRequestComplete(result,
/*onMinimalUiErroredAndClosed=*/this::close, this::onMinimalUiCompletedAndClosed,
this::onNonMinimalUiHandledComplete);
/*onMinimalUiErroredAndClosed=*/this::close, this::onUiCompleted);
}
// Implement BrowserPaymentRequest:
......
......@@ -71,6 +71,7 @@ import org.chromium.content_public.browser.WebContents;
import org.chromium.payments.mojom.AddressErrors;
import org.chromium.payments.mojom.PayerDetail;
import org.chromium.payments.mojom.PayerErrors;
import org.chromium.payments.mojom.PaymentComplete;
import org.chromium.payments.mojom.PaymentCurrencyAmount;
import org.chromium.payments.mojom.PaymentDetails;
import org.chromium.payments.mojom.PaymentDetailsModifier;
......@@ -436,17 +437,16 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs
}
/**
* Called when the payment request is complete.
* @param result The status of PaymentComplete.
* Called when the merchant calls complete() to complete the payment request.
* @param result The completion status of the payment request, defined in {@link
* PaymentComplete}, provided by the merchant with
* PaymentResponse.complete(paymentResult).
* @param onMinimalUiErroredAndClosed The function called when MinimalUI errors and closes.
* @param onMinimalUiCompletedAndClosed The function called when MinimalUI completes and closes.
* @param onPaymentRequestCompleteForNonMinimalUI The function called when PaymentRequest
* completes for non-minimal UI.
* @param onUiCompleted The function called when the opened UI has handled the completion.
*/
public void onPaymentRequestComplete(int result,
MinimalUICoordinator.ErrorAndCloseObserver onMinimalUiErroredAndClosed,
MinimalUICoordinator.CompleteAndCloseObserver onMinimalUiCompletedAndClosed,
Runnable onPaymentRequestCompleteForNonMinimalUI) {
Runnable onUiCompleted) {
// Update records of the used payment app for sorting payment apps next time.
EditableOption selectedPaymentMethod = mPaymentMethodsSection.getSelectedItem();
PaymentPreferencesUtil.increasePaymentAppUseCount(selectedPaymentMethod.getIdentifier());
......@@ -454,12 +454,14 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs
selectedPaymentMethod.getIdentifier(), System.currentTimeMillis());
if (mMinimalUi != null) {
mMinimalUi.onPaymentRequestComplete(
result, onMinimalUiErroredAndClosed, onMinimalUiCompletedAndClosed);
mMinimalUi.onPaymentRequestComplete(result,
onMinimalUiErroredAndClosed, /*onCompletedAndClosed=*/
onUiCompleted::run);
return;
}
onPaymentRequestCompleteForNonMinimalUI.run();
// When non-minimal UI is opened.
onUiCompleted.run();
}
/** @return Whether PaymentRequestUI should be skipped. */
......
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