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

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

Issue 184103016: Autofill: Refactoring to support fetching password after a username is selected (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Actually fix compile failure. Created 6 years, 8 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/password_autofill_agent.cc
diff --git a/components/autofill/content/renderer/password_autofill_agent.cc b/components/autofill/content/renderer/password_autofill_agent.cc
index e2714226c66f8bd9963fbdeef86d245fae659c66..d1fa6a8ec0ab91807f9a5074fe757611705a5032 100644
--- a/components/autofill/content/renderer/password_autofill_agent.cc
+++ b/components/autofill/content/renderer/password_autofill_agent.cc
@@ -344,21 +344,29 @@ bool PasswordAutofillAgent::TextFieldHandlingKeyDown(
return true;
}
-bool PasswordAutofillAgent::DidAcceptAutofillSuggestion(
+bool PasswordAutofillAgent::AcceptSuggestion(
const blink::WebNode& node,
- const blink::WebString& username) {
- blink::WebInputElement input;
- PasswordInfo password;
- if (!FindLoginInfo(node, &input, &password))
+ const blink::WebString& username,
+ const blink::WebString& password) {
+ blink::WebInputElement username_element;
+ PasswordInfo password_info;
+
+ if (!FindLoginInfo(node, &username_element, &password_info) ||
+ !IsElementAutocompletable(username_element) ||
+ !IsElementAutocompletable(password_info.password_field)) {
return false;
+ }
- // Set the incoming |username| in the text field and |FillUserNameAndPassword|
- // will do the rest.
- input.setValue(username, true);
- return FillUserNameAndPassword(&input, &password.password_field,
- password.fill_data,
- true /* exact_username_match */,
- true /* set_selection */);
+ base::string16 current_username = username_element.value();
+ username_element.setValue(username, true);
+ username_element.setAutofilled(true);
+ username_element.setSelectionRange(current_username.length(),
+ username.length());
+
+ password_info.password_field.setValue(password, true);
+ password_info.password_field.setAutofilled(true);
+
+ return true;
}
bool PasswordAutofillAgent::DidClearAutofillSelection(
« no previous file with comments | « components/autofill/content/renderer/password_autofill_agent.h ('k') | components/autofill/core/browser/autofill_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698