diff options
author | gcasto@chromium.org <gcasto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-12 11:47:02 +0000 |
---|---|---|
committer | gcasto@chromium.org <gcasto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-12 11:48:57 +0000 |
commit | 42f315f4e700fb8ec2a7c90a575df4b8da2a3771 (patch) | |
tree | 5940f1e4aaa1a2cb7f996311b78da8ecd7a12dd5 /components | |
parent | db4461b93accc68837dffd4adf0091649be7d585 (diff) | |
download | chromium_src-42f315f4e700fb8ec2a7c90a575df4b8da2a3771.zip chromium_src-42f315f4e700fb8ec2a7c90a575df4b8da2a3771.tar.gz chromium_src-42f315f4e700fb8ec2a7c90a575df4b8da2a3771.tar.bz2 |
[Password Generation] Wait longer to dismiss suggestion UI
UX feedback is that users generally look at the keyboard when starting to
type passwords and thus miss the prompt. The UI will now show until the user
types 5 characters instead of being dismissed after they type anything.
BUG=318977
Review URL: https://codereview.chromium.org/447873004
Cr-Commit-Position: refs/heads/master@{#288935}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288935 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r-- | components/autofill/content/renderer/password_generation_agent.cc | 19 | ||||
-rw-r--r-- | components/autofill/content/renderer/password_generation_agent.h | 3 |
2 files changed, 16 insertions, 6 deletions
diff --git a/components/autofill/content/renderer/password_generation_agent.cc b/components/autofill/content/renderer/password_generation_agent.cc index e90f1c9..b777c9c 100644 --- a/components/autofill/content/renderer/password_generation_agent.cc +++ b/components/autofill/content/renderer/password_generation_agent.cc @@ -288,10 +288,12 @@ bool PasswordGenerationAgent::FocusedNodeHasChanged( return true; } - // Only trigger if the password field is empty. + // Assume that if the password field has less than kMaximumOfferSize + // characters then the user is not finished typing their password and display + // the password suggestion. if (!element->isReadOnly() && element->isEnabled() && - element->value().isEmpty()) { + element->value().length() <= kMaximumOfferSize) { ShowGenerationPopup(); return true; } @@ -318,10 +320,7 @@ bool PasswordGenerationAgent::TextDidChangeInTextField( // Offer generation again. ShowGenerationPopup(); - } else if (!password_is_generated_) { - // User has rejected the feature and has started typing a password. - HidePopup(); - } else { + } else if (password_is_generated_) { password_edited_ = true; // Mirror edits to any confirmation password fields. for (std::vector<blink::WebInputElement>::iterator it = @@ -329,6 +328,14 @@ bool PasswordGenerationAgent::TextDidChangeInTextField( it != password_elements_.end(); ++it) { it->setValue(element.value()); } + } else if (element.value().length() > kMaximumOfferSize) { + // User has rejected the feature and has started typing a password. + HidePopup(); + } else { + // Password isn't generated and there are fewer than kMaximumOfferSize + // characters typed, so keep offering the password. Note this function + // will just keep the previous popup if one is already showing. + ShowGenerationPopup(); } return true; diff --git a/components/autofill/content/renderer/password_generation_agent.h b/components/autofill/content/renderer/password_generation_agent.h index bf632ae..2d75af0 100644 --- a/components/autofill/content/renderer/password_generation_agent.h +++ b/components/autofill/content/renderer/password_generation_agent.h @@ -39,6 +39,9 @@ class PasswordGenerationAgent : public content::RenderViewObserver { // Returns true if the newly focused node caused the generation UI to show. bool FocusedNodeHasChanged(const blink::WebNode& node); + // The length that a password can be before the UI is hidden. + static const size_t kMaximumOfferSize = 5; + protected: // Returns true if this document is one that we should consider analyzing. // Virtual so that it can be overriden during testing. |