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

[WebLayer] Separate continueShow

Separates CPRService#continueShow into two parts -
PRService#continueShow and CPRService#continueShow. The former is
shareable with WebLayer; the latter is chrome specific.

Bug: 1131059

Change-Id: I68848a3c31b380282ecccd1aaa579ee50e537cab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2533137
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826475}
parent 1695c58e
......@@ -504,28 +504,7 @@ public class ChromePaymentRequestService implements BrowserPaymentRequest,
// Implements BrowserPaymentRequest:
@Override
public void continueShow(PaymentDetails details) {
assert mPaymentRequestService.isShowWaitingForUpdatedDetails();
// mSpec.updateWith() can be used only when mSpec has not been destroyed.
assert !mSpec.isDestroyed();
if (!PaymentValidator.validatePaymentDetails(details)
|| !parseAndValidateDetailsFurtherIfNeeded(details)) {
mJourneyLogger.setAborted(AbortReason.INVALID_DATA_FROM_RENDERER);
disconnectFromClientWithDebugMessage(ErrorStrings.INVALID_PAYMENT_DETAILS);
return;
}
if (!TextUtils.isEmpty(details.error)) {
mJourneyLogger.setNotShown(NotShownReason.OTHER);
disconnectFromClientWithDebugMessage(ErrorStrings.INVALID_STATE);
return;
}
mSpec.updateWith(details);
mPaymentRequestService.resetWaitingForUpdatedDetails();
public void continueShow() {
ChromeActivity chromeActivity = ChromeActivity.fromWebContents(mWebContents);
if (chromeActivity == null) {
mJourneyLogger.setNotShown(NotShownReason.OTHER);
......
......@@ -194,9 +194,8 @@ public interface BrowserPaymentRequest {
/**
* Continues the unfinished part of show() that was blocked for the payment details that was
* pending to be updated.
* @param details The updated payment details that show() is waiting for.
*/
default void continueShow(PaymentDetails details) {}
default void continueShow() {}
/**
* If needed, do extra parsing and validation for details.
......
......@@ -943,6 +943,32 @@ public class PaymentRequestService
&& invokedPaymentApp.isValidForPaymentMethodData(methodName, null);
}
private void continueShow(PaymentDetails details) {
assert mIsShowWaitingForUpdatedDetails;
// mSpec.updateWith() can be used only when mSpec has not been destroyed.
assert !mSpec.isDestroyed();
if (!PaymentValidator.validatePaymentDetails(details)
|| !mBrowserPaymentRequest.parseAndValidateDetailsFurtherIfNeeded(details)) {
mJourneyLogger.setAborted(AbortReason.INVALID_DATA_FROM_RENDERER);
disconnectFromClientWithDebugMessage(
ErrorStrings.INVALID_PAYMENT_DETAILS, PaymentErrorReason.USER_CANCEL);
return;
}
if (!TextUtils.isEmpty(details.error)) {
mJourneyLogger.setNotShown(NotShownReason.OTHER);
disconnectFromClientWithDebugMessage(
ErrorStrings.INVALID_STATE, PaymentErrorReason.USER_CANCEL);
return;
}
mSpec.updateWith(details);
mIsShowWaitingForUpdatedDetails = false;
mBrowserPaymentRequest.continueShow();
}
/**
* The component part of the {@link PaymentRequest#updateWith} implementation.
* @param details The details that the merchant provides to update the payment request.
......@@ -952,7 +978,7 @@ public class PaymentRequestService
if (mIsShowWaitingForUpdatedDetails) {
// Under this condition, updateWith() is called in response to the resolution of
// show()'s PaymentDetailsUpdate promise.
mBrowserPaymentRequest.continueShow(details);
continueShow(details);
return;
}
......
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