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

[WebLayer] Move method-types logging into CPRService

This CL moves the method-types logging into CPRService because the
logging is shareable with the payment request service on WebLayer.

Note that the original method depended on
mPaymentUiService.merchantSupportsAutofillCards(). Since this method is
equivalent to BasicCardUtils.merchantSupportsBasicCard(), this CL
do a replacement such that PRService does not have to depend on
PaymentUiService.

Bug: 1131059
Change-Id: Iaa7181494b3ab169bef9bd0895abeb1d61119017
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2537139
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827833}
parent 34992965
...@@ -148,32 +148,6 @@ public class ChromePaymentRequestService ...@@ -148,32 +148,6 @@ public class ChromePaymentRequestService
public void onSpecValidated(PaymentRequestSpec spec) { public void onSpecValidated(PaymentRequestSpec spec) {
mSpec = spec; mSpec = spec;
mPaymentUiService.initialize(mSpec.getPaymentDetails()); mPaymentUiService.initialize(mSpec.getPaymentDetails());
// Log the various types of payment methods that were requested by the merchant.
boolean requestedMethodGoogle = false;
// Not to record requestedMethodBasicCard because JourneyLogger ignore the case where the
// specified networks are unsupported. mPaymentUiService.merchantSupportsAutofillCards()
// better captures this group of interest than requestedMethodBasicCard.
boolean requestedMethodOther = false;
for (String methodName : mSpec.getMethodData().keySet()) {
switch (methodName) {
case MethodStrings.ANDROID_PAY:
case MethodStrings.GOOGLE_PAY:
requestedMethodGoogle = true;
break;
case MethodStrings.BASIC_CARD:
// Not to record requestedMethodBasicCard because
// mPaymentUiService.merchantSupportsAutofillCards() is used instead.
break;
default:
// "Other" includes https url, http url(when certificate check is bypassed) and
// the unlisted methods defined in {@link MethodStrings}.
requestedMethodOther = true;
}
}
mJourneyLogger.setRequestedPaymentMethodTypes(
/*requestedBasicCard=*/mPaymentUiService.merchantSupportsAutofillCards(),
requestedMethodGoogle, requestedMethodOther);
} }
// Implements BrowserPaymentRequest: // Implements BrowserPaymentRequest:
......
...@@ -524,9 +524,39 @@ public class PaymentRequestService ...@@ -524,9 +524,39 @@ public class PaymentRequestService
} }
mSpec = spec; mSpec = spec;
mBrowserPaymentRequest.onSpecValidated(mSpec); mBrowserPaymentRequest.onSpecValidated(mSpec);
logMethodTypes(mSpec.getMethodData());
return true; return true;
} }
private void logMethodTypes(Map<String, PaymentMethodData> methodDataMap) {
// Log the various types of payment methods that were requested by the merchant.
boolean requestedMethodGoogle = false;
// Not to record requestedMethodBasicCard because JourneyLogger ignore the case where the
// specified networks are unsupported. mPaymentUiService.merchantSupportsAutofillCards()
// better captures this group of interest than requestedMethodBasicCard.
boolean requestedMethodOther = false;
for (String methodName : mSpec.getMethodData().keySet()) {
switch (methodName) {
case MethodStrings.ANDROID_PAY:
case MethodStrings.GOOGLE_PAY:
requestedMethodGoogle = true;
break;
case MethodStrings.BASIC_CARD:
// Do not record requestedMethodBasicCard because
// BasicCardUtils.merchantSupportsBasicCard() is used instead.
break;
default:
// "Other" includes https url, http url(when certificate check is bypassed) and
// the unlisted methods defined in {@link MethodStrings}.
requestedMethodOther = true;
}
}
boolean requestedBasicCard = BasicCardUtils.merchantSupportsBasicCard(methodDataMap);
mJourneyLogger.setRequestedPaymentMethodTypes(
/*requestedBasicCard=*/requestedBasicCard, requestedMethodGoogle,
requestedMethodOther);
}
// Implements PaymentResponseHelper.PaymentResponseResultCallback: // Implements PaymentResponseHelper.PaymentResponseResultCallback:
@Override @Override
public void onPaymentResponseReady(PaymentResponse response) { public void onPaymentResponseReady(PaymentResponse response) {
......
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