Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / profiles / profile_metrics.h
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.
4
5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_
6 #define CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_
7
8 #include <stddef.h>
9 #include <string>
10
11 #include "base/basictypes.h"
12
13 class Profile;
14 class ProfileManager;
15
16 namespace base {
17 class FilePath;
18 }
19
20 class ProfileMetrics {
21  public:
22   // Enum for counting the ways users were added.
23   enum ProfileAdd {
24     ADD_NEW_USER_ICON = 0,    // User adds new user from icon menu
25     ADD_NEW_USER_MENU,        // User adds new user from menu bar
26     ADD_NEW_USER_DIALOG,      // User adds new user from create-profile dialog
27     ADD_NEW_USER_MANAGER,     // User adds new user from User Manager
28     NUM_PROFILE_ADD_METRICS
29   };
30
31   // Enum for counting the ways user profiles and menus were opened.
32   enum ProfileOpen {
33     NTP_AVATAR_BUBBLE = 0,    // User opens avatar icon menu from NTP
34     ICON_AVATAR_BUBBLE,       // User opens avatar icon menu from icon
35     SWITCH_PROFILE_ICON,      // User switches profiles from icon menu
36     SWITCH_PROFILE_MENU,      // User switches profiles from menu bar
37     SWITCH_PROFILE_DOCK,      // User switches profiles from dock (Mac-only)
38     OPEN_USER_MANAGER,        // User opens the User Manager
39     SWITCH_PROFILE_MANAGER,   // User switches profiles from the User Manager
40     SWITCH_PROFILE_UNLOCK,    // User switches to lockd profile via User Manager
41     SWITCH_PROFILE_GUEST,     // User switches to guest profile
42     NUM_PROFILE_OPEN_METRICS
43   };
44
45   // Enum for getting net counts for adding and deleting users.
46   enum ProfileNetUserCounts {
47     ADD_NEW_USER = 0,         // Total count of add new user
48     PROFILE_DELETED,          // User deleted a profile
49     NUM_PROFILE_NET_METRICS
50   };
51
52   // Sign in is logged once the user has entered their GAIA information.
53   // The options for sync are logged after the user has submitted the options
54   // form. See sync_setup_handler.h.
55   enum ProfileSync {
56     SYNC_CUSTOMIZE = 0,       // User decided to customize sync
57     SYNC_CHOOSE,              // User chose what to sync
58     SYNC_ENCRYPT,             // User has chosen to encrypt all data
59     SYNC_PASSPHRASE,          // User is using a passphrase
60     NUM_PROFILE_SYNC_METRICS
61   };
62
63   enum ProfileType {
64     ORIGINAL = 0,             // Refers to the original/default profile
65     SECONDARY,                // Refers to a user-created profile
66     NUM_PROFILE_TYPE_METRICS
67   };
68
69   enum ProfileGaia {
70     GAIA_OPT_IN = 0,          // User changed to GAIA photo as avatar
71     GAIA_OPT_OUT,             // User changed to not use GAIA photo as avatar
72     NUM_PROFILE_GAIA_METRICS
73   };
74
75   enum ProfileAuth {
76     AUTH_UNNECESSARY,         // Profile was not locked
77     AUTH_LOCAL,               // Profile was authenticated locally
78     AUTH_ONLINE,              // Profile was authenticated on-line
79     AUTH_FAILED,              // Profile failed authentication
80     NUM_PROFILE_AUTH_METRICS
81   };
82
83   // Enum for tracking if new profile management is enabled and Promo views.
84   // This is used in a histogram; the items should not be removed or re-ordered.
85   enum ProfileUpgradeEnrollment {
86     // User viewed the Upgrade promo card in the user menu.
87     PROFILE_ENROLLMENT_SHOW_PREVIEW_PROMO,
88     // User selected to view the intro tutorial.
89     PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE,
90     // User opted into New Profile Management via Promo card.
91     PROFILE_ENROLLMENT_ACCEPT_NEW_PROFILE_MGMT,
92     // User closed the Upgrade card.
93     PROFILE_ENROLLMENT_CLOSE_WELCOME_CARD,
94     // Used disabled New Profile Management.
95     PROFILE_ENROLLMENT_DISABLE_NEW_PROFILE_MGMT,
96     NUM_PROFILE_ENROLLMENT_METRICS,
97   };
98
99   static void UpdateReportedProfilesStatistics(ProfileManager* manager);
100
101   static void LogNumberOfProfiles(ProfileManager* manager);
102   static void LogProfileAddNewUser(ProfileAdd metric);
103   static void LogProfileAvatarSelection(size_t icon_index);
104   static void LogProfileDeleteUser(ProfileNetUserCounts metric);
105   static void LogProfileOpenMethod(ProfileOpen metric);
106   static void LogProfileSwitchGaia(ProfileGaia metric);
107   static void LogProfileSwitchUser(ProfileOpen metric);
108   static void LogProfileSyncInfo(ProfileSync metric);
109   static void LogProfileAuthResult(ProfileAuth metric);
110   static void LogProfileUpgradeEnrollment(ProfileUpgradeEnrollment metric);
111
112   // These functions should only be called on the UI thread because they hook
113   // into g_browser_process through a helper function.
114   static void LogProfileLaunch(Profile* profile);
115   static void LogProfileSyncSignIn(const base::FilePath& profile_path);
116   static void LogProfileUpdate(const base::FilePath& profile_path);
117 };
118
119
120 #endif  // CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_