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

Save a use of mParams.hasClose() in PaymentUiService

Following up on CL[1], this CL is to save a use of mParams.hasClose()
on PaymentUiService#onlySingleAppCanProvideAllRequiredInformation() by
passing the paymentOptions from ChromePaymentRequestService.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2422783/4..7/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentUIsManager.java#b1403

Change-Id: I02161365bb4d73a6918341174f848fa64d4f6a80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2481357
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarSahel Sharify <sahel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818317}
parent 569e6686
...@@ -413,7 +413,8 @@ public class ChromePaymentRequestService ...@@ -413,7 +413,8 @@ public class ChromePaymentRequestService
// request.show() is called. // request.show() is called.
mPaymentUiService.calculateWhetherShouldSkipShowingPaymentRequestUi(mIsUserGestureShow, mPaymentUiService.calculateWhetherShouldSkipShowingPaymentRequestUi(mIsUserGestureShow,
mURLPaymentMethodIdentifiersSupported, mURLPaymentMethodIdentifiersSupported,
mPaymentRequestService.skipUiForNonUrlPaymentMethodIdentifiers()); mPaymentRequestService.skipUiForNonUrlPaymentMethodIdentifiers(),
mPaymentOptions);
if (!buildUI(chromeActivity)) return; if (!buildUI(chromeActivity)) return;
if (!mPaymentUiService.shouldSkipShowingPaymentRequestUi() if (!mPaymentUiService.shouldSkipShowingPaymentRequestUi()
&& mSkipToGPayHelper == null) { && mSkipToGPayHelper == null) {
...@@ -1570,7 +1571,8 @@ public class ChromePaymentRequestService ...@@ -1570,7 +1571,8 @@ public class ChromePaymentRequestService
assert mIsFinishedQueryingPaymentApps; assert mIsFinishedQueryingPaymentApps;
mPaymentUiService.calculateWhetherShouldSkipShowingPaymentRequestUi(mIsUserGestureShow, mPaymentUiService.calculateWhetherShouldSkipShowingPaymentRequestUi(mIsUserGestureShow,
mURLPaymentMethodIdentifiersSupported, mURLPaymentMethodIdentifiersSupported,
mPaymentRequestService.skipUiForNonUrlPaymentMethodIdentifiers()); mPaymentRequestService.skipUiForNonUrlPaymentMethodIdentifiers(),
mPaymentOptions);
if (!buildUI(chromeActivity)) return; if (!buildUI(chromeActivity)) return;
if (!mPaymentUiService.shouldSkipShowingPaymentRequestUi() if (!mPaymentUiService.shouldSkipShowingPaymentRequestUi()
&& mSkipToGPayHelper == null) { && mSkipToGPayHelper == null) {
......
...@@ -1385,14 +1385,14 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs ...@@ -1385,14 +1385,14 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs
} }
/** /**
* @param options The payment options specified in the payment request.
* @return true when there is exactly one available payment app which can provide all requested * @return true when there is exactly one available payment app which can provide all requested
* information including shipping address and payer's contact information whenever needed. * information including shipping address and payer's contact information whenever needed.
*/ */
public boolean onlySingleAppCanProvideAllRequiredInformation() { public boolean onlySingleAppCanProvideAllRequiredInformation(PaymentOptions options) {
assert mPaymentMethodsSection != null; assert mPaymentMethodsSection != null;
if (mParams.hasClosed()) return false; if (!PaymentOptionsUtils.requestAnyInformation(options)) {
if (!PaymentOptionsUtils.requestAnyInformation(mParams.getPaymentOptions())) {
return mPaymentMethodsSection.getSize() == 1 return mPaymentMethodsSection.getSize() == 1
&& !((PaymentApp) mPaymentMethodsSection.getItem(0)).isAutofillInstrument(); && !((PaymentApp) mPaymentMethodsSection.getItem(0)).isAutofillInstrument();
} }
...@@ -1401,11 +1401,10 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs ...@@ -1401,11 +1401,10 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs
int sectionSize = mPaymentMethodsSection.getSize(); int sectionSize = mPaymentMethodsSection.getSize();
for (int i = 0; i < sectionSize; i++) { for (int i = 0; i < sectionSize; i++) {
PaymentApp app = (PaymentApp) mPaymentMethodsSection.getItem(i); PaymentApp app = (PaymentApp) mPaymentMethodsSection.getItem(i);
if ((!mParams.getPaymentOptions().requestShipping || app.handlesShippingAddress()) if ((!options.requestShipping || app.handlesShippingAddress())
&& (!mParams.getPaymentOptions().requestPayerName || app.handlesPayerName()) && (!options.requestPayerName || app.handlesPayerName())
&& (!mParams.getPaymentOptions().requestPayerPhone || app.handlesPayerPhone()) && (!options.requestPayerPhone || app.handlesPayerPhone())
&& (!mParams.getPaymentOptions().requestPayerEmail && (!options.requestPayerEmail || app.handlesPayerEmail())) {
|| app.handlesPayerEmail())) {
// There is more than one available app that can provide all merchant requested // There is more than one available app that can provide all merchant requested
// information information. // information information.
if (anAppCanProvideAllInfo) return false; if (anAppCanProvideAllInfo) return false;
...@@ -1448,10 +1447,11 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs ...@@ -1448,10 +1447,11 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs
* identifier is specified in payment request. * identifier is specified in payment request.
* @param skipUiForNonUrlPaymentMethodIdentifiers True when skip UI is available for non-url * @param skipUiForNonUrlPaymentMethodIdentifiers True when skip UI is available for non-url
* based payment method identifiers (e.g., basic-card). * based payment method identifiers (e.g., basic-card).
* @param options The payment options specified in the payment request.
*/ */
public void calculateWhetherShouldSkipShowingPaymentRequestUi(boolean isUserGestureShow, public void calculateWhetherShouldSkipShowingPaymentRequestUi(boolean isUserGestureShow,
boolean urlPaymentMethodIdentifiersSupported, boolean urlPaymentMethodIdentifiersSupported,
boolean skipUiForNonUrlPaymentMethodIdentifiers) { boolean skipUiForNonUrlPaymentMethodIdentifiers, PaymentOptions options) {
assert mPaymentMethodsSection != null; assert mPaymentMethodsSection != null;
PaymentApp selectedApp = (PaymentApp) mPaymentMethodsSection.getSelectedItem(); PaymentApp selectedApp = (PaymentApp) mPaymentMethodsSection.getSelectedItem();
...@@ -1465,7 +1465,7 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs ...@@ -1465,7 +1465,7 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs
// the payment request UI, thus can't be skipped. // the payment request UI, thus can't be skipped.
&& (urlPaymentMethodIdentifiersSupported || skipUiForNonUrlPaymentMethodIdentifiers) && (urlPaymentMethodIdentifiersSupported || skipUiForNonUrlPaymentMethodIdentifiers)
&& mPaymentMethodsSection.getSize() >= 1 && mPaymentMethodsSection.getSize() >= 1
&& onlySingleAppCanProvideAllRequiredInformation() && onlySingleAppCanProvideAllRequiredInformation(options)
// Skip to payment app only if it can be pre-selected. // Skip to payment app only if it can be pre-selected.
&& selectedApp != null && selectedApp != null
// Skip to payment app only if user gesture is provided when it is required to // Skip to payment app only if user gesture is provided when it is required to
......
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