Commit 34b020bf authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Autofill] Hide suggestion only if form isn't autofilled

Before this patch:
"Hide suggestions" entry was always added when there are non-empty
suggestions.
When the user selects a suggestion, a new entry is added to
"Clear form".
And there is always an entry to "Manage addresses...".
As a result, when the user select an entry, there are 3 extra entries
added.

After this patch:
"Hide suggestions" is only shown if the user didn't interact with the
suggestions. If the user selects one suggestion, this indicates the
suggestions are actually useful. If the user clears the form, they will
be presented with "Hide suggestions" again.

i.e. the "Hide suggestions" and "Clear form" are alternating but they
never appear together in the suggestions list.
As a result, we at most have 2 extra entries added.



Bug: 1030649
Change-Id: Icf4e81f141db8018fbbf7029dec0472d70db9153
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2083172Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745933}
parent 152f125d
...@@ -122,11 +122,17 @@ void AutofillExternalDelegate::OnSuggestionsReturned( ...@@ -122,11 +122,17 @@ void AutofillExternalDelegate::OnSuggestionsReturned(
defined(OS_CHROMEOS) defined(OS_CHROMEOS)
if (base::FeatureList::IsEnabled( if (base::FeatureList::IsEnabled(
features::kAutofillEnableHideSuggestionsUI)) { features::kAutofillEnableHideSuggestionsUI)) {
if (!suggestions.empty() && (GetPopupType() == PopupType::kAddresses || // If the user has selected a suggestion, it indicates the suggestions are
GetPopupType() == PopupType::kUnspecified)) { // useful to the user and no need hide them. In this case,
suggestions.push_back( // ApplyAutofillOptions() should have added a "Clear form" option instead.
Suggestion(l10n_util::GetStringUTF16(IDS_AUTOFILL_HIDE_SUGGESTIONS))); if (!query_field_.is_autofilled) {
suggestions.back().frontend_id = POPUP_ITEM_ID_HIDE_AUTOFILL_SUGGESTIONS; if (!suggestions.empty() && (GetPopupType() == PopupType::kAddresses ||
GetPopupType() == PopupType::kUnspecified)) {
suggestions.push_back(Suggestion(
l10n_util::GetStringUTF16(IDS_AUTOFILL_HIDE_SUGGESTIONS)));
suggestions.back().frontend_id =
POPUP_ITEM_ID_HIDE_AUTOFILL_SUGGESTIONS;
}
} }
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment