Commit 4b06ffc5 authored by vabr's avatar vabr Committed by Commit bot

Extend logging for password manager internals page

This CL adds logging for the internals page during filling passwords in the
renderer code. Those have been missing and would have been helpful for
investigating the associated bug.

BUG=606736

Review URL: https://codereview.chromium.org/1918823005

Cr-Commit-Position: refs/heads/master@{#389810}
parent a0f8b011
......@@ -7,6 +7,7 @@
#include <stddef.h>
#include <memory>
#include <string>
#include <utility>
#include "base/bind.h"
......@@ -433,7 +434,11 @@ bool FillUserNameAndPassword(
bool set_selection,
std::map<const blink::WebInputElement, blink::WebString>*
nonscript_modified_values,
base::Callback<void(blink::WebInputElement*)> registration_callback) {
base::Callback<void(blink::WebInputElement*)> registration_callback,
RendererSavePasswordProgressLogger* logger) {
if (logger)
logger->LogMessage(Logger::STRING_FILL_USERNAME_AND_PASSWORD_METHOD);
// Don't fill username if password can't be set.
if (!IsElementAutocompletable(*password_element))
return false;
......@@ -452,6 +457,8 @@ bool FillUserNameAndPassword(
exact_username_match)) {
username = fill_data.username_field.value;
password = fill_data.password_field.value;
if (logger)
logger->LogMessage(Logger::STRING_USERNAMES_MATCH);
} else {
// Scan additional logins for a match.
for (const auto& it : fill_data.additional_logins) {
......@@ -461,6 +468,10 @@ bool FillUserNameAndPassword(
break;
}
}
if (logger) {
logger->LogBoolean(Logger::STRING_MATCH_IN_ADDITIONAL,
!(username.empty() && password.empty()));
}
// Check possible usernames.
if (username.empty() && password.empty()) {
......@@ -487,10 +498,12 @@ bool FillUserNameAndPassword(
// Input matches the username, fill in required values.
if (!username_element->isNull() &&
IsElementAutocompletable(*username_element)) {
// TODO(vabr): Why not setSuggestedValue? http://crbug.com/507714
// TODO(crbug.com/507714): Why not setSuggestedValue?
username_element->setValue(username, true);
(*nonscript_modified_values)[*username_element] = username;
username_element->setAutofilled(true);
if (logger)
logger->LogMessage(Logger::STRING_USERNAME_FILLED);
if (set_selection) {
form_util::PreviewSuggestion(username, current_username,
username_element);
......@@ -509,6 +522,8 @@ bool FillUserNameAndPassword(
registration_callback.Run(password_element);
password_element->setAutofilled(true);
if (logger)
logger->LogMessage(Logger::STRING_PASSWORD_FILLED);
return true;
}
......@@ -526,7 +541,8 @@ bool FillFormOnPasswordReceived(
blink::WebInputElement password_element,
std::map<const blink::WebInputElement, blink::WebString>*
nonscript_modified_values,
base::Callback<void(blink::WebInputElement*)> registration_callback) {
base::Callback<void(blink::WebInputElement*)> registration_callback,
RendererSavePasswordProgressLogger* logger) {
// Do not fill if the password field is in a chain of iframes not having
// identical origin.
blink::WebFrame* cur_frame = password_element.document().frame();
......@@ -594,13 +610,10 @@ bool FillFormOnPasswordReceived(
// Fill if we have an exact match for the username. Note that this sets
// username to autofilled.
return FillUserNameAndPassword(&username_element,
&password_element,
fill_data,
true /* exact_username_match */,
false /* set_selection */,
nonscript_modified_values,
registration_callback);
return FillUserNameAndPassword(
&username_element, &password_element, fill_data,
true /* exact_username_match */, false /* set_selection */,
nonscript_modified_values, registration_callback, logger);
}
// Takes a |map| with pointers as keys and linked_ptr as values, and returns
......@@ -694,11 +707,11 @@ bool PasswordAutofillAgent::TextFieldDidEndEditing(
// Do not set selection when ending an editing session, otherwise it can
// mess with focus.
FillUserNameAndPassword(
&username, &password, fill_data, true, false,
&nonscript_modified_values_,
base::Bind(&PasswordValueGatekeeper::RegisterElement,
base::Unretained(&gatekeeper_)));
FillUserNameAndPassword(&username, &password, fill_data, true, false,
&nonscript_modified_values_,
base::Bind(&PasswordValueGatekeeper::RegisterElement,
base::Unretained(&gatekeeper_)),
nullptr);
return true;
}
......@@ -1311,10 +1324,24 @@ void PasswordAutofillAgent::DidStartProvisionalLoad() {
void PasswordAutofillAgent::OnFillPasswordForm(
int key,
const PasswordFormFillData& form_data) {
std::unique_ptr<RendererSavePasswordProgressLogger> logger;
if (logging_state_active_) {
logger.reset(new RendererSavePasswordProgressLogger(this, routing_id()));
logger->LogMessage(Logger::STRING_ON_FILL_PASSWORD_FORM_METHOD);
}
bool ambiguous_or_empty_names =
DoesFormContainAmbiguousOrEmptyNames(form_data);
FormElementsList forms;
FindFormElements(render_frame(), form_data, ambiguous_or_empty_names, &forms);
if (logger) {
logger->LogBoolean(Logger::STRING_AMBIGUOUS_OR_EMPTY_NAMES,
ambiguous_or_empty_names);
logger->LogNumber(Logger::STRING_NUMBER_OF_POTENTIAL_FORMS_TO_FILL,
forms.size());
logger->LogBoolean(Logger::STRING_FORM_DATA_WAIT,
form_data.wait_for_username);
}
for (const auto& form : forms) {
base::string16 username_field_name;
base::string16 password_field_name =
......@@ -1325,6 +1352,14 @@ void PasswordAutofillAgent::OnFillPasswordForm(
username_field_name =
FieldName(form_data.username_field, ambiguous_or_empty_names);
}
if (logger) {
logger->LogBoolean(Logger::STRING_CONTAINS_FILLABLE_USERNAME_FIELD,
form_contains_fillable_username_field);
logger->LogBoolean(Logger::STRING_USERNAME_FIELD_NAME_EMPTY,
username_field_name.empty());
logger->LogBoolean(Logger::STRING_PASSWORD_FIELD_NAME_EMPTY,
password_field_name.empty());
}
// Attach autocomplete listener to enable selecting alternate logins.
blink::WebInputElement username_element;
......@@ -1362,12 +1397,11 @@ void PasswordAutofillAgent::OnFillPasswordForm(
// until the user types in a valid username.
if (!form_data.wait_for_username) {
FillFormOnPasswordReceived(
form_data,
username_element,
password_element,
form_data, username_element, password_element,
&nonscript_modified_values_,
base::Bind(&PasswordValueGatekeeper::RegisterElement,
base::Unretained(&gatekeeper_)));
base::Unretained(&gatekeeper_)),
logger.get());
}
PasswordInfo password_info;
......
......@@ -357,6 +357,30 @@ std::string SavePasswordProgressLogger::GetStringFromID(
case SavePasswordProgressLogger::STRING_UNOWNED_INPUTS_VISIBLE:
return "Some control elements not associated to a form element are "
"visible";
case SavePasswordProgressLogger::STRING_ON_FILL_PASSWORD_FORM_METHOD:
return "PasswordAutofillAgent::OnFillPasswordForm";
case SavePasswordProgressLogger::STRING_AMBIGUOUS_OR_EMPTY_NAMES:
return "ambiguous_or_empty_names";
case SavePasswordProgressLogger::STRING_NUMBER_OF_POTENTIAL_FORMS_TO_FILL:
return "Number of potential forms to fill";
case SavePasswordProgressLogger::STRING_CONTAINS_FILLABLE_USERNAME_FIELD:
return "form_contains_fillable_username_field";
case SavePasswordProgressLogger::STRING_USERNAME_FIELD_NAME_EMPTY:
return "username_field_name empty";
case SavePasswordProgressLogger::STRING_PASSWORD_FIELD_NAME_EMPTY:
return "password_field_name empty";
case SavePasswordProgressLogger::STRING_FORM_DATA_WAIT:
return "form_data's wait_for_username";
case SavePasswordProgressLogger::STRING_FILL_USERNAME_AND_PASSWORD_METHOD:
return "FillUserNameAndPassword in PasswordAutofillAgent";
case SavePasswordProgressLogger::STRING_USERNAMES_MATCH:
return "Username to fill matches that on the page";
case SavePasswordProgressLogger::STRING_MATCH_IN_ADDITIONAL:
return "Match found in additional logins";
case SavePasswordProgressLogger::STRING_USERNAME_FILLED:
return "Username was filled";
case SavePasswordProgressLogger::STRING_PASSWORD_FILLED:
return "Password was filled";
case SavePasswordProgressLogger::STRING_INVALID:
return "INVALID";
// Intentionally no default: clause here -- all IDs need to get covered.
......
......@@ -131,6 +131,18 @@ class SavePasswordProgressLogger {
STRING_ADDING_SIGNATURE,
STRING_FORM_MANAGER_STATE,
STRING_UNOWNED_INPUTS_VISIBLE,
STRING_ON_FILL_PASSWORD_FORM_METHOD,
STRING_AMBIGUOUS_OR_EMPTY_NAMES,
STRING_NUMBER_OF_POTENTIAL_FORMS_TO_FILL,
STRING_CONTAINS_FILLABLE_USERNAME_FIELD,
STRING_USERNAME_FIELD_NAME_EMPTY,
STRING_PASSWORD_FIELD_NAME_EMPTY,
STRING_FORM_DATA_WAIT,
STRING_FILL_USERNAME_AND_PASSWORD_METHOD,
STRING_USERNAMES_MATCH,
STRING_MATCH_IN_ADDITIONAL,
STRING_USERNAME_FILLED,
STRING_PASSWORD_FILLED,
STRING_INVALID, // Represents a string returned in a case of an error.
STRING_MAX = STRING_INVALID
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment