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

Unified Diff: chrome/renderer/autofill/password_autofill_manager.cc

Issue 9625026: Save password without an associated username. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Delete a unintentional spaces Created 8 years, 9 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: chrome/renderer/autofill/password_autofill_manager.cc
===================================================================
--- chrome/renderer/autofill/password_autofill_manager.cc (revision 127980)
+++ chrome/renderer/autofill/password_autofill_manager.cc (working copy)
@@ -423,26 +423,28 @@
if (!form_data.wait_for_username)
FillForm(form_elements.get(), form_data.basic_data);
- // Attach autocomplete listener to enable selecting alternate logins.
- // First, get pointers to username element.
- WebKit::WebInputElement username_element =
- form_elements->input_elements[form_data.basic_data.fields[0].name];
-
// Get pointer to password element. (We currently only support single
// password forms).
WebKit::WebInputElement password_element =
- form_elements->input_elements[form_data.basic_data.fields[1].name];
+ form_elements->input_elements[form_data.GetPasswordField().name];
- // We might have already filled this form if there are two <form> elements
- // with identical markup.
- if (login_to_password_info_.find(username_element) !=
- login_to_password_info_.end())
- continue;
-
- PasswordInfo password_info;
- password_info.fill_data = form_data;
- password_info.password_field = password_element;
- login_to_password_info_[username_element] = password_info;
+ // If there is a username, set the username and login_to_password_info_.
+ if (form_data.GetDataType() ==
+ webkit::forms::PasswordFormFillData::kUsernameAndPassword) {
+ // Attach autocomplete listener to enable selecting alternate logins.
+ // First, get pointers to username element.
+ WebKit::WebInputElement username_element =
+ form_elements->input_elements[form_data.GetUsernameField().name];
+ // We might have already filled this form if there are two <form> elements
+ // with identical markup.
+ if (login_to_password_info_.find(username_element) !=
+ login_to_password_info_.end())
+ continue;
+ PasswordInfo password_info;
+ password_info.fill_data = form_data;
+ password_info.password_field = password_element;
+ login_to_password_info_[username_element] = password_info;
+ }
}
}
@@ -453,9 +455,11 @@
const webkit::forms::PasswordFormFillData& fill_data,
const string16& input,
std::vector<string16>* suggestions) {
- if (StartsWith(fill_data.basic_data.fields[0].value, input, false))
- suggestions->push_back(fill_data.basic_data.fields[0].value);
-
+ if (fill_data.GetDataType() ==
+ webkit::forms::PasswordFormFillData::kUsernameAndPassword) {
+ if (StartsWith(fill_data.GetUsernameField().value, input, false))
+ suggestions->push_back(fill_data.GetUsernameField().value);
+ }
webkit::forms::PasswordFormFillData::LoginCollection::const_iterator iter;
for (iter = fill_data.additional_logins.begin();
iter != fill_data.additional_logins.end(); ++iter) {
@@ -501,11 +505,19 @@
string16 username;
string16 password;
+ // If there isn't any username form, just exit.
+ // Because this function is used for the case
+ // that the username form and the possword form exist.
+ if (fill_data.GetDataType() ==
+ webkit::forms::PasswordFormFillData::kOnlyPassword) {
+ return false;
+ }
+
// Look for any suitable matches to current field text.
- if (DoUsernamesMatch(fill_data.basic_data.fields[0].value, current_username,
+ if (DoUsernamesMatch(fill_data.GetUsernameField().value, current_username,
exact_username_match)) {
- username = fill_data.basic_data.fields[0].value;
- password = fill_data.basic_data.fields[1].value;
+ username = fill_data.GetUsernameField().value;
+ password = fill_data.GetPasswordField().value;
} else {
// Scan additional logins for a match.
webkit::forms::PasswordFormFillData::LoginCollection::const_iterator iter;

Powered by Google App Engine
This is Rietveld 408576698