| Index: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
|
| index 83ea538b76d4b023fafaec50174fc9ebdafb1322..fa2b40a2a3a37f655aaad08d427451d2c4dc9d3e 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
|
| @@ -44,6 +44,8 @@ import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType;
|
| import org.chromium.chrome.browser.tabmodel.TabModelObserver;
|
| import org.chromium.chrome.browser.tabmodel.TabModelSelector;
|
| import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver;
|
| +import org.chromium.components.payments.CurrencyFormatter;
|
| +import org.chromium.components.payments.PaymentValidator;
|
| import org.chromium.components.url_formatter.UrlFormatter;
|
| import org.chromium.content_public.browser.WebContents;
|
| import org.chromium.mojo.system.MojoException;
|
| @@ -403,8 +405,8 @@ public class PaymentRequestImpl
|
|
|
| if (!parseAndValidateDetailsOrDisconnectFromClient(details)) return;
|
|
|
| - PaymentAppFactory.getInstance().create(
|
| - mWebContents, Collections.unmodifiableSet(mMethodData.keySet()), this);
|
| + PaymentAppFactory.getInstance().create(mWebContents,
|
| + Collections.unmodifiableSet(mMethodData.keySet()), this /* callback */);
|
|
|
| mRequestShipping = options != null && options.requestShipping;
|
| mRequestPayerName = options != null && options.requestPayerName;
|
| @@ -632,6 +634,15 @@ public class PaymentRequestImpl
|
| }
|
| }
|
|
|
| + if (queryApps.isEmpty()) {
|
| + CanMakePaymentQuery query = sCanMakePaymentQueries.get(mSchemelessOriginForPaymentApp);
|
| + if (query != null && query.matchesPaymentMethods(mMethodData)) {
|
| + query.notifyObserversOfResponse(false);
|
| + }
|
| + }
|
| +
|
| + if (disconnectIfNoPaymentMethodsSupported()) return;
|
| +
|
| // Query instruments after mMerchantSupportsAutofillPaymentInstruments has been initialized,
|
| // so a fast response from a non-autofill payment app at the front of the app list does not
|
| // cause NOT_SUPPORTED payment rejection.
|
| @@ -1386,7 +1397,9 @@ public class PaymentRequestImpl
|
| }
|
|
|
| CanMakePaymentQuery query = sCanMakePaymentQueries.get(mSchemelessOriginForPaymentApp);
|
| - if (query != null) query.notifyObserversOfResponse(mCanMakePayment);
|
| + if (query != null && query.matchesPaymentMethods(mMethodData)) {
|
| + query.notifyObserversOfResponse(mCanMakePayment);
|
| + }
|
|
|
| // The list of payment instruments is ready to display.
|
| List<PaymentInstrument> sortedInstruments = new ArrayList<>();
|
| @@ -1412,15 +1425,14 @@ public class PaymentRequestImpl
|
| * @return True if no payment methods are supported
|
| */
|
| private boolean disconnectIfNoPaymentMethodsSupported() {
|
| - if (!isFinishedQueryingPaymentApps()) return false;
|
| + if (!isFinishedQueryingPaymentApps() || !mIsCurrentPaymentRequestShowing) return false;
|
|
|
| boolean foundPaymentMethods = mPaymentMethodsSection != null
|
| && !mPaymentMethodsSection.isEmpty();
|
| boolean userCanAddCreditCard = mMerchantSupportsAutofillPaymentInstruments
|
| && !ChromeFeatureList.isEnabled(ChromeFeatureList.NO_CREDIT_CARD_ABORT);
|
|
|
| - if (!mArePaymentMethodsSupported || (mIsCurrentPaymentRequestShowing && !foundPaymentMethods
|
| - && !userCanAddCreditCard)) {
|
| + if (!mArePaymentMethodsSupported || (!foundPaymentMethods && !userCanAddCreditCard)) {
|
| // All payment apps have responded, but none of them have instruments. It's possible to
|
| // add credit cards, but the merchant does not support them either. The payment request
|
| // must be rejected.
|
|
|