Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / profiles / profile_metrics.h
blob776c93f45b406b3c0f8e5a1c02f04192f59943be
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_
6 #define CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_
8 #include <stddef.h>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/time/time.h"
13 #include "components/signin/core/browser/signin_header_helper.h"
15 class Profile;
16 class ProfileManager;
18 namespace base {
19 class FilePath;
22 class ProfileMetrics {
23 public:
24 struct ProfileCounts {
25 size_t total;
26 size_t signedin;
27 size_t supervised;
28 size_t unused;
29 size_t gaia_icon;
30 size_t auth_errors;
32 ProfileCounts()
33 : total(0),
34 signedin(0),
35 supervised(0),
36 unused(0),
37 gaia_icon(0),
38 auth_errors(0) {}
41 // Enum for counting the ways users were added.
42 enum ProfileAdd {
43 ADD_NEW_USER_ICON = 0, // User adds new user from icon menu
44 ADD_NEW_USER_MENU, // User adds new user from menu bar
45 ADD_NEW_USER_DIALOG, // User adds new user from create-profile dialog
46 ADD_NEW_USER_MANAGER, // User adds new user from User Manager
47 ADD_NEW_USER_LAST_DELETED, // Auto-created after deleting last user
48 NUM_PROFILE_ADD_METRICS
51 enum ProfileDelete {
52 // Delete profile from settings page.
53 DELETE_PROFILE_SETTINGS = 0,
54 // Delete profile from User Manager.
55 DELETE_PROFILE_USER_MANAGER,
56 // Show the delete profile warning in the User Manager.
57 DELETE_PROFILE_USER_MANAGER_SHOW_WARNING,
58 // Show the delete profile warning in the Settings page.
59 DELETE_PROFILE_SETTINGS_SHOW_WARNING,
60 NUM_DELETE_PROFILE_METRICS
63 // Enum for counting the ways user profiles and menus were opened.
64 enum ProfileOpen {
65 NTP_AVATAR_BUBBLE = 0, // User opens avatar menu from NTP
66 ICON_AVATAR_BUBBLE, // User opens the avatar menu from button
67 SWITCH_PROFILE_ICON, // User switches profiles from icon menu
68 SWITCH_PROFILE_MENU, // User switches profiles from menu bar
69 SWITCH_PROFILE_DOCK, // User switches profiles from dock (Mac-only)
70 OPEN_USER_MANAGER, // User opens the User Manager
71 SWITCH_PROFILE_MANAGER, // User switches profiles from the User Manager
72 SWITCH_PROFILE_UNLOCK, // User switches to lockd profile via User Manager
73 SWITCH_PROFILE_GUEST, // User switches to guest profile
74 NUM_PROFILE_OPEN_METRICS
77 // Enum for getting net counts for adding and deleting users.
78 enum ProfileNetUserCounts {
79 ADD_NEW_USER = 0, // Total count of add new user
80 PROFILE_DELETED, // User deleted a profile
81 NUM_PROFILE_NET_METRICS
84 // Sign in is logged once the user has entered their GAIA information.
85 // The options for sync are logged after the user has submitted the options
86 // form. See sync_setup_handler.h.
87 enum ProfileSync {
88 SYNC_CUSTOMIZE = 0, // User decided to customize sync
89 SYNC_CHOOSE, // User chose what to sync
90 SYNC_ENCRYPT, // User has chosen to encrypt all data
91 SYNC_PASSPHRASE, // User is using a passphrase
92 NUM_PROFILE_SYNC_METRICS
95 enum ProfileType {
96 ORIGINAL = 0, // Refers to the original/default profile
97 SECONDARY, // Refers to a user-created profile
98 NUM_PROFILE_TYPE_METRICS
101 enum ProfileGaia {
102 GAIA_OPT_IN = 0, // User changed to GAIA photo as avatar
103 GAIA_OPT_OUT, // User changed to not use GAIA photo as avatar
104 NUM_PROFILE_GAIA_METRICS
107 enum ProfileAuth {
108 AUTH_UNNECESSARY, // Profile was not locked
109 AUTH_LOCAL, // Profile was authenticated locally
110 AUTH_ONLINE, // Profile was authenticated on-line
111 AUTH_FAILED, // Profile failed authentication
112 AUTH_FAILED_OFFLINE, // Profile failed authentication and was offline
113 NUM_PROFILE_AUTH_METRICS
116 // Enum for tracking user interactions with the user menu and user manager.
117 // Interactions initiated from the content area are logged into a different
118 // histogram from those that were initiated from the avatar button.
119 // An example of the interaction beginning in the content area is
120 // clicking "Manage Accounts" within account selection on a Google property.
121 enum ProfileDesktopMenu {
122 // User opened the user menu, and clicked lock.
123 PROFILE_DESKTOP_MENU_LOCK = 0,
124 // User opened the user menu, and removed an account.
125 PROFILE_DESKTOP_MENU_REMOVE_ACCT,
126 // User opened the user menu, and started adding an account.
127 PROFILE_DESKTOP_MENU_ADD_ACCT,
128 // User opened the user menu, and changed the profile name.
129 PROFILE_DESKTOP_MENU_EDIT_NAME,
130 // User opened the user menu, and started selecting a new profile image.
131 PROFILE_DESKTOP_MENU_EDIT_IMAGE,
132 // User opened the user menu, and opened the user manager.
133 PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER,
134 // User opened the user menu, and selected Go Incognito.
135 PROFILE_DESKTOP_MENU_GO_INCOGNITO,
136 NUM_PROFILE_DESKTOP_MENU_METRICS,
139 #if defined(OS_ANDROID)
140 // Enum for tracking user interactions with the account management menu
141 // on Android.
143 // A Java counterpart will be generated for this enum.
144 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.profiles
145 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: ProfileAccountManagementMetrics
146 // GENERATED_JAVA_PREFIX_TO_STRIP: PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_
147 enum ProfileAndroidAccountManagementMenu {
148 // User arrived at the Account management screen.
149 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_VIEW = 0,
150 // User arrived at the Account management screen, and clicked Add account.
151 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_ADD_ACCOUNT = 1,
152 // User arrived at the Account management screen, and clicked Go incognito.
153 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_GO_INCOGNITO = 2,
154 // User arrived at the Account management screen, and clicked on primary.
155 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_CLICK_PRIMARY_ACCOUNT = 3,
156 // User arrived at the Account management screen, and clicked on secondary.
157 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_CLICK_SECONDARY_ACCOUNT = 4,
158 // User arrived at the Account management screen, toggled Chrome signout.
159 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_TOGGLE_SIGNOUT = 5,
160 // User toggled Chrome signout, and clicked Signout.
161 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_SIGNOUT_SIGNOUT = 6,
162 // User toggled Chrome signout, and clicked Cancel.
163 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_SIGNOUT_CANCEL = 7,
164 // User arrived at the android Account management screen directly from some
165 // Gaia requests.
166 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_DIRECT_ADD_ACCOUNT = 8,
167 NUM_PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_METRICS,
169 #endif // defined(OS_ANDROID)
171 // Enum for tracking user interactions with the 'Not You?' bubble that users
172 // can navigate to from the Upgrade bubble after upgrade.
173 enum ProfileNewAvatarMenuNotYou {
174 // User views the 'Not You?' bubble.
175 PROFILE_AVATAR_MENU_NOT_YOU_VIEW = 0,
176 // User selects back from within the 'Not You?' bubble.
177 PROFILE_AVATAR_MENU_NOT_YOU_BACK,
178 // User adds a person from within the 'Not You?' bubble.
179 PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON,
180 // User chooses to disconnect (sign out) from within the 'Not You?' bubble.
181 PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT,
182 NUM_PROFILE_AVATAR_MENU_NOT_YOU_METRICS,
185 // Enum for tracking user interactions with the signin bubble that appears
186 // in the New Avatar Menu after using the Inline Signin flow.
187 enum ProfileNewAvatarMenuSignin {
188 // User viewed the signin bubble after successfully using the inline signin.
189 PROFILE_AVATAR_MENU_SIGNIN_VIEW = 0,
190 // User selected ok to dismiss the signin bubble.
191 PROFILE_AVATAR_MENU_SIGNIN_OK,
192 // User opened the settings from the signin bubble.
193 PROFILE_AVATAR_MENU_SIGNIN_SETTINGS,
194 NUM_PROFILE_AVATAR_MENU_SIGNIN_METRICS,
197 // Enum for tracking user interactions with the bubble that appears for all
198 // users in the new avatar menu after upgrading.
199 enum ProfileNewAvatarMenuUpgrade {
200 // User views the upgrade bubble.
201 PROFILE_AVATAR_MENU_UPGRADE_VIEW = 0,
202 // User dismissed the upgrade bubble.
203 PROFILE_AVATAR_MENU_UPGRADE_DISMISS,
204 // User selects 'What's New' in the upgrade bubble.
205 PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW,
206 // User selects 'Not You?' in the upgrade bubble.
207 PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU,
208 NUM_PROFILE_AVATAR_MENU_UPGRADE_METRICS,
211 static void UpdateReportedProfilesStatistics(ProfileManager* manager);
212 // Count and return summary information about the profiles currently in the
213 // |manager|. This information is returned in the output variable |counts|.
214 static bool CountProfileInformation(ProfileManager* manager,
215 ProfileCounts* counts);
217 static void LogNumberOfProfileSwitches();
218 #if defined(OS_WIN) || defined(OS_MACOSX)
219 // Update OS level tracking of profile counts.
220 static void UpdateReportedOSProfileStatistics(size_t active, size_t signedin);
221 #endif
223 static void LogNumberOfProfiles(ProfileManager* manager);
224 static void LogProfileAddNewUser(ProfileAdd metric);
225 static void LogProfileAvatarSelection(size_t icon_index);
226 static void LogProfileDeleteUser(ProfileDelete metric);
227 static void LogProfileOpenMethod(ProfileOpen metric);
228 static void LogProfileSwitch(ProfileOpen metric,
229 ProfileManager* manager,
230 const base::FilePath& profile_path);
231 static void LogProfileSwitchGaia(ProfileGaia metric);
232 static void LogProfileSyncInfo(ProfileSync metric);
233 static void LogProfileAuthResult(ProfileAuth metric);
234 static void LogProfileDesktopMenu(ProfileDesktopMenu metric,
235 signin::GAIAServiceType gaia_service);
236 static void LogProfileDelete(bool profile_was_signed_in);
237 static void LogProfileNewAvatarMenuNotYou(ProfileNewAvatarMenuNotYou metric);
238 static void LogProfileNewAvatarMenuSignin(ProfileNewAvatarMenuSignin metric);
239 static void LogProfileNewAvatarMenuUpgrade(
240 ProfileNewAvatarMenuUpgrade metric);
241 static void LogTimeToOpenUserManager(const base::TimeDelta& time_to_open);
243 #if defined(OS_ANDROID)
244 static void LogProfileAndroidAccountManagementMenu(
245 ProfileAndroidAccountManagementMenu metric,
246 signin::GAIAServiceType gaia_service);
247 #endif // defined(OS_ANDROID)
249 // These functions should only be called on the UI thread because they hook
250 // into g_browser_process through a helper function.
251 static void LogProfileLaunch(Profile* profile);
252 static void LogProfileSyncSignIn(const base::FilePath& profile_path);
253 static void LogProfileUpdate(const base::FilePath& profile_path);
257 #endif // CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_