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

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

Issue 166043006: Add password manager autocomplete suggestion when a username element in clicked. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed a comment and cleaned up a browser test Created 6 years, 10 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 df8056242e3eed16495550ae170eeafec6200860..036b0a5170d0fdece64225d6633285358480bd0a 100644
--- a/components/autofill/content/renderer/password_autofill_agent.cc
+++ b/components/autofill/content/renderer/password_autofill_agent.cc
@@ -317,7 +317,7 @@ bool PasswordAutofillAgent::TextDidChangeInTextField(
// But refresh the popup. Note, since this is ours, return true to signal
// no further processing is required.
if (iter->second.backspace_pressed_last) {
- ShowSuggestionPopup(iter->second.fill_data, username);
+ ShowSuggestionPopup(iter->second.fill_data, username, false);
return true;
}
@@ -376,7 +376,8 @@ bool PasswordAutofillAgent::DidClearAutofillSelection(
}
bool PasswordAutofillAgent::ShowSuggestions(
- const blink::WebInputElement& element) {
+ const blink::WebInputElement& element,
+ bool show_all) {
LoginToPasswordInfoMap::const_iterator iter =
login_to_password_info_.find(element);
if (iter == login_to_password_info_.end())
@@ -390,7 +391,7 @@ bool PasswordAutofillAgent::ShowSuggestions(
!IsElementAutocompletable(iter->second.password_field))
return true;
- return ShowSuggestionPopup(iter->second.fill_data, element);
+ return ShowSuggestionPopup(iter->second.fill_data, element, show_all);
}
bool PasswordAutofillAgent::OriginCanAccessPasswordManager(
@@ -653,8 +654,10 @@ void PasswordAutofillAgent::GetSuggestions(
const PasswordFormFillData& fill_data,
const base::string16& input,
std::vector<base::string16>* suggestions,
- std::vector<base::string16>* realms) {
- if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) {
+ std::vector<base::string16>* realms,
+ bool show_all) {
+ if (show_all ||
+ StartsWith(fill_data.basic_data.fields[0].value, input, false)) {
suggestions->push_back(fill_data.basic_data.fields[0].value);
realms->push_back(base::UTF8ToUTF16(fill_data.preferred_realm));
}
@@ -662,7 +665,7 @@ void PasswordAutofillAgent::GetSuggestions(
for (PasswordFormFillData::LoginCollection::const_iterator iter =
fill_data.additional_logins.begin();
iter != fill_data.additional_logins.end(); ++iter) {
- if (StartsWith(iter->first, input, false)) {
+ if (show_all || StartsWith(iter->first, input, false)) {
suggestions->push_back(iter->first);
realms->push_back(base::UTF8ToUTF16(iter->second.realm));
}
@@ -672,7 +675,7 @@ void PasswordAutofillAgent::GetSuggestions(
fill_data.other_possible_usernames.begin();
iter != fill_data.other_possible_usernames.end(); ++iter) {
for (size_t i = 0; i < iter->second.size(); ++i) {
- if (StartsWith(iter->second[i], input, false)) {
+ if (show_all || StartsWith(iter->second[i], input, false)) {
usernames_usage_ = OTHER_POSSIBLE_USERNAME_SHOWN;
suggestions->push_back(iter->second[i]);
realms->push_back(base::UTF8ToUTF16(iter->first.realm));
@@ -683,7 +686,8 @@ void PasswordAutofillAgent::GetSuggestions(
bool PasswordAutofillAgent::ShowSuggestionPopup(
const PasswordFormFillData& fill_data,
- const blink::WebInputElement& user_input) {
+ const blink::WebInputElement& user_input,
+ bool show_all) {
blink::WebFrame* frame = user_input.document().frame();
if (!frame)
return false;
@@ -694,7 +698,8 @@ bool PasswordAutofillAgent::ShowSuggestionPopup(
std::vector<base::string16> suggestions;
std::vector<base::string16> realms;
- GetSuggestions(fill_data, user_input.value(), &suggestions, &realms);
+ GetSuggestions(
+ fill_data, user_input.value(), &suggestions, &realms, show_all);
DCHECK_EQ(suggestions.size(), realms.size());
FormData form;
@@ -861,8 +866,7 @@ void PasswordAutofillAgent::PerformInlineAutocomplete(
}
// Show the popup with the list of available usernames.
- ShowSuggestionPopup(fill_data, username);
-
+ ShowSuggestionPopup(fill_data, username, false);
#if !defined(OS_ANDROID)
// Fill the user and password field with the most relevant match. Android

Powered by Google App Engine
This is Rietveld 408576698