Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / autofill / core / common / password_generation_util.h
1 // Copyright 2013 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 COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_GENERATION_UTIL_H_
6 #define COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_GENERATION_UTIL_H_
7
8 namespace autofill {
9 namespace password_generation {
10
11 // Enumerates various events related to the password generation process.
12 // Do not remove items from this enum as they are used for UMA stats logging.
13 enum PasswordGenerationEvent {
14   // No Account creation form is detected.
15   NO_SIGN_UP_DETECTED,
16
17   // Account creation form is detected.
18   SIGN_UP_DETECTED,
19
20   // DEPRECATED: Password generation icon shown (old UI).
21   DEPRECATED_ICON_SHOWN,
22
23   // DEPRECATED: Password generation bubble shown (old UI).
24   DEPRECATED_BUBBLE_SHOWN,
25
26   // Password generation could be triggered if the user selects the appropriate
27   // element.
28   GENERATION_AVAILABLE,
29
30   // Password generation popup is shown after user focuses the appropriate
31   // password field.
32   // DEPRECATED: These reports were triggered when the popup could have shown
33   // not when it did show so they paint an unreliable picture. Newer stats
34   // are only incremented per page, which is more useful to judge the
35   // effectiveness of the UI.
36   DEPRECATED_GENERATION_POPUP_SHOWN,
37
38   // Generated password was accepted by the user.
39   PASSWORD_ACCEPTED,
40
41   // User focused the password field containing the generated password.
42   // DEPRECATED: These reports were triggered when the popup could have shown
43   // not when it did show so they paint an unreliable picture. Newer stats
44   // are only incremented per page, which is more useful to judge the
45   // effectiveness of the UI.
46   DEPRECATED_EDITING_POPUP_SHOWN,
47
48   // Password was changed after generation.
49   PASSWORD_EDITED,
50
51   // Generated password was deleted by the user
52   PASSWORD_DELETED,
53
54   // Password generation popup is shown after user focuses the appropriate
55   // password field.
56   GENERATION_POPUP_SHOWN,
57
58   // User focused the password field containing the generated password.
59   EDITING_POPUP_SHOWN,
60
61   // Number of enum entries, used for UMA histogram reporting macros.
62   EVENT_ENUM_COUNT
63 };
64
65 // Wrapper to store the user interactions with the password generation bubble.
66 struct PasswordGenerationActions {
67   // Whether the user has clicked on the learn more link.
68   bool learn_more_visited;
69
70   // Whether the user has accepted the generated password.
71   bool password_accepted;
72
73   // Whether the user has manually edited password entry.
74   bool password_edited;
75
76   // Whether the user has clicked on the regenerate button.
77   bool password_regenerated;
78
79   PasswordGenerationActions();
80   ~PasswordGenerationActions();
81 };
82
83 void LogUserActions(PasswordGenerationActions actions);
84
85 void LogPasswordGenerationEvent(PasswordGenerationEvent event);
86
87 // Enumerates user actions after password generation bubble is shown.
88 // These are visible for testing purposes.
89 enum UserAction {
90   // User closes the bubble without any meaningful actions (e.g. use backspace
91   // key, close the bubble, click outside the bubble, etc).
92   IGNORE_FEATURE,
93
94   // User navigates to the learn more page. Note that in the current
95   // implementation this will result in closing the bubble so this action
96   // doesn't overlap with the following two actions.
97   LEARN_MORE,
98
99   // User accepts the generated password without manually editing it (but
100   // including changing it through the regenerate button).
101   ACCEPT_ORIGINAL_PASSWORD,
102
103   // User accepts the gererated password after manually editing it.
104   ACCEPT_AFTER_EDITING,
105
106   // Number of enum entries, used for UMA histogram reporting macros.
107   ACTION_ENUM_COUNT
108 };
109
110 // Returns true if Password Generation is enabled according to the field
111 // trial result and the flags.
112 bool IsPasswordGenerationEnabled();
113
114 }  // namespace password_generation
115 }  // namespace autofill
116
117 #endif  // COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_GENERATION_UTIL_H_