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

[WebLayer] Log the number of apps in WebLayer

Behavioural changes:
This CL adds the logic of logging the number of available apps to
WebLayer.

Changes:
* Moved setNumberOfSuggestionsShown() from PaymentUiService to
  PRService. The new call site is just after the original call site
  in execution sequence so the original behaviour in CPRService is
  preserved.
* Plumbed hasAnyCompleteAppSuggestion() from UI to PRService to provide
  the logging data. The plumbing is necessary because PaymentUiService
  is responsible for the payment apps management.

Bug: 1152498
Change-Id: Iec48ebac896ad82c025cb884b117385bb1d1745f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2581230
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835701}
parent ceadeb13
......@@ -147,6 +147,12 @@ public class ChromePaymentRequestService
return mPaymentUiService.getPaymentApps();
}
// Implements BrowserPaymentRequest:
@Override
public boolean hasAnyCompleteApp() {
return mPaymentUiService.hasAnyCompleteAppSuggestion();
}
// Implements BrowserPaymentRequest:
@Override
public void onWhetherGooglePayBridgeEligible(boolean googlePayBridgeEligible,
......
......@@ -370,6 +370,17 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs
return paymentApps;
}
/**
* Whether the payment apps includes at least one that is "complete" which is defined
* by {@link PaymentApp#isComplete()}. This method can be called only after
* {@link #setPaymentApps}.
* @return The result.
*/
public boolean hasAnyCompleteAppSuggestion() {
List<PaymentApp> apps = getPaymentApps();
return !apps.isEmpty() && apps.get(0).isComplete();
}
/**
* Returns the selected payment app, if any.
* @return The selected payment app or null if none selected.
......@@ -395,13 +406,6 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs
mPaymentMethodsSection = new SectionInformation(
PaymentRequestUI.DataType.PAYMENT_METHODS, selection, new ArrayList<>(apps));
// Record the number suggested payment methods and whether at least one of them was
// complete.
// TODO(crbug.com/1152498): move this into PaymentRequestService because the WebLayer
// payment request needs to record this as well.
mJourneyLogger.setNumberOfSuggestionsShown(
Section.PAYMENT_METHOD, apps.size(), !apps.isEmpty() && apps.get(0).isComplete());
updateAppModifiedTotals();
SettingsAutofillAndPaymentsObserver.getInstance().registerObserver(this);
......
......@@ -233,4 +233,10 @@ public interface BrowserPaymentRequest {
/** @return All of the available payment apps. */
List<PaymentApp> getPaymentApps();
/**
* @return Whether the payment apps includes at least one that is "complete" which is defined
* by {@link PaymentApp#isComplete()}.
*/
boolean hasAnyCompleteApp();
}
......@@ -771,6 +771,11 @@ public class PaymentRequestService
mBrowserPaymentRequest.notifyPaymentUiOfPendingApps(mPendingApps);
mPendingApps.clear();
// Record the number suggested payment methods and whether at least one of them was
// complete.
mJourneyLogger.setNumberOfSuggestionsShown(Section.PAYMENT_METHOD,
mBrowserPaymentRequest.getPaymentApps().size(),
mBrowserPaymentRequest.hasAnyCompleteApp());
if (mIsShowCalled) {
PaymentNotShownError notShownError = onShowCalledAndAppsQueried();
if (notShownError != null) {
......
......@@ -146,4 +146,10 @@ public class WebLayerPaymentRequestService implements BrowserPaymentRequest {
public List<PaymentApp> getPaymentApps() {
return mAvailableApps;
}
// Implements BrowserPaymentRequest:
@Override
public boolean hasAnyCompleteApp() {
return !mAvailableApps.isEmpty() && mAvailableApps.get(0).isComplete();
}
}
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