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

SkipToGPay close client if details invalid

Context:
Organize the logic of parseAndValidateDetailsOrDisconnectFromClient
to prepare for splitting it into business logic and UI logic. The
change of this CL is done based on the discussion[1].

Change:
* Rename setShippingOption into setShippingOptionIfValid so as to be
explicit about the validation purpose.
* Close client before SkipToGPay error out.

[1]
https://chromium-review.googlesource.com/c/chromium/src/+/1787117/5/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java#1243

Change-Id: I918fb133444d32797b7a71d3aede4586c3c0cb10
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2372802
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarDanyao Wang <danyao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801026}
parent 277db352
...@@ -1126,7 +1126,9 @@ public class PaymentRequestImpl ...@@ -1126,7 +1126,9 @@ public class PaymentRequestImpl
mPaymentUIsManager.getShippingOptions(details.shippingOptions)); mPaymentUIsManager.getShippingOptions(details.shippingOptions));
} }
if (mSkipToGPayHelper != null && !mSkipToGPayHelper.setShippingOption(details)) { if (mSkipToGPayHelper != null && !mSkipToGPayHelper.setShippingOptionIfValid(details)) {
mJourneyLogger.setAborted(AbortReason.INVALID_DATA_FROM_RENDERER);
disconnectFromClientWithDebugMessage(ErrorStrings.INVALID_PAYMENT_DETAILS);
return false; return false;
} }
......
...@@ -110,7 +110,7 @@ public class SkipToGPayHelper { ...@@ -110,7 +110,7 @@ public class SkipToGPayHelper {
* @return True if a shipping is requested and a single pre-selected shipping option exists. * @return True if a shipping is requested and a single pre-selected shipping option exists.
* False otherwise. * False otherwise.
*/ */
public boolean setShippingOption(PaymentDetails details) { public boolean setShippingOptionIfValid(PaymentDetails details) {
if (!mPaymentOptionsRequestShipping) return true; if (!mPaymentOptionsRequestShipping) return true;
if (details.shippingOptions == null || details.shippingOptions.length != 1 if (details.shippingOptions == null || details.shippingOptions.length != 1
|| !details.shippingOptions[0].selected) { || !details.shippingOptions[0].selected) {
......
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