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

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

Issue 962673004: [Autofill/Autocomplete Feature] Substring matching instead of prefix matching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Just code rebase. 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..3447a3d51c2e94d3b08a97021f27f5ae0dc5c007 100644
--- a/components/autofill/content/renderer/password_autofill_agent.cc
+++ b/components/autofill/content/renderer/password_autofill_agent.cc
@@ -17,6 +17,7 @@
#include "components/autofill/content/renderer/renderer_save_password_progress_logger.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/autofill/core/common/autofill_switches.h"
+#include "components/autofill/core/common/autofill_util.h"
#include "components/autofill/core/common/form_field_data.h"
#include "components/autofill/core/common/password_form.h"
#include "components/autofill/core/common/password_form_fill_data.h"
@@ -225,7 +226,8 @@ bool DoUsernamesMatch(const base::string16& username1,
bool exact_match) {
if (exact_match)
return username1 == username2;
- return base::StartsWith(username1, username2, true);
+ return base::StartsWith(username1, username2, true) ||
+ ContainsTokenThatStartsWith(username1, username2, true);
please use gerrit instead 2015/06/28 00:43:03 1) Change ContainsTokenThatStartsWith() to use bas
Pritam Nikam 2015/06/29 15:38:21 We do rank suggestions based on MFU, moving |base:
please use gerrit instead 2015/06/29 22:06:28 Do we ever use ContainsTokenThatStartsWith() witho
Pritam Nikam 2015/06/30 15:05:50 Yes. We have to treat both cases seperatly for bel
}
// Returns |true| if the given element is editable. Otherwise, returns |false|.
@@ -415,8 +417,14 @@ bool FillUserNameAndPassword(
username_element->setAutofilled(true);
if (set_selection) {
- username_element->setSelectionRange(current_username.length(),
- username.length());
+ if (IsFeatureSubstringMatchEnabled()) {
please use gerrit instead 2015/06/28 00:43:03 Use PreviewSuggestion() here.
Pritam Nikam 2015/06/29 15:38:21 Acknowledged. I'm getting some problem here, sha
please use gerrit instead 2015/06/29 22:06:28 I can help you resolve the issue if you describe i
Pritam Nikam 2015/06/30 15:05:50 For password forms, we autocomplets the suggestion
+ size_t start =
+ autofill::GetTextSelectionStart(username, current_username);
+ username_element->setSelectionRange(start, username.length());
+ } else {
+ username_element->setSelectionRange(current_username.length(),
+ username.length());
+ }
}
} else if (current_username != username) {
// If the username can't be filled and it doesn't match a saved password
@@ -791,13 +799,22 @@ bool PasswordAutofillAgent::PreviewSuggestion(
return false;
}
+ base::string16 current_username = username_element.value();
+ base::string16 suggested_username = username;
please use gerrit instead 2015/06/28 00:43:03 No need for these temporary variables on lines 802
Pritam Nikam 2015/06/29 15:38:21 Done.
please use gerrit instead 2015/06/29 22:06:28 They're still here. I think you were planning to r
Pritam Nikam 2015/06/30 15:05:50 Done. Yes, I forgot to get rid of these.
was_username_autofilled_ = username_element.isAutofilled();
username_selection_start_ = username_element.selectionStart();
username_element.setSuggestedValue(username);
username_element.setAutofilled(true);
- username_element.setSelectionRange(
- username_selection_start_,
- username_element.suggestedValue().length());
+
+ if (IsFeatureSubstringMatchEnabled()) {
please use gerrit instead 2015/06/28 00:43:03 Use PreviewSuggestion() here.
Pritam Nikam 2015/06/29 15:38:21 Done.
+ size_t start =
+ autofill::GetTextSelectionStart(suggested_username, current_username);
+ username_element.setSelectionRange(start, suggested_username.length());
+ was_username_autofilled_ = start;
+ } else {
+ username_element.setSelectionRange(
+ username_selection_start_, username_element.suggestedValue().length());
+ }
was_password_autofilled_ = password_info->password_field.isAutofilled();
password_info->password_field.setSuggestedValue(password);

Powered by Google App Engine
This is Rietveld 408576698