| 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 328686f33227531bc4c87d57cf3281174fa68391..88e17b922b582781f72fd6913c074d2b0e800294 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
 | 
| @@ -24,6 +24,7 @@ import org.chromium.chrome.browser.autofill.PersonalDataManager;
 | 
|  import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
 | 
|  import org.chromium.chrome.browser.favicon.FaviconHelper;
 | 
|  import org.chromium.chrome.browser.pageinfo.CertificateChainHelper;
 | 
| +import org.chromium.chrome.browser.payments.PaymentAppFactory.PaymentManifestParser;
 | 
|  import org.chromium.chrome.browser.payments.ui.Completable;
 | 
|  import org.chromium.chrome.browser.payments.ui.ContactDetailsSection;
 | 
|  import org.chromium.chrome.browser.payments.ui.LineItem;
 | 
| @@ -57,6 +58,7 @@ import org.chromium.payments.mojom.PaymentMethodData;
 | 
|  import org.chromium.payments.mojom.PaymentOptions;
 | 
|  import org.chromium.payments.mojom.PaymentRequest;
 | 
|  import org.chromium.payments.mojom.PaymentRequestClient;
 | 
| +import org.chromium.payments.mojom.PaymentRequestClient.ParsePaymentManifestResponse;
 | 
|  import org.chromium.payments.mojom.PaymentResponse;
 | 
|  import org.chromium.payments.mojom.PaymentShippingOption;
 | 
|  import org.chromium.payments.mojom.PaymentShippingType;
 | 
| @@ -78,11 +80,12 @@ import javax.annotation.Nullable;
 | 
|   * Android implementation of the PaymentRequest service defined in
 | 
|   * components/payments/payment_request.mojom.
 | 
|   */
 | 
| -public class PaymentRequestImpl
 | 
| -        implements PaymentRequest, PaymentRequestUI.Client, PaymentApp.InstrumentsCallback,
 | 
| -                   PaymentInstrument.InstrumentDetailsCallback,
 | 
| -                   PaymentAppFactory.PaymentAppCreatedCallback,
 | 
| -                   PaymentResponseHelper.PaymentResponseRequesterDelegate, FocusChangedObserver {
 | 
| +public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Client,
 | 
| +                                           PaymentApp.InstrumentsCallback,
 | 
| +                                           PaymentInstrument.InstrumentDetailsCallback,
 | 
| +                                           PaymentAppFactory.PaymentAppCreatedCallback,
 | 
| +                                           PaymentResponseHelper.PaymentResponseRequesterDelegate,
 | 
| +                                           FocusChangedObserver, PaymentManifestParser {
 | 
|      /**
 | 
|       * A test-only observer for the PaymentRequest service implementation.
 | 
|       */
 | 
| @@ -383,8 +386,9 @@ 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 /* parser */,
 | 
| +                this /* callback */);
 | 
|  
 | 
|          mRequestShipping = options != null && options.requestShipping;
 | 
|          mRequestPayerName = options != null && options.requestPayerName;
 | 
| @@ -611,6 +615,13 @@ public class PaymentRequestImpl
 | 
|              }
 | 
|          }
 | 
|  
 | 
| +        if (queryApps.isEmpty()) {
 | 
| +            CanMakePaymentQuery query = sCanMakePaymentQueries.get(mOrigin);
 | 
| +            if (query != null) query.setResponse(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.
 | 
| @@ -1254,6 +1265,7 @@ public class PaymentRequestImpl
 | 
|      }
 | 
|  
 | 
|      private void respondCanMakePaymentQuery(boolean response) {
 | 
| +        if (mClient == null) return;
 | 
|          mClient.onCanMakePayment(response ? CanMakePaymentQueryResult.CAN_MAKE_PAYMENT
 | 
|                  : CanMakePaymentQueryResult.CANNOT_MAKE_PAYMENT);
 | 
|          mJourneyLogger.setCanMakePaymentValue(mCanMakePayment);
 | 
| @@ -1396,15 +1408,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.
 | 
| @@ -1482,6 +1493,16 @@ public class PaymentRequestImpl
 | 
|      }
 | 
|  
 | 
|      @Override
 | 
| +    public void parsePaymentManifest(String content, ParsePaymentManifestResponse callback) {
 | 
| +        if (mClient == null) {
 | 
| +            callback.call(null);
 | 
| +            return;
 | 
| +        }
 | 
| +
 | 
| +        mClient.parsePaymentManifest(content, callback);
 | 
| +    }
 | 
| +
 | 
| +    @Override
 | 
|      public void onFocusChanged(@PaymentRequestUI.DataType int dataType, boolean willFocus) {
 | 
|          assert dataType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES;
 | 
|  
 | 
| 
 |