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

[PRImpl] Move ShouldShowContactSection

Change:
* Move ShouldShowContactSection into PaymentUIsManager.

Bug: 1102522

Change-Id: I5a9b7c0369cf27cef4a8c0de1c26e6a9428ebb05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2317506
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarSahel Sharify <sahel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792482}
parent 873f74d1
...@@ -1671,20 +1671,7 @@ public class PaymentRequestImpl ...@@ -1671,20 +1671,7 @@ public class PaymentRequestImpl
@Override @Override
public boolean shouldShowContactSection() { public boolean shouldShowContactSection() {
PaymentApp selectedApp = (mPaymentUIsManager.getPaymentMethodsSection() == null) return mPaymentUIsManager.shouldShowContactSection();
? null
: (PaymentApp) mPaymentUIsManager.getPaymentMethodsSection().getSelectedItem();
if (mRequestPayerName && (selectedApp == null || !selectedApp.handlesPayerName())) {
return true;
}
if (mRequestPayerPhone && (selectedApp == null || !selectedApp.handlesPayerPhone())) {
return true;
}
if (mRequestPayerEmail && (selectedApp == null || !selectedApp.handlesPayerEmail())) {
return true;
}
return false;
} }
private void editAddress(final AutofillAddress toEdit) { private void editAddress(final AutofillAddress toEdit) {
......
...@@ -559,7 +559,7 @@ public class PaymentUIsManager ...@@ -559,7 +559,7 @@ public class PaymentUIsManager
} }
} }
/** @return Whether PaymentRequest UI should show the shipping section. */ /** Implements {@link PaymentRequestUI.Client.shouldShowShippingSection}. */
public boolean shouldShowShippingSection() { public boolean shouldShowShippingSection() {
if (!PaymentOptionsUtils.requestShipping(mParams.getPaymentOptions())) return false; if (!PaymentOptionsUtils.requestShipping(mParams.getPaymentOptions())) return false;
...@@ -568,4 +568,26 @@ public class PaymentUIsManager ...@@ -568,4 +568,26 @@ public class PaymentUIsManager
PaymentApp selectedApp = (PaymentApp) mPaymentMethodsSection.getSelectedItem(); PaymentApp selectedApp = (PaymentApp) mPaymentMethodsSection.getSelectedItem();
return selectedApp == null || !selectedApp.handlesShippingAddress(); return selectedApp == null || !selectedApp.handlesShippingAddress();
} }
/** Implements {@link PaymentRequestUI.Client.shouldShowContactSection}. */
public boolean shouldShowContactSection() {
PaymentApp selectedApp = (mPaymentMethodsSection == null)
? null
: (PaymentApp) mPaymentMethodsSection.getSelectedItem();
org.chromium.payments.mojom.PaymentOptions options = mParams.getPaymentOptions();
if (PaymentOptionsUtils.requestPayerName(options)
&& (selectedApp == null || !selectedApp.handlesPayerName())) {
return true;
}
if (PaymentOptionsUtils.requestPayerPhone(options)
&& (selectedApp == null || !selectedApp.handlesPayerPhone())) {
return true;
}
if (PaymentOptionsUtils.requestPayerEmail(options)
&& (selectedApp == null || !selectedApp.handlesPayerEmail())) {
return true;
}
return false;
}
} }
...@@ -51,4 +51,31 @@ public class PaymentOptionsUtils { ...@@ -51,4 +51,31 @@ public class PaymentOptionsUtils {
org.chromium.payments.mojom.PaymentOptions paymentOptions) { org.chromium.payments.mojom.PaymentOptions paymentOptions) {
return paymentOptions != null && paymentOptions.requestShipping; return paymentOptions != null && paymentOptions.requestShipping;
} }
/**
* @param paymentOptions The PaymentOptions of the payment request.
* @return Whether requestPayerName is specified in the payment request.
*/
public static boolean requestPayerName(
org.chromium.payments.mojom.PaymentOptions paymentOptions) {
return paymentOptions != null && paymentOptions.requestPayerName;
}
/**
* @param paymentOptions The PaymentOptions of the payment request.
* @return Whether requestPayerPhone is specified in the payment request.
*/
public static boolean requestPayerPhone(
org.chromium.payments.mojom.PaymentOptions paymentOptions) {
return paymentOptions != null && paymentOptions.requestPayerPhone;
}
/**
* @param paymentOptions The PaymentOptions of the payment request.
* @return Whether requestPayerEmail is specified in the payment request.
*/
public static boolean requestPayerEmail(
org.chromium.payments.mojom.PaymentOptions paymentOptions) {
return paymentOptions != null && paymentOptions.requestPayerEmail;
}
} }
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