Commit f902085a authored by Liquan (Max) Gu's avatar Liquan (Max) Gu Committed by Commit Bot

[WebLayer] Moves MethodChecker

Moves MethodChecker from CPRService into PRService.

Bug: 1131059

Change-Id: Iedc3fb57a884e957b715d89b89ec356508032f38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2530799Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826416}
parent ec967613
......@@ -30,8 +30,6 @@ import org.chromium.components.payments.PackageManagerDelegate;
import org.chromium.components.payments.PaymentApp;
import org.chromium.components.payments.PaymentAppService;
import org.chromium.components.payments.PaymentAppType;
import org.chromium.components.payments.PaymentDetailsConverter;
import org.chromium.components.payments.PaymentDetailsConverter.MethodChecker;
import org.chromium.components.payments.PaymentDetailsUpdateServiceHelper;
import org.chromium.components.payments.PaymentFeatureList;
import org.chromium.components.payments.PaymentHandlerHost;
......@@ -69,7 +67,6 @@ import java.util.Set;
* living in {@link PaymentRequestService}.
*/
public class ChromePaymentRequestService implements BrowserPaymentRequest,
PaymentDetailsConverter.MethodChecker,
PaymentUiService.Delegate, PaymentUIsObserver {
// Null-check is necessary because retainers of ChromePaymentRequestService could still
......@@ -477,19 +474,6 @@ public class ChromePaymentRequestService implements BrowserPaymentRequest,
return paymentHandlerWebContents;
}
@Override
public boolean isInvokedInstrumentValidForPaymentMethodIdentifier(
String methodName, PaymentApp invokedPaymentApp) {
return invokedPaymentApp != null
&& invokedPaymentApp.isValidForPaymentMethodData(methodName, null);
}
// Implement BrowserPaymentRequest:
@Override
public MethodChecker getMethodChecker() {
return this;
}
// Implement BrowserPaymentRequest:
@Override
public void onPaymentDetailsUpdated(
......
......@@ -6,7 +6,6 @@ package org.chromium.components.payments;
import androidx.annotation.Nullable;
import org.chromium.components.payments.PaymentDetailsConverter.MethodChecker;
import org.chromium.content_public.browser.WebContents;
import org.chromium.payments.mojom.PaymentDetails;
import org.chromium.payments.mojom.PaymentMethodData;
......@@ -207,12 +206,4 @@ public interface BrowserPaymentRequest {
default boolean parseAndValidateDetailsFurtherIfNeeded(PaymentDetails details) {
return true;
}
/**
* @return The {@link MethodChecker} that can check whether the invoked payment app is valid for
* the given payment method identifier.
*/
default MethodChecker getMethodChecker() {
return null;
}
}
......@@ -60,7 +60,7 @@ import java.util.Map;
public class PaymentRequestService
implements PaymentAppFactoryDelegate, PaymentAppFactoryParams,
PaymentRequestUpdateEventListener, PaymentApp.AbortCallback,
PaymentApp.InstrumentDetailsCallback,
PaymentApp.InstrumentDetailsCallback, PaymentDetailsConverter.MethodChecker,
PaymentResponseHelperInterface.PaymentResponseResultCallback {
private static final String TAG = "PaymentRequestServ";
/**
......@@ -935,6 +935,14 @@ public class PaymentRequestService
mBrowserPaymentRequest.triggerPaymentAppUiSkipIfApplicable();
}
// Implements PaymentDetailsConverter.MethodChecker:
@Override
public boolean isInvokedInstrumentValidForPaymentMethodIdentifier(
String methodName, PaymentApp invokedPaymentApp) {
return invokedPaymentApp != null
&& invokedPaymentApp.isValidForPaymentMethodData(methodName, null);
}
/**
* The component part of the {@link PaymentRequest#updateWith} implementation.
* @param details The details that the merchant provides to update the payment request.
......@@ -981,8 +989,7 @@ public class PaymentRequestService
// updated price in its UI.
mInvokedPaymentApp.updateWith(
PaymentDetailsConverter.convertToPaymentRequestDetailsUpdate(details,
/*methodChecker=*/mBrowserPaymentRequest.getMethodChecker(),
mInvokedPaymentApp));
/*methodChecker=*/this, mInvokedPaymentApp));
}
mBrowserPaymentRequest.onPaymentDetailsUpdated(details, hasNotifiedInvokedPaymentApp);
}
......
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