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

[WebLayer] Separates onPaymentDetailsNotUpdated

This CL separates onPaymentDetailsNotUpdated into the common part and
the chrome specific part. The common part is moved into PRService.

Change-Id: I4252f0e1227c78b3100511076ac24826b441a321
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2533413
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826490}
parent 22400017
...@@ -545,30 +545,10 @@ public class ChromePaymentRequestService implements BrowserPaymentRequest, ...@@ -545,30 +545,10 @@ public class ChromePaymentRequestService implements BrowserPaymentRequest,
} }
// Implement BrowserPaymentRequest: // Implement BrowserPaymentRequest:
/**
* Called when the merchant received a new shipping address, shipping option, or payment method
* info, but did not update the payment details in response.
*/
@Override @Override
public void onPaymentDetailsNotUpdated() { public void onPaymentDetailsNotUpdated(@Nullable String selectedShippingOptionError) {
if (mPaymentRequestService == null) return; // This method is only supposed to be called by mPaymentRequestService.
// mSpec.recomputeSpecForDetails(), mSpec.selectedShippingOptionError() can be used only assert mPaymentRequestService != null;
// when mSpec has not been destroyed.
assert !mSpec.isDestroyed();
if (mPaymentUiService.getPaymentRequestUI() == null) {
mJourneyLogger.setAborted(AbortReason.INVALID_DATA_FROM_RENDERER);
disconnectFromClientWithDebugMessage(ErrorStrings.CANNOT_UPDATE_WITHOUT_SHOW);
return;
}
mSpec.recomputeSpecForDetails();
PaymentApp invokedPaymentApp = mPaymentRequestService.getInvokedPaymentApp();
if (invokedPaymentApp != null && invokedPaymentApp.isWaitingForPaymentDetailsUpdate()) {
invokedPaymentApp.onPaymentDetailsNotUpdated();
return;
}
if (mPaymentUiService.shouldShowShippingSection() if (mPaymentUiService.shouldShowShippingSection()
&& (mPaymentUiService.getUiShippingOptions().isEmpty() && (mPaymentUiService.getUiShippingOptions().isEmpty()
...@@ -578,7 +558,7 @@ public class ChromePaymentRequestService implements BrowserPaymentRequest, ...@@ -578,7 +558,7 @@ public class ChromePaymentRequestService implements BrowserPaymentRequest,
mPaymentUiService.getShippingAddressesSection().setSelectedItemIndex( mPaymentUiService.getShippingAddressesSection().setSelectedItemIndex(
SectionInformation.INVALID_SELECTION); SectionInformation.INVALID_SELECTION);
mPaymentUiService.getShippingAddressesSection().setErrorMessage( mPaymentUiService.getShippingAddressesSection().setErrorMessage(
mSpec.selectedShippingOptionError()); selectedShippingOptionError);
} }
boolean providedInformationToPaymentRequestUI = boolean providedInformationToPaymentRequestUI =
......
...@@ -44,8 +44,11 @@ public interface BrowserPaymentRequest { ...@@ -44,8 +44,11 @@ public interface BrowserPaymentRequest {
*/ */
void onPaymentDetailsUpdated(PaymentDetails details, boolean hasNotifiedInvokedPaymentApp); void onPaymentDetailsUpdated(PaymentDetails details, boolean hasNotifiedInvokedPaymentApp);
/** The browser part of the {@link PaymentRequest#onPaymentDetailsNotUpdated} implementation. */ /**
void onPaymentDetailsNotUpdated(); * The browser part of the {@link PaymentRequest#onPaymentDetailsNotUpdated} implementation.
* @param selectedShippingOptionError The selected shipping option error, can be null.
*/
void onPaymentDetailsNotUpdated(@Nullable String selectedShippingOptionError);
/** The browser part of the {@link PaymentRequest#complete} implementation. */ /** The browser part of the {@link PaymentRequest#complete} implementation. */
void complete(int result); void complete(int result);
......
...@@ -1025,7 +1025,18 @@ public class PaymentRequestService ...@@ -1025,7 +1025,18 @@ public class PaymentRequestService
*/ */
/* package */ void onPaymentDetailsNotUpdated() { /* package */ void onPaymentDetailsNotUpdated() {
if (mBrowserPaymentRequest == null) return; if (mBrowserPaymentRequest == null) return;
mBrowserPaymentRequest.onPaymentDetailsNotUpdated(); if (!mIsCurrentPaymentRequestShowing) {
mJourneyLogger.setAborted(AbortReason.INVALID_DATA_FROM_RENDERER);
disconnectFromClientWithDebugMessage(
ErrorStrings.CANNOT_UPDATE_WITHOUT_SHOW, PaymentErrorReason.USER_CANCEL);
return;
}
mSpec.recomputeSpecForDetails();
if (mInvokedPaymentApp != null && mInvokedPaymentApp.isWaitingForPaymentDetailsUpdate()) {
mInvokedPaymentApp.onPaymentDetailsNotUpdated();
return;
}
mBrowserPaymentRequest.onPaymentDetailsNotUpdated(mSpec.selectedShippingOptionError());
} }
/** The component part of the {@link PaymentRequest#abort} implementation. */ /** The component part of the {@link PaymentRequest#abort} implementation. */
......
...@@ -30,7 +30,7 @@ public class WebLayerPaymentRequestService implements BrowserPaymentRequest { ...@@ -30,7 +30,7 @@ public class WebLayerPaymentRequestService implements BrowserPaymentRequest {
} }
@Override @Override
public void onPaymentDetailsNotUpdated() { public void onPaymentDetailsNotUpdated(String selectedShippingOptionError) {
assert false : "Not implemented yet"; assert false : "Not implemented yet";
} }
......
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