From e6956ee8c5f023f65f4471f922002c2a273996d6 Mon Sep 17 00:00:00 2001 From: "dhollowa@chromium.org" Date: Thu, 13 Jan 2011 23:43:58 +0000 Subject: Password Autofill disables auto-completed textfield This change fixes an issue where the password completion, when the tab key is used to cycle focus, was causing focus to get lost. BUG=67888 TEST=PasswordAutocompleteManagerTest.*, and manual tests according to bug. Review URL: http://codereview.chromium.org/6280003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71383 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/password_autocomplete_manager.cc | 20 ++++++++++++++------ chrome/renderer/password_autocomplete_manager.h | 3 ++- 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'chrome/renderer') diff --git a/chrome/renderer/password_autocomplete_manager.cc b/chrome/renderer/password_autocomplete_manager.cc index a18f9b8..2c59b7d 100644 --- a/chrome/renderer/password_autocomplete_manager.cc +++ b/chrome/renderer/password_autocomplete_manager.cc @@ -241,7 +241,10 @@ bool PasswordAutocompleteManager::TextFieldDidEndEditing( return false; WebKit::WebInputElement username = element; // We need a non-const. - FillUserNameAndPassword(&username, &password, fill_data, true); + + // Do not set selection when ending an editing session, otherwise it can + // mess with focus. + FillUserNameAndPassword(&username, &password, fill_data, true, false); return true; } @@ -317,7 +320,7 @@ bool PasswordAutocompleteManager::FillPassword( WebKit::WebInputElement password = iter->second.password_field; WebKit::WebInputElement non_const_user_input(user_input); return FillUserNameAndPassword(&non_const_user_input, &password, - fill_data, true); + fill_data, true, true); } void PasswordAutocompleteManager::PerformInlineAutocomplete( @@ -341,7 +344,7 @@ void PasswordAutocompleteManager::PerformInlineAutocomplete( ShowSuggestionPopup(fill_data, username); // Fill the user and password field with the most relevant match. - FillUserNameAndPassword(&username, &password, fill_data, false); + FillUserNameAndPassword(&username, &password, fill_data, false, true); } void PasswordAutocompleteManager::SendPasswordForms(WebKit::WebFrame* frame, @@ -436,7 +439,8 @@ bool PasswordAutocompleteManager::FillUserNameAndPassword( WebKit::WebInputElement* username_element, WebKit::WebInputElement* password_element, const webkit_glue::PasswordFormFillData& fill_data, - bool exact_username_match) { + bool exact_username_match, + bool set_selection) { string16 current_username = username_element->value(); // username and password will contain the match found if any. string16 username; @@ -465,8 +469,12 @@ bool PasswordAutocompleteManager::FillUserNameAndPassword( // Input matches the username, fill in required values. username_element->setValue(username); - username_element->setSelectionRange(current_username.length(), - username.length()); + + if (set_selection) { + username_element->setSelectionRange(current_username.length(), + username.length()); + } + SetElementAutofilled(username_element, true); if (IsElementEditable(*password_element)) password_element->setValue(password); diff --git a/chrome/renderer/password_autocomplete_manager.h b/chrome/renderer/password_autocomplete_manager.h index cf6c4eb..c4e4b2f 100644 --- a/chrome/renderer/password_autocomplete_manager.h +++ b/chrome/renderer/password_autocomplete_manager.h @@ -89,7 +89,8 @@ class PasswordAutocompleteManager : public PageClickListener { WebKit::WebInputElement* username_element, WebKit::WebInputElement* password_element, const webkit_glue::PasswordFormFillData& fill_data, - bool exact_username_match); + bool exact_username_match, + bool set_selection); // Convenience method that returns the routing ID of the render view we are // associated with. -- cgit v1.1