Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(916)

Unified Diff: components/autofill/core/common/password_form_fill_data.cc

Issue 548953002: [Password Manager] Modified to support saving passwords on forms without username fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated review changes and code refactoring. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/common/password_form_fill_data.cc
diff --git a/components/autofill/core/common/password_form_fill_data.cc b/components/autofill/core/common/password_form_fill_data.cc
index 7dbc97d0ab62b42dc7b158bcea47b663d7fcd149..1902bda66c652cdbb534ba60d6c53be43d87c460 100644
--- a/components/autofill/core/common/password_form_fill_data.cc
+++ b/components/autofill/core/common/password_form_fill_data.cc
@@ -39,21 +39,23 @@ void InitPasswordFormFillData(
// Note that many of the |FormFieldData| members are not initialized for
// |username_field| and |password_field| because they are currently not used
// by the password autocomplete code.
- FormFieldData username_field;
- username_field.name = form_on_page.username_element;
- username_field.value = preferred_match->username_value;
+ if (!form_on_page.username_element.empty()) {
+ FormFieldData username_field;
+ username_field.name = form_on_page.username_element;
+ username_field.value = preferred_match->username_value;
+ result->basic_data.fields.push_back(username_field);
+ }
+
FormFieldData password_field;
password_field.name = form_on_page.password_element;
password_field.value = preferred_match->password_value;
password_field.form_control_type = "password";
+ result->basic_data.fields.push_back(password_field);
// Fill basic form data.
result->basic_data.origin = form_on_page.origin;
result->basic_data.action = form_on_page.action;
- result->basic_data.fields.push_back(username_field);
- result->basic_data.fields.push_back(password_field);
result->wait_for_username = wait_for_username_before_autofill;
-
result->preferred_realm = preferred_match->original_signon_realm;
// Copy additional username/value pairs.

Powered by Google App Engine
This is Rietveld 408576698