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

Unified Diff: components/autofill/content/renderer/autofill_agent.cc

Issue 208453002: Add "previewing on hover" support for password field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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: components/autofill/content/renderer/autofill_agent.cc
diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc
index 5f3b03043eb0d6793db7fb47026ea428a26ab0ec..b017f9d48bc4acf5c296e0307e0a6b46cabef144 100644
--- a/components/autofill/content/renderer/autofill_agent.cc
+++ b/components/autofill/content/renderer/autofill_agent.cc
@@ -157,6 +157,7 @@ bool AutofillAgent::OnMessageReceived(const IPC::Message& message) {
OnAcceptDataListSuggestion)
IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion,
OnAcceptPasswordAutofillSuggestion)
+ IPC_MESSAGE_HANDLER(AutofillMsg_PreviewPassword, OnPreviewPassword)
IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult,
OnRequestAutocompleteResult)
IPC_MESSAGE_UNHANDLED(handled = false)
@@ -436,10 +437,22 @@ void AutofillAgent::OnClearForm() {
void AutofillAgent::OnClearPreviewedForm() {
if (!element_.isNull()) {
- if (password_autofill_agent_->DidClearAutofillSelection(element_))
+ if (password_autofill_agent_->DidClearAutofillSelection(element_) &&
+ !is_password_previewed_)
return;
- ClearPreviewedFormWithElement(element_, was_query_node_autofilled_);
+ if(is_password_previewed_) {
+ ClearPreviewedFormWithElement(
+ element_,
+ REQUIRE_NONE,
+ was_query_node_autofilled_,
+ password_autofill_agent_->WasPasswordAutofilled());
+ } else {
+ ClearPreviewedFormWithElement(element_,
+ REQUIRE_AUTOCOMPLETE,
+ was_query_node_autofilled_,
+ false);
+ }
} else {
// TODO(isherman): There seem to be rare cases where this code *is*
// reachable: see [ http://crbug.com/96321#c6 ]. Ideally we would
@@ -473,6 +486,15 @@ void AutofillAgent::OnAcceptPasswordAutofillSuggestion(
DCHECK(handled);
}
+void AutofillAgent::OnPreviewPassword(const base::string16& username) {
+ was_query_node_autofilled_ = element_.isAutofilled();
+ bool handled = password_autofill_agent_->DidSelectAutofillSuggestion(
+ element_,
+ username);
+ is_password_previewed_ = handled;
+ DCHECK(handled);
+}
+
void AutofillAgent::OnRequestAutocompleteResult(
WebFormElement::AutocompleteResult result,
const FormData& form_data) {

Powered by Google App Engine
This is Rietveld 408576698