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, ...@@ -344,7 +344,7 @@ public class ChromePaymentRequestService implements BrowserPaymentRequest,
ChromeActivity chromeActivity = ChromeActivity.fromWebContents(mWebContents); ChromeActivity chromeActivity = ChromeActivity.fromWebContents(mWebContents);
if (quitShowIfActivityNotFound(chromeActivity) || !buildUI(chromeActivity)) return false; if (quitShowIfActivityNotFound(chromeActivity) || !buildUI(chromeActivity)) return false;
if (!mPaymentUiService.shouldSkipShowingPaymentRequestUi() && mSkipToGPayHelper == null) { if (!mPaymentUiService.shouldSkipShowingPaymentRequestUi() && mSkipToGPayHelper == null) {
mPaymentUiService.getPaymentRequestUI().show(); mPaymentUiService.getPaymentRequestUI().show(mWaitForUpdatedDetails);
} }
return true; return true;
} }
...@@ -803,12 +803,6 @@ public class ChromePaymentRequestService implements BrowserPaymentRequest, ...@@ -803,12 +803,6 @@ public class ChromePaymentRequestService implements BrowserPaymentRequest,
return mSkipToGPayHelper == null || mSkipToGPayHelper.setShippingOptionIfValid(details); return mSkipToGPayHelper == null || mSkipToGPayHelper.setShippingOptionIfValid(details);
} }
// Implements PaymentUiService.Delegate:
@Override
public boolean waitForUpdatedDetails() {
return mWaitForUpdatedDetails;
}
// Implements PaymentUiService.Delegate: // Implements PaymentUiService.Delegate:
@Override @Override
public void recordShowEventAndTransactionAmount() { public void recordShowEventAndTransactionAmount() {
......
...@@ -98,8 +98,11 @@ public class PaymentRequestUI implements DimmingDialog.OnDismissListener, View.O ...@@ -98,8 +98,11 @@ public class PaymentRequestUI implements DimmingDialog.OnDismissListener, View.O
public interface Client { public interface Client {
/** /**
* Asynchronously returns the default payment information. * 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 * 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 ...@@ -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. * 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); mDialog.addBottomSheetView(mRequestView);
mPaymentUisShowStateReconciler.showPaymentRequestDialogWhenNoBottomSheet(); mPaymentUisShowStateReconciler.showPaymentRequestDialogWhenNoBottomSheet();
mClient.getDefaultPaymentInformation(new Callback<PaymentInformation>() { mClient.getDefaultPaymentInformation(
@Override waitForUpdatedDetails, new Callback<PaymentInformation>() {
public void onResult(PaymentInformation result) { @Override
updateOrderSummarySection(result.getShoppingCart()); public void onResult(PaymentInformation result) {
updateOrderSummarySection(result.getShoppingCart());
if (mClient.shouldShowShippingSection()) {
updateSection(DataType.SHIPPING_ADDRESSES, result.getShippingAddresses()); if (mClient.shouldShowShippingSection()) {
updateSection(DataType.SHIPPING_OPTIONS, result.getShippingOptions()); updateSection(
} DataType.SHIPPING_ADDRESSES, result.getShippingAddresses());
updateSection(DataType.SHIPPING_OPTIONS, result.getShippingOptions());
if (mClient.shouldShowContactSection()) { }
updateSection(DataType.CONTACT_DETAILS, result.getContactDetails());
} if (mClient.shouldShowContactSection()) {
updateSection(DataType.CONTACT_DETAILS, result.getContactDetails());
mPaymentMethodSection.setDisplaySummaryInSingleLineInNormalMode( }
result.getPaymentMethods()
.getDisplaySelectedItemSummaryInSingleLineInNormalMode()); mPaymentMethodSection.setDisplaySummaryInSingleLineInNormalMode(
updateSection(DataType.PAYMENT_METHODS, result.getPaymentMethods()); result.getPaymentMethods()
updatePayButtonEnabled(); .getDisplaySelectedItemSummaryInSingleLineInNormalMode());
updateSection(DataType.PAYMENT_METHODS, result.getPaymentMethods());
// Hide the loading indicators and show the real sections. updatePayButtonEnabled();
changeSpinnerVisibility(false);
mRequestView.addOnLayoutChangeListener(new SheetEnlargingAnimator(false)); // 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 ...@@ -167,8 +167,6 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs
* called. * called.
*/ */
boolean wasRetryCalled(); 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 // TODO(crbug.com/1144165): The return semantics is not intuitive for this method; the
// method should not take the selectedShippingAddress, selectedShippingOption parameters of // method should not take the selectedShippingAddress, selectedShippingOption parameters of
...@@ -1490,14 +1488,10 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs ...@@ -1490,14 +1488,10 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs
} }
} }
/** // Implements PaymentRequestUI.Client:
* The implementation of {@link PaymentRequestUI.Client#getDefaultPaymentInformation}.
* @param callback Retrieves the data to show in the initial PaymentRequest UI.
*/
// Implements PaymentUiService.Delegate:
@Override @Override
public void getDefaultPaymentInformation(Callback<PaymentInformation> callback) { public void getDefaultPaymentInformation(
boolean waitForUpdatedDetails = mDelegate.waitForUpdatedDetails(); boolean waitForUpdatedDetails, Callback<PaymentInformation> callback) {
mPaymentInformationCallback = callback; mPaymentInformationCallback = callback;
if (waitForUpdatedDetails) return; 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