Chromium Code Reviews| 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 58d95b38c5a4961275e5f471aff7aaa9393b32c1..81dfcbfaff1d1835a2293b113991bc178b54ad8b 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 |
| @@ -397,8 +397,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; |
| @@ -625,6 +625,15 @@ public class PaymentRequestImpl |
| } |
| } |
| + if (queryApps.isEmpty()) { |
| + CanMakePaymentQuery query = sCanMakePaymentQueries.get(mSchemelessOriginForPaymentApp); |
| + if (query != null && query.matchesPaymentMethods(mMethodData)) { |
| + query.notifyObserversOfResponse(false); |
|
gogerald1
2017/03/03 19:40:27
How about add this logic to disconnectFromClientWi
please use gerrit instead
2017/03/09 18:05:32
Closing the connection to the current instance of
|
| + } |
| + } |
| + |
| + 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. |
| @@ -1376,7 +1385,9 @@ public class PaymentRequestImpl |
| } |
| CanMakePaymentQuery query = sCanMakePaymentQueries.get(mSchemelessOriginForPaymentApp); |
| - if (query != null) query.notifyObserversOfResponse(mCanMakePayment); |
| + if (query != null && query.matchesPaymentMethods(mMethodData)) { |
|
gogerald1
2017/03/03 19:40:27
We should no need matchesPaymentMethods if notifyO
please use gerrit instead
2017/03/09 18:05:32
This is important for the merchant that has create
|
| + query.notifyObserversOfResponse(mCanMakePayment); |
| + } |
| // The list of payment instruments is ready to display. |
| List<PaymentInstrument> sortedInstruments = new ArrayList<>(); |
| @@ -1402,15 +1413,14 @@ public class PaymentRequestImpl |
| * @return True if no payment methods are supported |
| */ |
| private boolean disconnectIfNoPaymentMethodsSupported() { |
| - if (!isFinishedQueryingPaymentApps()) return false; |
| + if (!isFinishedQueryingPaymentApps() || !mIsCurrentPaymentRequestShowing) return false; |
|
gogerald1
2017/03/03 19:40:27
This looks has been broken here https://cs.chromiu
please use gerrit instead
2017/03/09 18:05:32
I don't follow. Please explain more.
|
| 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. |