[Passwords] Replacing some suffixes with Patterned Histograms

This change replaces suffixes with variants for the following
histograms:
PasswordManager.AccountStorageUserStateDuration
PasswordManager.MoveUIDismissalReason
PasswordManager.SavedGaiaPasswordHashCount
PasswordManager.SaveUIDismissalReason

Change-Id: I00a8a539a24d83ac87a6f8e151c9fa30fdc437f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3982198
Reviewed-by: Ioana Pandele <ioanap@chromium.org>
Commit-Queue: Viktor Semeniuk <vsemeniuk@google.com>
Cr-Commit-Position: refs/heads/main@{#1064817}
diff --git a/tools/metrics/histograms/metadata/histogram_suffixes_list.xml b/tools/metrics/histograms/metadata/histogram_suffixes_list.xml
index 180375c..5bb3d9d 100644
--- a/tools/metrics/histograms/metadata/histogram_suffixes_list.xml
+++ b/tools/metrics/histograms/metadata/histogram_suffixes_list.xml
@@ -2867,13 +2867,6 @@
   <affected-histogram name="PLT.PT_StartToFinish"/>
 </histogram_suffixes>
 
-<histogram_suffixes name="GaiaAccountType" separator=".">
-  <suffix name="SignedInNonSync"
-      label="A primary account does not exist for the profile"/>
-  <suffix name="Sync" label="A primary account exists for the profile"/>
-  <affected-histogram name="PasswordManager.SavedGaiaPasswordHashCount"/>
-</histogram_suffixes>
-
 <histogram_suffixes name="GeolocationSettingsDialogSource" separator=".">
   <suffix name="DSE" label="Default search engine"/>
   <suffix name="NonDSE" label="Non-default search engine"/>
@@ -6961,29 +6954,6 @@
   <affected-histogram name="PasswordManager.NewlySavedPasswordIsGenerated"/>
 </histogram_suffixes>
 
-<histogram_suffixes name="PasswordAccountStorageUserState" separator=".">
-  <suffix name="SignedInAccountStoreUser"
-      label="Signed-in user, opted in to the account storage, and saving
-             passwords to the account storage."/>
-  <suffix name="SignedInAccountStoreUserSavingLocally"
-      label="Signed-in user and opted in to the account storage, but has
-             chosen to save passwords only on the device."/>
-  <suffix name="SignedInUser"
-      label="Signed-in user, not opted in to the account storage (but will
-             save passwords to the account storage by default)."/>
-  <suffix name="SignedInUserSavingLocally"
-      label="Signed-in user, not opted in to the account storage, and has
-             explicitly chosen to save passwords only on the device."/>
-  <suffix name="SignedOutAccountStoreUser"
-      label="Signed-out user, but an account storage opt-in exists."/>
-  <suffix name="SignedOutUser"
-      label="Signed-out user (and no account storage opt-in exists)."/>
-  <suffix name="SyncUser" label="Syncing user."/>
-  <affected-histogram name="PasswordManager.AccountStorageUserStateDuration"/>
-  <affected-histogram name="PasswordManager.MoveUIDismissalReason"/>
-  <affected-histogram name="PasswordManager.SaveUIDismissalReason"/>
-</histogram_suffixes>
-
 <histogram_suffixes name="PasswordCustomPassphrase" separator=".">
   <suffix name="WithCustomPassphrase" label=""/>
   <suffix name="WithoutCustomPassphrase" label=""/>
diff --git a/tools/metrics/histograms/metadata/password/histograms.xml b/tools/metrics/histograms/metadata/password/histograms.xml
index 7a83f5b..d123df23 100644
--- a/tools/metrics/histograms/metadata/password/histograms.xml
+++ b/tools/metrics/histograms/metadata/password/histograms.xml
@@ -95,6 +95,27 @@
                performing reenrollment possibility check"/>
 </variants>
 
+<variants name="UserSyncingType">
+  <variant name="" summary="all users."/>
+  <variant name=".SignedInAccountStoreUser"
+      summary="signed-in user, opted in to the account storage, and saving
+               passwords to the account storage."/>
+  <variant name=".SignedInAccountStoreUserSavingLocally"
+      summary="signed-in user and opted in to the account storage, but has
+               chosen to save passwords only on the device."/>
+  <variant name=".SignedInUser"
+      summary="signed-in user, not opted in to the account storage (but will
+               save passwords to the account storage by default)."/>
+  <variant name=".SignedInUserSavingLocally"
+      summary="signed-in user, not opted in to the account storage, and has
+               explicitly chosen to save passwords only on the device."/>
+  <variant name=".SignedOutAccountStoreUser"
+      summary="signed-out user, but an account storage opt-in exists."/>
+  <variant name=".SignedOutUser"
+      summary="signed-out user (and no account storage opt-in exists)."/>
+  <variant name=".SyncUser" summary="syncing user."/>
+</variants>
+
 <histogram name="KeyboardAccessory.AccessoryActionImpression"
     enum="AccessoryAction" expires_after="2023-02-26">
   <owner>fhorschig@chromium.org</owner>
@@ -464,10 +485,9 @@
   </summary>
 </histogram>
 
-<histogram base="true" name="PasswordManager.AccountStorageUserStateDuration"
-    units="ms" expires_after="2023-04-16">
-<!-- Name completed by histogram_suffixes name="PasswordAccountStorageUserState" -->
-
+<histogram
+    name="PasswordManager.AccountStorageUserStateDuration{UserSyncingType}"
+    units="ms" expires_after="2023-02-12">
   <owner>mamir@chromium.org</owner>
   <owner>treib@chromium.org</owner>
   <summary>
@@ -495,7 +515,10 @@
     at the same time, their session activity will be logged from all the
     profiles, instead of only from the profile that the user is using at that
     moment.
+
+    Recorded for {UserSyncingType}
   </summary>
+  <token key="UserSyncingType" variants="UserSyncingType"/>
 </histogram>
 
 <histogram name="PasswordManager.AccountStoreBlocklistedEntriesAfterOptIn"
@@ -1795,17 +1818,16 @@
   </token>
 </histogram>
 
-<histogram name="PasswordManager.MoveUIDismissalReason"
-    enum="PasswordManagerUIDismissalReason" expires_after="2023-04-23">
-<!-- Name completed by histogram_suffixes name="PasswordAccountStorageUserState" -->
-
+<histogram name="PasswordManager.MoveUIDismissalReason{UserSyncingType}"
+    enum="PasswordManagerUIDismissalReason" expires_after="2023-02-19">
   <owner>mamir@chromium.org</owner>
   <owner>treib@chromium.org</owner>
   <summary>
     Why was the &quot;move password to account?&quot; bubble closed? Recorded
     whenever the bubble is closed, either because the user clicked one of the
-    buttons or it went away automatically (lost focus).
+    buttons or it went away automatically (lost focus) for {UserSyncingType}
   </summary>
+  <token key="UserSyncingType" variants="UserSyncingType"/>
 </histogram>
 
 <histogram
@@ -2750,15 +2772,23 @@
   </summary>
 </histogram>
 
-<histogram name="PasswordManager.SavedGaiaPasswordHashCount" units="count"
-    expires_after="2023-03-26">
+<histogram name="PasswordManager.SavedGaiaPasswordHashCount{SyncConsentStatus}"
+    units="count" expires_after="2023-03-26">
   <owner>vsemeniuk@google.com</owner>
   <owner>chrome-counter-abuse-alerts@google.com</owner>
   <summary>
     Records the number of Gaia password hashes that have been saved for password
-    reuse detection. This is logged during the initialization of the
-    PasswordReuseManagerImpl class.
+    reuse detection {SyncConsentStatus}. This is logged during the
+    initialization of the PasswordReuseManagerImpl class.
   </summary>
+  <token key="SyncConsentStatus">
+    <variant name="" summary=""/>
+    <variant name=".SignedInNonSync"
+        summary="when the primary account for the profile does not have Sync
+                 consent"/>
+    <variant name=".Sync"
+        summary="when the primary account for the profile has Sync consent"/>
+  </token>
 </histogram>
 
 <histogram
@@ -2793,16 +2823,6 @@
   </summary>
 </histogram>
 
-<histogram name="PasswordManager.SaveUIDismissalReason"
-    enum="PasswordManagerUIDismissalReason" expires_after="2023-02-26">
-<!-- Name completed by histogram_suffixes name="PasswordAccountStorageUserState" -->
-
-  <owner>vasilii@chromium.org</owner>
-  <owner>treib@chromium.org</owner>
-  <owner>mamir@chromium.org</owner>
-  <summary>Why was the save password UI (bubble or infobar) closed?</summary>
-</histogram>
-
 <histogram name="PasswordManager.SaveUIDismissalReasonAfterUnblacklisting"
     enum="PasswordManagerUIDismissalReason" expires_after="M110">
   <owner>ioanap@chromium.org</owner>
@@ -2815,6 +2835,18 @@
   </summary>
 </histogram>
 
+<histogram name="PasswordManager.SaveUIDismissalReason{UserSyncingType}"
+    enum="PasswordManagerUIDismissalReason" expires_after="2023-02-26">
+  <owner>vasilii@chromium.org</owner>
+  <owner>treib@chromium.org</owner>
+  <owner>mamir@chromium.org</owner>
+  <summary>
+    Why was the save password UI (bubble or infobar) closed? Recorded for
+    {UserSyncingType}
+  </summary>
+  <token key="UserSyncingType" variants="UserSyncingType"/>
+</histogram>
+
 <histogram
     name="PasswordManager.SaveUIOnClearedPasswordChangeFormDismissalReason"
     enum="PasswordManagerUIDismissalReason" expires_after="2023-04-16">