summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/autofill
diff options
context:
space:
mode:
authorzysxqn@google.com <zysxqn@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-29 22:08:39 +0000
committerzysxqn@google.com <zysxqn@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-29 22:08:39 +0000
commitca22b3c67bed31e4540c57ffa1d09dbc193fcb3e (patch)
treeef870fb51fe86b9c5e6bdb17b5aa7f2e536bb9d0 /chrome/renderer/autofill
parent08b59a27f09c5868cbca926f8259148d37821c46 (diff)
downloadchromium_src-ca22b3c67bed31e4540c57ffa1d09dbc193fcb3e.zip
chromium_src-ca22b3c67bed31e4540c57ffa1d09dbc193fcb3e.tar.gz
chromium_src-ca22b3c67bed31e4540c57ffa1d09dbc193fcb3e.tar.bz2
Focus should be moved to the next input field after we generate the password.
BUG=131390 TEST=PasswordGenerationManagerTest Review URL: https://chromiumcodereview.appspot.com/10705006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145007 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/autofill')
-rw-r--r--chrome/renderer/autofill/password_generation_manager.cc6
-rw-r--r--chrome/renderer/autofill/password_generation_manager.h2
-rw-r--r--chrome/renderer/autofill/password_generation_manager_browsertest.cc8
3 files changed, 15 insertions, 1 deletions
diff --git a/chrome/renderer/autofill/password_generation_manager.cc b/chrome/renderer/autofill/password_generation_manager.cc
index ac93760..1e7b6fa 100644
--- a/chrome/renderer/autofill/password_generation_manager.cc
+++ b/chrome/renderer/autofill/password_generation_manager.cc
@@ -56,8 +56,9 @@ bool GetAccountCreationPasswordFields(
PasswordGenerationManager::PasswordGenerationManager(
content::RenderView* render_view)
: content::RenderViewObserver(render_view),
+ render_view_(render_view),
enabled_(false) {
- render_view->GetWebView()->addTextFieldDecoratorClient(this);
+ render_view_->GetWebView()->addTextFieldDecoratorClient(this);
}
PasswordGenerationManager::~PasswordGenerationManager() {}
@@ -189,6 +190,9 @@ void PasswordGenerationManager::OnPasswordAccepted(const string16& password) {
it != passwords_.end(); ++it) {
it->setValue(password);
it->setAutofilled(true);
+ // Advance focus to the next input field. We assume password fields in
+ // an account creation form are always adjacent.
+ render_view_->GetWebView()->advanceFocus(false);
}
}
diff --git a/chrome/renderer/autofill/password_generation_manager.h b/chrome/renderer/autofill/password_generation_manager.h
index c5fffa2..6e27205 100644
--- a/chrome/renderer/autofill/password_generation_manager.h
+++ b/chrome/renderer/autofill/password_generation_manager.h
@@ -68,6 +68,8 @@ class PasswordGenerationManager : public content::RenderViewObserver,
// Helper function to decide whether we should show password generation icon.
void MaybeShowIcon();
+ content::RenderView* render_view_;
+
// True if password generation is enabled for the profile associated
// with this renderer.
bool enabled_;
diff --git a/chrome/renderer/autofill/password_generation_manager_browsertest.cc b/chrome/renderer/autofill/password_generation_manager_browsertest.cc
index 0095c4a..6b434e8 100644
--- a/chrome/renderer/autofill/password_generation_manager_browsertest.cc
+++ b/chrome/renderer/autofill/password_generation_manager_browsertest.cc
@@ -106,6 +106,7 @@ const char kAccountCreationFormHTML[] =
" <INPUT type = 'text' id = 'username'/> "
" <INPUT type = 'password' id = 'first_password' size=5/> "
" <INPUT type = 'password' id = 'second_password' size=5/> "
+ " <INPUT type = 'text' id = 'address'/> "
" <INPUT type = 'submit' value = 'LOGIN' />"
"</FORM>";
@@ -210,6 +211,13 @@ TEST_F(PasswordGenerationManagerTest, FillTest) {
EXPECT_EQ(password, second_password_element.value());
EXPECT_TRUE(first_password_element.isAutofilled());
EXPECT_TRUE(second_password_element.isAutofilled());
+
+ // Focus moved to the next input field.
+ // TODO(zysxqn): Change this back to the address element once Bug 90224
+ // https://bugs.webkit.org/show_bug.cgi?id=90224 has been fixed.
+ element = document.getElementById(WebString::fromUTF8("first_password"));
+ ASSERT_FALSE(element.isNull());
+ EXPECT_EQ(element, document.focusedNode());
}
TEST_F(PasswordGenerationManagerTest, BlacklistedTest) {