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 enum PasswordGenerationEvent { 13 // No Account creation form is detected. 14 NO_SIGN_UP_DETECTED, 15 16 // Account creation form is detected. 17 SIGN_UP_DETECTED, 18 19 // Password generation icon is shown inside the first password field. 20 ICON_SHOWN, 21 22 // Password generation bubble is shown after user clicks on the icon. 23 BUBBLE_SHOWN, 24 25 // Number of enum entries, used for UMA histogram reporting macros. 26 EVENT_ENUM_COUNT 27 }; 28 29 // Wrapper to store the user interactions with the password generation bubble. 30 struct PasswordGenerationActions { 31 // Whether the user has clicked on the learn more link. 32 bool learn_more_visited; 33 34 // Whether the user has accepted the generated password. 35 bool password_accepted; 36 37 // Whether the user has manually edited password entry. 38 bool password_edited; 39 40 // Whether the user has clicked on the regenerate button. 41 bool password_regenerated; 42 43 PasswordGenerationActions(); 44 ~PasswordGenerationActions(); 45 }; 46 47 void LogUserActions(PasswordGenerationActions actions); 48 49 void LogPasswordGenerationEvent(PasswordGenerationEvent event); 50 51 // Enumerates user actions after password generation bubble is shown. 52 // These are visible for testing purposes. 53 enum UserAction { 54 // User closes the bubble without any meaningful actions (e.g. use backspace 55 // key, close the bubble, click outside the bubble, etc). 56 IGNORE_FEATURE, 57 58 // User navigates to the learn more page. Note that in the current 59 // implementation this will result in closing the bubble so this action 60 // doesn't overlap with the following two actions. 61 LEARN_MORE, 62 63 // User accepts the generated password without manually editing it (but 64 // including changing it through the regenerate button). 65 ACCEPT_ORIGINAL_PASSWORD, 66 67 // User accepts the gererated password after manually editing it. 68 ACCEPT_AFTER_EDITING, 69 70 // Number of enum entries, used for UMA histogram reporting macros. 71 ACTION_ENUM_COUNT 72 }; 73 74 // Returns true if Password Generation is enabled according to the field 75 // trial result and the flags. 76 bool IsPasswordGenerationEnabled(); 77 78 } // namespace password_generation 79 } // namespace autofill 80 81 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_GENERATION_UTIL_H_ 82