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

[WebLayer] pass waitForUpdatedDetails to ui by parameter

Before the CL, PaymentRequestUi takes waitForUpdatedDetails from
CPRService by PaymentUiService.Delegate.waitForUpdatedDetails(). Using
a delegate is not as simplified as a method parameter.

After the CL, PaymentRequestUi takes the value by method parameters.

Change-Id: Icb61a32c6df6d6f2b01d6f6669483cd4b2111b30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2527543
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825581}
parent 9c1f87c5
......@@ -344,7 +344,7 @@ public class ChromePaymentRequestService implements BrowserPaymentRequest,
ChromeActivity chromeActivity = ChromeActivity.fromWebContents(mWebContents);
if (quitShowIfActivityNotFound(chromeActivity) || !buildUI(chromeActivity)) return false;
if (!mPaymentUiService.shouldSkipShowingPaymentRequestUi() && mSkipToGPayHelper == null) {
mPaymentUiService.getPaymentRequestUI().show();
mPaymentUiService.getPaymentRequestUI().show(mWaitForUpdatedDetails);
}
return true;
}
......@@ -803,12 +803,6 @@ public class ChromePaymentRequestService implements BrowserPaymentRequest,
return mSkipToGPayHelper == null || mSkipToGPayHelper.setShippingOptionIfValid(details);
}
// Implements PaymentUiService.Delegate:
@Override
public boolean waitForUpdatedDetails() {
return mWaitForUpdatedDetails;
}
// Implements PaymentUiService.Delegate:
@Override
public void recordShowEventAndTransactionAmount() {
......
......@@ -98,8 +98,11 @@ public class PaymentRequestUI implements DimmingDialog.OnDismissListener, View.O
public interface Client {
/**
* Asynchronously returns the default payment information.
* @param waitForUpdatedDetails Whether the payment details is pending for updating.
* @param callback Retrieves the data to show in the initial PaymentRequest UI.
*/
void getDefaultPaymentInformation(Callback<PaymentInformation> callback);
void getDefaultPaymentInformation(
boolean waitForUpdatedDetails, Callback<PaymentInformation> callback);
/**
* Asynchronously returns the full bill. Includes the total price and its breakdown into
......@@ -428,35 +431,38 @@ public class PaymentRequestUI implements DimmingDialog.OnDismissListener, View.O
/**
* Shows the PaymentRequest UI. This will dim the background behind the PaymentRequest UI.
* @param waitForUpdatedDetails Whether the payment details is pending to be updated.
*/
public void show() {
public void show(boolean waitForUpdatedDetails) {
mDialog.addBottomSheetView(mRequestView);
mPaymentUisShowStateReconciler.showPaymentRequestDialogWhenNoBottomSheet();
mClient.getDefaultPaymentInformation(new Callback<PaymentInformation>() {
@Override
public void onResult(PaymentInformation result) {
updateOrderSummarySection(result.getShoppingCart());
if (mClient.shouldShowShippingSection()) {
updateSection(DataType.SHIPPING_ADDRESSES, result.getShippingAddresses());
updateSection(DataType.SHIPPING_OPTIONS, result.getShippingOptions());
}
if (mClient.shouldShowContactSection()) {
updateSection(DataType.CONTACT_DETAILS, result.getContactDetails());
}
mPaymentMethodSection.setDisplaySummaryInSingleLineInNormalMode(
result.getPaymentMethods()
.getDisplaySelectedItemSummaryInSingleLineInNormalMode());
updateSection(DataType.PAYMENT_METHODS, result.getPaymentMethods());
updatePayButtonEnabled();
// Hide the loading indicators and show the real sections.
changeSpinnerVisibility(false);
mRequestView.addOnLayoutChangeListener(new SheetEnlargingAnimator(false));
}
});
mClient.getDefaultPaymentInformation(
waitForUpdatedDetails, new Callback<PaymentInformation>() {
@Override
public void onResult(PaymentInformation result) {
updateOrderSummarySection(result.getShoppingCart());
if (mClient.shouldShowShippingSection()) {
updateSection(
DataType.SHIPPING_ADDRESSES, result.getShippingAddresses());
updateSection(DataType.SHIPPING_OPTIONS, result.getShippingOptions());
}
if (mClient.shouldShowContactSection()) {
updateSection(DataType.CONTACT_DETAILS, result.getContactDetails());
}
mPaymentMethodSection.setDisplaySummaryInSingleLineInNormalMode(
result.getPaymentMethods()
.getDisplaySelectedItemSummaryInSingleLineInNormalMode());
updateSection(DataType.PAYMENT_METHODS, result.getPaymentMethods());
updatePayButtonEnabled();
// Hide the loading indicators and show the real sections.
changeSpinnerVisibility(false);
mRequestView.addOnLayoutChangeListener(new SheetEnlargingAnimator(false));
}
});
}
/**
......
......@@ -167,8 +167,6 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs
* called.
*/
boolean wasRetryCalled();
/** @return Whether to wait for updated payment details. */
boolean waitForUpdatedDetails();
// TODO(crbug.com/1144165): The return semantics is not intuitive for this method; the
// method should not take the selectedShippingAddress, selectedShippingOption parameters of
......@@ -1490,14 +1488,10 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs
}
}
/**
* The implementation of {@link PaymentRequestUI.Client#getDefaultPaymentInformation}.
* @param callback Retrieves the data to show in the initial PaymentRequest UI.
*/
// Implements PaymentUiService.Delegate:
// Implements PaymentRequestUI.Client:
@Override
public void getDefaultPaymentInformation(Callback<PaymentInformation> callback) {
boolean waitForUpdatedDetails = mDelegate.waitForUpdatedDetails();
public void getDefaultPaymentInformation(
boolean waitForUpdatedDetails, Callback<PaymentInformation> callback) {
mPaymentInformationCallback = callback;
if (waitForUpdatedDetails) 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