Commit f2dd8ddd authored by Liquan (Max) Gu's avatar Liquan (Max) Gu Committed by Chromium LUCI CQ

[WebLayer] Refactor disconnectIfNoPaymentMethodsSupported

This CL causes no behavioural changes. This CL lays the preparatory
work to create onShowCalledAndAppQueried() which will encapsulate the
following methods:
- disconnectIfNoPaymentMethodsSupported
- showAppSelector
- triggerPaymentAppUiSkipIfApplicable

Changes:
* Moved the "show called" and "app queried" conditions out of
  disconnectIfNoPaymentMethodsSupported().
* Inlined "hasAvailableApps" because it always equals
  "mBrowserPaymentRequest.hasAvailableApps()".

Bug: 1153353
Change-Id: Ia76c342daf4701b2913b7d84fafa6a210ff4fd22
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2562963Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832159}
parent 43b15b6c
......@@ -743,9 +743,7 @@ public class PaymentRequestService
mIsFinishedQueryingPaymentApps = true;
if (disconnectIfNoPaymentMethodsSupported(mBrowserPaymentRequest.hasAvailableApps())) {
return;
}
if (mIsShowCalled && disconnectIfNoPaymentMethodsSupported()) return;
// Always return false when can make payment is disabled.
mHasEnrolledInstrument &= mDelegate.prefsCanMakePayment();
......@@ -790,12 +788,11 @@ public class PaymentRequestService
/**
* If no payment methods are supported, disconnect from the client and return true.
* @param hasAvailableApps Whether any payment app is available.
* @return Whether client has been disconnected.
*/
private boolean disconnectIfNoPaymentMethodsSupported(boolean hasAvailableApps) {
if (!mIsFinishedQueryingPaymentApps || !mIsShowCalled) return false;
if (!mCanMakePayment || (mPendingApps.isEmpty() && !hasAvailableApps)) {
private boolean disconnectIfNoPaymentMethodsSupported() {
if (!mCanMakePayment
|| (mPendingApps.isEmpty() && !mBrowserPaymentRequest.hasAvailableApps())) {
// All factories have responded, but none of them have apps. It's possible to add credit
// cards, but the merchant does not support them either. The payment request must be
// rejected.
......@@ -1025,10 +1022,9 @@ public class PaymentRequestService
mIsShowWaitingForUpdatedDetails = waitForUpdatedDetails;
mJourneyLogger.setTriggerTime();
if (disconnectIfNoPaymentMethodsSupported(mBrowserPaymentRequest.hasAvailableApps())) {
return;
}
if (mIsFinishedQueryingPaymentApps) {
if (disconnectIfNoPaymentMethodsSupported()) return;
String error = mBrowserPaymentRequest.showAppSelector(mIsShowWaitingForUpdatedDetails,
mSpec.getRawTotal(), mSpec.getPaymentOptions(), mIsUserGestureShow);
if (error != null) {
......
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