summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlaforge@chromium.org <laforge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-14 00:11:48 +0000
committerlaforge@chromium.org <laforge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-14 00:11:48 +0000
commit50b798289548aeee6f819fb6eafe896c74239a9c (patch)
tree61ebd24de5e61199fb55ebd713128dca407bcb60
parent16bff853ad72d93837d6d865c61c911007be125c (diff)
downloadchromium_src-50b798289548aeee6f819fb6eafe896c74239a9c.zip
chromium_src-50b798289548aeee6f819fb6eafe896c74239a9c.tar.gz
chromium_src-50b798289548aeee6f819fb6eafe896c74239a9c.tar.bz2
Merge 71383 - 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 TBR=dhollowa@chromium.org Review URL: http://codereview.chromium.org/6247004 git-svn-id: svn://svn.chromium.org/chrome/branches/597/src@71393 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/renderer/password_autocomplete_manager.cc20
-rw-r--r--chrome/renderer/password_autocomplete_manager.h3
2 files changed, 16 insertions, 7 deletions
diff --git a/chrome/renderer/password_autocomplete_manager.cc b/chrome/renderer/password_autocomplete_manager.cc
index 284f12f..4e24a05 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,
@@ -430,7 +433,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;
@@ -459,8 +463,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.