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, ...@@ -407,14 +407,7 @@ public class ChromePaymentRequestService implements BrowserPaymentRequest,
null /* selectedShippingAddress */, null /* selectedShippingOption */, app); null /* selectedShippingAddress */, null /* selectedShippingOption */, app);
} }
private void onMinimalUiCompletedAndClosed() { private void onUiCompleted() {
if (mPaymentRequestService == null) return;
mPaymentRequestService.onComplete();
close();
}
/** Called after the non-minimal UI has handled {@link #complete}. */
private void onNonMinimalUiHandledComplete() {
if (PaymentRequestService.getNativeObserverForTest() != null) { if (PaymentRequestService.getNativeObserverForTest() != null) {
PaymentRequestService.getNativeObserverForTest().onCompleteCalled(); PaymentRequestService.getNativeObserverForTest().onCompleteCalled();
} }
...@@ -669,8 +662,7 @@ public class ChromePaymentRequestService implements BrowserPaymentRequest, ...@@ -669,8 +662,7 @@ public class ChromePaymentRequestService implements BrowserPaymentRequest,
} }
mPaymentUiService.onPaymentRequestComplete(result, mPaymentUiService.onPaymentRequestComplete(result,
/*onMinimalUiErroredAndClosed=*/this::close, this::onMinimalUiCompletedAndClosed, /*onMinimalUiErroredAndClosed=*/this::close, this::onUiCompleted);
this::onNonMinimalUiHandledComplete);
} }
// Implement BrowserPaymentRequest: // Implement BrowserPaymentRequest:
......
...@@ -71,6 +71,7 @@ import org.chromium.content_public.browser.WebContents; ...@@ -71,6 +71,7 @@ import org.chromium.content_public.browser.WebContents;
import org.chromium.payments.mojom.AddressErrors; import org.chromium.payments.mojom.AddressErrors;
import org.chromium.payments.mojom.PayerDetail; import org.chromium.payments.mojom.PayerDetail;
import org.chromium.payments.mojom.PayerErrors; import org.chromium.payments.mojom.PayerErrors;
import org.chromium.payments.mojom.PaymentComplete;
import org.chromium.payments.mojom.PaymentCurrencyAmount; import org.chromium.payments.mojom.PaymentCurrencyAmount;
import org.chromium.payments.mojom.PaymentDetails; import org.chromium.payments.mojom.PaymentDetails;
import org.chromium.payments.mojom.PaymentDetailsModifier; import org.chromium.payments.mojom.PaymentDetailsModifier;
...@@ -436,17 +437,16 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs ...@@ -436,17 +437,16 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs
} }
/** /**
* Called when the payment request is complete. * Called when the merchant calls complete() to complete the payment request.
* @param result The status of PaymentComplete. * @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 onMinimalUiErroredAndClosed The function called when MinimalUI errors and closes.
* @param onMinimalUiCompletedAndClosed The function called when MinimalUI completes and closes. * @param onUiCompleted The function called when the opened UI has handled the completion.
* @param onPaymentRequestCompleteForNonMinimalUI The function called when PaymentRequest
* completes for non-minimal UI.
*/ */
public void onPaymentRequestComplete(int result, public void onPaymentRequestComplete(int result,
MinimalUICoordinator.ErrorAndCloseObserver onMinimalUiErroredAndClosed, MinimalUICoordinator.ErrorAndCloseObserver onMinimalUiErroredAndClosed,
MinimalUICoordinator.CompleteAndCloseObserver onMinimalUiCompletedAndClosed, Runnable onUiCompleted) {
Runnable onPaymentRequestCompleteForNonMinimalUI) {
// Update records of the used payment app for sorting payment apps next time. // Update records of the used payment app for sorting payment apps next time.
EditableOption selectedPaymentMethod = mPaymentMethodsSection.getSelectedItem(); EditableOption selectedPaymentMethod = mPaymentMethodsSection.getSelectedItem();
PaymentPreferencesUtil.increasePaymentAppUseCount(selectedPaymentMethod.getIdentifier()); PaymentPreferencesUtil.increasePaymentAppUseCount(selectedPaymentMethod.getIdentifier());
...@@ -454,12 +454,14 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs ...@@ -454,12 +454,14 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs
selectedPaymentMethod.getIdentifier(), System.currentTimeMillis()); selectedPaymentMethod.getIdentifier(), System.currentTimeMillis());
if (mMinimalUi != null) { if (mMinimalUi != null) {
mMinimalUi.onPaymentRequestComplete( mMinimalUi.onPaymentRequestComplete(result,
result, onMinimalUiErroredAndClosed, onMinimalUiCompletedAndClosed); onMinimalUiErroredAndClosed, /*onCompletedAndClosed=*/
onUiCompleted::run);
return; return;
} }
onPaymentRequestCompleteForNonMinimalUI.run(); // When non-minimal UI is opened.
onUiCompleted.run();
} }
/** @return Whether PaymentRequestUI should be skipped. */ /** @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