Commit ef6925ad authored by Alice Wang's avatar Alice Wang Committed by Chromium LUCI CQ

[Signin][Android] Move logAccountConsistencyPromoAction to SigninMetricsUtils

This CL moves the method logAccountConsistencyPromoAction to
SigninMetricsUtils to regroup the signin metrics logging util methods
in one place.

Bug: 1158341
Change-Id: I6e7935020aaf1e28abcb3634aa0b91f498ee6665
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2588932Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836613}
parent 55b9cd54
......@@ -21,10 +21,10 @@ import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.feedback.HelpAndFeedbackLauncherImpl;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.signin.account_picker.AccountPickerBottomSheetCoordinator;
import org.chromium.chrome.browser.signin.account_picker.AccountPickerDelegate;
import org.chromium.chrome.browser.signin.account_picker.AccountPickerDelegateImpl;
import org.chromium.chrome.browser.signin.services.IdentityServicesProvider;
import org.chromium.chrome.browser.signin.services.SigninManager;
import org.chromium.chrome.browser.signin.services.SigninMetricsUtils;
import org.chromium.chrome.browser.signin.services.WebSigninBridge;
import org.chromium.chrome.browser.sync.settings.AccountManagementFragment;
import org.chromium.chrome.browser.tabmodel.TabCreator;
......@@ -89,14 +89,14 @@ public class SigninUtils {
SigninManager signinManager = IdentityServicesProvider.get().getSigninManager(
Profile.getLastUsedRegularProfile());
if (!signinManager.isSignInAllowed()) {
AccountPickerDelegate.recordAccountConsistencyPromoAction(
SigninMetricsUtils.logAccountConsistencyPromoAction(
AccountConsistencyPromoAction.SUPPRESSED_SIGNIN_NOT_ALLOWED);
return;
}
if (AccountManagerFacadeProvider.getInstance().tryGetGoogleAccounts().isEmpty()) {
// TODO(https://crbug.com/1119720): Show the bottom sheet when no accounts on device
// in the future. This disabling is only temporary.
AccountPickerDelegate.recordAccountConsistencyPromoAction(
SigninMetricsUtils.logAccountConsistencyPromoAction(
AccountConsistencyPromoAction.SUPPRESSED_NO_ACCOUNTS);
return;
}
......
......@@ -13,6 +13,7 @@ import androidx.annotation.VisibleForTesting;
import org.chromium.chrome.browser.feedback.HelpAndFeedbackLauncher;
import org.chromium.chrome.browser.incognito.interstitial.IncognitoInterstitialCoordinator;
import org.chromium.chrome.browser.incognito.interstitial.IncognitoInterstitialDelegate;
import org.chromium.chrome.browser.signin.services.SigninMetricsUtils;
import org.chromium.chrome.browser.tabmodel.TabCreator;
import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.components.browser_ui.bottomsheet.BottomSheetController;
......@@ -35,13 +36,13 @@ public class AccountPickerBottomSheetCoordinator {
public void onSheetClosed(@StateChangeReason int reason) {
super.onSheetClosed(reason);
if (reason == StateChangeReason.SWIPE) {
AccountPickerDelegate.recordAccountConsistencyPromoAction(
SigninMetricsUtils.logAccountConsistencyPromoAction(
AccountConsistencyPromoAction.DISMISSED_SWIPE_DOWN);
} else if (reason == StateChangeReason.BACK_PRESS) {
AccountPickerDelegate.recordAccountConsistencyPromoAction(
SigninMetricsUtils.logAccountConsistencyPromoAction(
AccountConsistencyPromoAction.DISMISSED_BACK);
} else if (reason == StateChangeReason.TAP_SCRIM) {
AccountPickerDelegate.recordAccountConsistencyPromoAction(
SigninMetricsUtils.logAccountConsistencyPromoAction(
AccountConsistencyPromoAction.DISMISSED_SCRIM);
}
}
......@@ -79,8 +80,7 @@ public class AccountPickerBottomSheetCoordinator {
BottomSheetController bottomSheetController,
AccountPickerDelegate accountPickerDelegate,
IncognitoInterstitialDelegate incognitoInterstitialDelegate) {
AccountPickerDelegate.recordAccountConsistencyPromoAction(
AccountConsistencyPromoAction.SHOWN);
SigninMetricsUtils.logAccountConsistencyPromoAction(AccountConsistencyPromoAction.SHOWN);
mAccountPickerBottomSheetMediator = new AccountPickerBottomSheetMediator(
activity, accountPickerDelegate, this::dismissBottomSheet);
......@@ -91,7 +91,7 @@ public class AccountPickerBottomSheetCoordinator {
IncognitoInterstitialCoordinator incognitoInterstitialCoordinator =
new IncognitoInterstitialCoordinator(
mView.getIncognitoInterstitialView(), incognitoInterstitialDelegate, () -> {
AccountPickerDelegate.recordAccountConsistencyPromoAction(
SigninMetricsUtils.logAccountConsistencyPromoAction(
AccountConsistencyPromoAction.STARTED_INCOGNITO_SESSION);
});
mBottomSheetController = bottomSheetController;
......
......@@ -15,6 +15,7 @@ import org.chromium.base.task.AsyncTask;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.signin.account_picker.AccountPickerBottomSheetProperties.ViewState;
import org.chromium.chrome.browser.signin.services.ProfileDataCache;
import org.chromium.chrome.browser.signin.services.SigninMetricsUtils;
import org.chromium.components.signin.AccountManagerFacade;
import org.chromium.components.signin.AccountManagerFacadeProvider;
import org.chromium.components.signin.AccountUtils;
......@@ -53,7 +54,7 @@ class AccountPickerBottomSheetMediator implements AccountPickerCoordinator.Liste
context, context.getResources().getDimensionPixelSize(R.dimen.user_picture_size));
OnClickListener onDismissClicked = v -> {
AccountPickerDelegate.recordAccountConsistencyPromoAction(
SigninMetricsUtils.logAccountConsistencyPromoAction(
AccountConsistencyPromoAction.DISMISSED_BUTTON);
dismissBottomSheetRunnable.run();
};
......@@ -89,11 +90,11 @@ class AccountPickerBottomSheetMediator implements AccountPickerCoordinator.Liste
*/
@Override
public void addAccount() {
AccountPickerDelegate.recordAccountConsistencyPromoAction(
SigninMetricsUtils.logAccountConsistencyPromoAction(
AccountConsistencyPromoAction.ADD_ACCOUNT_STARTED);
mAccountPickerDelegate.addAccount(accountName -> {
mAddedAccountName = accountName;
AccountPickerDelegate.recordAccountConsistencyPromoAction(
SigninMetricsUtils.logAccountConsistencyPromoAction(
AccountConsistencyPromoAction.ADD_ACCOUNT_COMPLETED);
onAccountSelected(accountName, false);
});
......@@ -221,13 +222,13 @@ class AccountPickerBottomSheetMediator implements AccountPickerCoordinator.Liste
private void signIn() {
mModel.set(AccountPickerBottomSheetProperties.VIEW_STATE, ViewState.SIGNIN_IN_PROGRESS);
if (TextUtils.equals(mSelectedAccountName, mAddedAccountName)) {
AccountPickerDelegate.recordAccountConsistencyPromoAction(
SigninMetricsUtils.logAccountConsistencyPromoAction(
AccountConsistencyPromoAction.SIGNED_IN_WITH_ADDED_ACCOUNT);
} else if (TextUtils.equals(mSelectedAccountName, mDefaultAccountName)) {
AccountPickerDelegate.recordAccountConsistencyPromoAction(
SigninMetricsUtils.logAccountConsistencyPromoAction(
AccountConsistencyPromoAction.SIGNED_IN_WITH_DEFAULT_ACCOUNT);
} else {
AccountPickerDelegate.recordAccountConsistencyPromoAction(
SigninMetricsUtils.logAccountConsistencyPromoAction(
AccountConsistencyPromoAction.SIGNED_IN_WITH_NON_DEFAULT_ACCOUNT);
}
new AsyncTask<String>() {
......@@ -256,7 +257,7 @@ class AccountPickerBottomSheetMediator implements AccountPickerCoordinator.Liste
promoAction = AccountConsistencyPromoAction.GENERIC_ERROR_SHOWN;
newViewState = ViewState.SIGNIN_GENERAL_ERROR;
}
AccountPickerDelegate.recordAccountConsistencyPromoAction(promoAction);
SigninMetricsUtils.logAccountConsistencyPromoAction(promoAction);
mModel.set(AccountPickerBottomSheetProperties.VIEW_STATE, newViewState);
}
......
......@@ -5,23 +5,13 @@
package org.chromium.chrome.browser.signin.account_picker;
import org.chromium.base.Callback;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.components.signin.base.CoreAccountInfo;
import org.chromium.components.signin.base.GoogleServiceAuthError;
import org.chromium.components.signin.metrics.AccountConsistencyPromoAction;
/**
* This interface is used in web sign-in flow for the account picker bottom sheet.
*/
public interface AccountPickerDelegate {
/**
* Records Signin.AccountConsistencyPromoAction histogram.
*/
static void recordAccountConsistencyPromoAction(
@AccountConsistencyPromoAction int promoAction) {
RecordHistogram.recordEnumeratedHistogram("Signin.AccountConsistencyPromoAction",
promoAction, AccountConsistencyPromoAction.MAX);
}
/**
* Called when the delegate is dismissed to release resources used by this class.
......
......@@ -7,8 +7,10 @@ package org.chromium.chrome.browser.signin.services;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.browser.profiles.ProfileAccountManagementMetrics;
import org.chromium.components.signin.GAIAServiceType;
import org.chromium.components.signin.metrics.AccountConsistencyPromoAction;
/**
* Util methods for signin metrics logging.
......@@ -22,6 +24,15 @@ public class SigninMetricsUtils {
SigninMetricsUtilsJni.get().logProfileAccountManagementMenu(metric, gaiaServiceType);
}
/**
* Logs Signin.AccountConsistencyPromoAction histogram.
*/
public static void logAccountConsistencyPromoAction(
@AccountConsistencyPromoAction int promoAction) {
RecordHistogram.recordEnumeratedHistogram("Signin.AccountConsistencyPromoAction",
promoAction, AccountConsistencyPromoAction.MAX);
}
@VisibleForTesting
@NativeMethods
public interface Natives {
......
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