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

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

Issue 1208133002: [Autofill/Autocomplete Feature] Substring matching instead of prefix matching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added |match_start| usage. Created 5 years, 6 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 f0dcefd80475482fc096bf1c14839fd18cab75d4..727b515bf6d699480732d09f408ac11f820e69ec 100644
--- a/components/autofill/content/renderer/password_autofill_agent.cc
+++ b/components/autofill/content/renderer/password_autofill_agent.cc
@@ -4,6 +4,8 @@
#include "components/autofill/content/renderer/password_autofill_agent.h"
+#include <algorithm>
+
#include "base/bind.h"
#include "base/command_line.h"
#include "base/memory/scoped_ptr.h"
@@ -778,10 +780,10 @@ bool PasswordAutofillAgent::FillSuggestion(
return true;
}
-bool PasswordAutofillAgent::PreviewSuggestion(
- const blink::WebNode& node,
- const blink::WebString& username,
- const blink::WebString& password) {
+bool PasswordAutofillAgent::PreviewSuggestion(const blink::WebNode& node,
+ const blink::WebString& username,
+ const blink::WebString& password,
+ int match_start) {
blink::WebInputElement username_element;
PasswordInfo* password_info;
@@ -792,7 +794,8 @@ bool PasswordAutofillAgent::PreviewSuggestion(
}
was_username_autofilled_ = username_element.isAutofilled();
- username_selection_start_ = username_element.selectionStart();
+ username_selection_start_ =
+ std::min(match_start, username_element.maxLength());
username_element.setSuggestedValue(username);
username_element.setAutofilled(true);
username_element.setSelectionRange(

Powered by Google App Engine
This is Rietveld 408576698