Home | History | Annotate | Download | only in common
      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   GENERATION_POPUP_SHOWN,
     33 
     34   // Generated password was accepted by the user.
     35   PASSWORD_ACCEPTED,
     36 
     37   // User focused the password field containing the generated password.
     38   EDITING_POPUP_SHOWN,
     39 
     40   // Password was changed after generation.
     41   PASSWORD_EDITED,
     42 
     43   // Generated password was deleted by the user
     44   PASSWORD_DELETED,
     45 
     46   // Number of enum entries, used for UMA histogram reporting macros.
     47   EVENT_ENUM_COUNT
     48 };
     49 
     50 // Wrapper to store the user interactions with the password generation bubble.
     51 struct PasswordGenerationActions {
     52   // Whether the user has clicked on the learn more link.
     53   bool learn_more_visited;
     54 
     55   // Whether the user has accepted the generated password.
     56   bool password_accepted;
     57 
     58   // Whether the user has manually edited password entry.
     59   bool password_edited;
     60 
     61   // Whether the user has clicked on the regenerate button.
     62   bool password_regenerated;
     63 
     64   PasswordGenerationActions();
     65   ~PasswordGenerationActions();
     66 };
     67 
     68 void LogUserActions(PasswordGenerationActions actions);
     69 
     70 void LogPasswordGenerationEvent(PasswordGenerationEvent event);
     71 
     72 // Enumerates user actions after password generation bubble is shown.
     73 // These are visible for testing purposes.
     74 enum UserAction {
     75   // User closes the bubble without any meaningful actions (e.g. use backspace
     76   // key, close the bubble, click outside the bubble, etc).
     77   IGNORE_FEATURE,
     78 
     79   // User navigates to the learn more page. Note that in the current
     80   // implementation this will result in closing the bubble so this action
     81   // doesn't overlap with the following two actions.
     82   LEARN_MORE,
     83 
     84   // User accepts the generated password without manually editing it (but
     85   // including changing it through the regenerate button).
     86   ACCEPT_ORIGINAL_PASSWORD,
     87 
     88   // User accepts the gererated password after manually editing it.
     89   ACCEPT_AFTER_EDITING,
     90 
     91   // Number of enum entries, used for UMA histogram reporting macros.
     92   ACTION_ENUM_COUNT
     93 };
     94 
     95 // Returns true if Password Generation is enabled according to the field
     96 // trial result and the flags.
     97 bool IsPasswordGenerationEnabled();
     98 
     99 }  // namespace password_generation
    100 }  // namespace autofill
    101 
    102 #endif  // COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_GENERATION_UTIL_H_
    103