1 // Copyright 2014 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 COMPONENTS_AUTOFILL_CORE_COMMON_SAVE_PASSWORD_PROGRESS_LOGGER_H_
6 #define COMPONENTS_AUTOFILL_CORE_COMMON_SAVE_PASSWORD_PROGRESS_LOGGER_H_
20 // When logging decisions made by password management code about whether to
21 // offer user-entered credentials for saving or not, do use this class. It
22 // offers a suite of convenience methods to format and scrub logs. The methods
23 // have built-in privacy protections (never include a password, scrub URLs), so
24 // that the result is appropriate for display on the internals page.
26 // To use this class, the method SendLog needs to be overriden to send the logs
27 // for display as appropriate.
29 // TODO(vabr): Logically, this class belongs to the password_manager component.
30 // But the PasswordAutofillAgent needs to use it, so until that agent is in a
31 // third component, shared by autofill and password_manager, this helper needs
32 // to stay in autofill as well.
33 class SavePasswordProgressLogger {
35 // IDs of strings allowed in the logs: for security reasons, we only pass the
36 // IDs from the renderer, and map them to strings in the browser.
49 STRING_SCHEME_MESSAGE,
51 STRING_ORIGINAL_SIGNON_REALM,
54 STRING_USERNAME_ELEMENT,
55 STRING_PASSWORD_ELEMENT,
56 STRING_PASSWORD_AUTOCOMPLETE_SET,
57 STRING_OLD_PASSWORD_ELEMENT,
59 STRING_PASSWORD_GENERATED,
61 STRING_USE_ADDITIONAL_AUTHENTICATION,
65 STRING_SET_AUTH_METHOD,
66 STRING_AUTHENTICATION_HANDLED,
67 STRING_LOGINHANDLER_FORM,
68 STRING_SEND_PASSWORD_FORMS_METHOD,
69 STRING_SECURITY_ORIGIN,
70 STRING_SECURITY_ORIGIN_FAILURE,
72 STRING_NUMBER_OF_ALL_FORMS,
73 STRING_FORM_FOUND_ON_PAGE,
74 STRING_FORM_IS_VISIBLE,
75 STRING_FORM_IS_PASSWORD,
76 STRING_WILL_SUBMIT_FORM_METHOD,
77 STRING_HTML_FORM_FOR_SUBMIT,
78 STRING_CREATED_PASSWORD_FORM,
79 STRING_SUBMITTED_PASSWORD_REPLACED,
80 STRING_DID_START_PROVISIONAL_LOAD_METHOD,
81 STRING_FORM_FRAME_EQ_FRAME,
82 STRING_PROVISIONALLY_SAVED_FORM_FOR_FRAME,
83 STRING_PASSWORD_FORM_FOUND_ON_PAGE,
84 STRING_PROVISIONALLY_SAVE_PASSWORD_METHOD,
85 STRING_PROVISIONALLY_SAVE_PASSWORD_FORM,
86 STRING_IS_SAVING_ENABLED,
87 STRING_EMPTY_PASSWORD,
89 STRING_MATCH_WITHOUT_ACTION,
90 STRING_NO_FORM_MANAGER,
91 STRING_FORM_BLACKLISTED,
93 STRING_AUTOCOMPLETE_OFF,
94 STRING_PROVISIONALLY_SAVED_FORM,
95 STRING_IGNORE_POSSIBLE_USERNAMES,
96 STRING_ON_PASSWORD_FORMS_RENDERED_METHOD,
97 STRING_NO_PROVISIONAL_SAVE_MANAGER,
98 STRING_NUMBER_OF_VISIBLE_FORMS,
99 STRING_PASSWORD_FORM_REAPPEARED,
100 STRING_SAVING_DISABLED,
101 STRING_NO_MATCHING_FORM,
102 STRING_INVALID, // Represents a string returned in a case of an error.
103 STRING_MAX = STRING_INVALID
106 SavePasswordProgressLogger();
107 virtual ~SavePasswordProgressLogger();
109 // Call these methods to log information. They sanitize the input and call
110 // SendLog to pass it for display.
111 void LogPasswordForm(StringID label, const autofill::PasswordForm& form);
112 void LogHTMLForm(StringID label,
113 const std::string& name_or_id,
114 const std::string& method,
116 void LogURL(StringID label, const GURL& url);
117 void LogBoolean(StringID label, bool truth_value);
118 void LogNumber(StringID label, int signed_number);
119 void LogNumber(StringID label, size_t unsigned_number);
120 void LogMessage(StringID message);
123 // Sends |log| immediately for display.
124 virtual void SendLog(const std::string& log) = 0;
127 // Converts |log| and its |label| to a string and calls SendLog on the result.
128 void LogValue(StringID label, const base::Value& log);
130 DISALLOW_COPY_AND_ASSIGN(SavePasswordProgressLogger);
133 } // namespace autofill
135 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_SAVE_PASSWORD_PROGRESS_LOGGER_H_