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

[WebLayer] Remove getPaymentAppsInPaymentAppList()

PaymentUiService provides two APIs, getPaymentApps,
getPaymentAppsInPaymentAppList, which returns a list of EditableOptions,
PaymentApps respectively. This CL combines the two APIs for simplicity
and made necessary changes to the use cases.

Bug: 1025619
Change-Id: I88d5e9cf8ce881fdd87266c077482ae65c32669f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2570748Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833320}
parent c3421524
......@@ -149,7 +149,7 @@ public class ChromePaymentRequestService
// Implements BrowserPaymentRequest:
@Override
public List<PaymentApp> getPaymentApps() {
return mPaymentUiService.getPaymentAppsInPaymentAppList();
return mPaymentUiService.getPaymentApps();
}
// Implements BrowserPaymentRequest:
......@@ -230,11 +230,6 @@ public class ChromePaymentRequestService
@Override
public String showOrSkipAppSelector(boolean isShowWaitingForUpdatedDetails, PaymentItem total,
boolean shouldSkipAppSelector) {
// Send AppListReady signal when all apps are created and request.show() is called.
if (PaymentRequestService.getNativeObserverForTest() != null) {
PaymentRequestService.getNativeObserverForTest().onAppListReady(
mPaymentUiService.getPaymentApps(), total);
}
ChromeActivity chromeActivity = ChromeActivity.fromWebContents(mWebContents);
if (chromeActivity == null) return ErrorStrings.ACTIVITY_NOT_FOUND;
String error = mPaymentUiService.buildPaymentRequestUI(chromeActivity,
......@@ -642,7 +637,7 @@ public class ChromePaymentRequestService
| AutofillPaymentInstrument.CompletionStatus.CREDIT_CARD_NO_BILLING_ADDRESS;
}
} else {
PaymentApp firstApp = (PaymentApp) mPaymentUiService.getPaymentApps().get(0);
PaymentApp firstApp = mPaymentUiService.getPaymentApps().get(0);
if (firstApp.isAutofillInstrument()) {
missingFields = ((AutofillPaymentInstrument) (firstApp)).getMissingFields();
}
......
......@@ -335,16 +335,8 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs
return mMerchantSupportsAutofillCards;
}
/** @return Get the payment apps of the PaymentRequest UI. */
public List<EditableOption> getPaymentApps() {
return mPaymentMethodsSection.getItems();
}
/**
* @return Get the payment apps of the PaymentRequest UI in the form of a {@link PaymentApp}
* list.
*/
public List<PaymentApp> getPaymentAppsInPaymentAppList() {
/** @return The payment apps. */
public List<PaymentApp> getPaymentApps() {
List<PaymentApp> paymentApps = new ArrayList<>();
for (EditableOption each : mPaymentMethodsSection.getItems()) {
paymentApps.add((PaymentApp) each);
......
......@@ -14,6 +14,7 @@ import org.chromium.base.annotations.JNINamespace;
import org.chromium.chrome.browser.payments.ChromePaymentRequestFactory;
import org.chromium.chrome.browser.payments.ChromePaymentRequestService;
import org.chromium.components.autofill.EditableOption;
import org.chromium.components.payments.PaymentApp;
import org.chromium.components.payments.PaymentRequestService;
import org.chromium.components.payments.PaymentRequestService.NativeObserverForTest;
import org.chromium.components.payments.PaymentUiServiceTestInterface;
......@@ -159,7 +160,7 @@ public class PaymentRequestTestBridge {
}
@Override
public void onAppListReady(List<EditableOption> apps, PaymentItem total) {
public void onAppListReady(List<PaymentApp> apps, PaymentItem total) {
String[] appLabels = new String[apps.size()];
String[] appSublabels = new String[apps.size()];
String[] appTotals = new String[apps.size()];
......
......@@ -12,7 +12,6 @@ import androidx.collection.ArrayMap;
import org.chromium.base.LocaleUtils;
import org.chromium.base.Log;
import org.chromium.components.autofill.EditableOption;
import org.chromium.components.embedder_support.util.UrlConstants;
import org.chromium.components.page_info.CertificateChainHelper;
import org.chromium.components.payments.BrowserPaymentRequest.Factory;
......@@ -159,7 +158,7 @@ public class PaymentRequestService
void onCanMakePaymentReturned();
void onHasEnrolledInstrumentCalled();
void onHasEnrolledInstrumentReturned();
void onAppListReady(@Nullable List<EditableOption> paymentApps, PaymentItem total);
void onAppListReady(@Nullable List<PaymentApp> paymentApps, PaymentItem total);
void onNotSupportedError();
void onConnectionTerminated();
void onAbortCalled();
......@@ -773,7 +772,11 @@ public class PaymentRequestService
PaymentNotShownError ensureError = ensureHasSupportedPaymentMethods();
if (ensureError != null) return ensureError;
// Send AppListReady signal when all apps are created and request.show() is called.
if (sNativeObserverForTest != null) {
sNativeObserverForTest.onAppListReady(
mBrowserPaymentRequest.getPaymentApps(), mSpec.getRawTotal());
}
boolean shouldSkip = shouldSkipAppSelector();
String showError = mBrowserPaymentRequest.showOrSkipAppSelector(
mIsShowWaitingForUpdatedDetails, mSpec.getRawTotal(), shouldSkip);
......
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