Commit 4437c357 authored by Friedrich Horschig's avatar Friedrich Horschig Committed by Commit Bot

[Autofill Android] Suppress suggestions for exact matches

If a field in a filled form is focused, the shown suggestions match the
field contents. When the shown suggestion is an exact match, clicking it
will fill the exact same content again -- effectively, it's a no-op.
This CL hides exact matches on Android.

This is harmless unless label disambiguation is enabled. Now, a sublabel
seemingly differentiates between multiple suggestions since their
sublabels differ. But clicking any of the suggestions will again only
fill the selected field (which is still a no-op). If a user is presented
with multiple different options, they will expect that each option fills
the entire dataset that a label represents. Instead, they get multiple,
differently labeled no-ops.

For Android, disambiguation labels are very prominent, especially in the
keyboard accessory which hosts them. Therefore, it makes sense to hide
the no-op suggestions completely.

For Desktop, label disambiguation isn't launched yet and the dataset
merging algorithm aggressively filters the datasets to one single
suggestion. This means the issue isn't very prominent. Hiding the labels
would actually have a negative side-effect: there would be no access to
the "Clear Form" option (which currently isn't visible on Android).

Bug: 1000039
Change-Id: Ibe43617202003900b3fa0f80259906d8467993eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787598
Commit-Queue: Friedrich [CET] <fhorschig@chromium.org>
Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693713}
parent abb95d20
...@@ -1145,8 +1145,8 @@ std::vector<Suggestion> PersonalDataManager::GetProfileSuggestions( ...@@ -1145,8 +1145,8 @@ std::vector<Suggestion> PersonalDataManager::GetProfileSuggestions(
std::vector<AutofillProfile*> matched_profiles; std::vector<AutofillProfile*> matched_profiles;
std::vector<Suggestion> suggestions = std::vector<Suggestion> suggestions =
suggestion_selection::GetPrefixMatchedSuggestions( suggestion_selection::GetPrefixMatchedSuggestions(
type, field_contents_canon, comparator, sorted_profiles, type, field_contents, field_contents_canon, comparator,
&matched_profiles); field_is_autofilled, sorted_profiles, &matched_profiles);
// Don't show two suggestions if one is a subset of the other. // Don't show two suggestions if one is a subset of the other.
std::vector<AutofillProfile*> unique_matched_profiles; std::vector<AutofillProfile*> unique_matched_profiles;
......
...@@ -67,8 +67,10 @@ constexpr size_t kMaxPrunedUniqueSuggestionsCount = 3; ...@@ -67,8 +67,10 @@ constexpr size_t kMaxPrunedUniqueSuggestionsCount = 3;
std::vector<Suggestion> GetPrefixMatchedSuggestions( std::vector<Suggestion> GetPrefixMatchedSuggestions(
const AutofillType& type, const AutofillType& type,
const base::string16& raw_field_contents,
const base::string16& field_contents_canon, const base::string16& field_contents_canon,
const AutofillProfileComparator& comparator, const AutofillProfileComparator& comparator,
bool field_is_autofilled,
const std::vector<AutofillProfile*>& profiles, const std::vector<AutofillProfile*>& profiles,
std::vector<AutofillProfile*>* matched_profiles) { std::vector<AutofillProfile*>* matched_profiles) {
std::vector<Suggestion> suggestions; std::vector<Suggestion> suggestions;
...@@ -81,6 +83,19 @@ std::vector<Suggestion> GetPrefixMatchedSuggestions( ...@@ -81,6 +83,19 @@ std::vector<Suggestion> GetPrefixMatchedSuggestions(
if (profile->ShouldSkipFillingOrSuggesting(type.GetStorableType())) if (profile->ShouldSkipFillingOrSuggesting(type.GetStorableType()))
continue; continue;
// Don't offer to fill the exact same value again. If detailed suggestions
// with different secondary data is available, it would appear to offer
// refilling the whole form with something else. E.g. the same name with a
// work and a home address would appear twice but a click would be a noop.
// TODO(fhorschig): Consider refilling form instead (at on least Android).
#if defined(OS_ANDROID)
if (base::FeatureList::IsEnabled(features::kAutofillKeyboardAccessory) &&
field_is_autofilled &&
profile->GetRawInfo(type.GetStorableType()) == raw_field_contents) {
continue;
}
#endif // defined(OS_ANDROID) || defined(OS_IOS)
base::string16 value = base::string16 value =
GetInfoInOneLine(profile, type, comparator.app_locale()); GetInfoInOneLine(profile, type, comparator.app_locale());
if (value.empty()) if (value.empty())
......
...@@ -30,8 +30,10 @@ extern const size_t kMaxPrunedUniqueSuggestionsCount; ...@@ -30,8 +30,10 @@ extern const size_t kMaxPrunedUniqueSuggestionsCount;
// |kMaxSuggestedProfilesCount| are returned. // |kMaxSuggestedProfilesCount| are returned.
std::vector<Suggestion> GetPrefixMatchedSuggestions( std::vector<Suggestion> GetPrefixMatchedSuggestions(
const AutofillType& type, const AutofillType& type,
const base::string16& raw_field_contents,
const base::string16& field_contents_canon, const base::string16& field_contents_canon,
const AutofillProfileComparator& comparator, const AutofillProfileComparator& comparator,
bool field_is_autofilled,
const std::vector<AutofillProfile*>& profiles, const std::vector<AutofillProfile*>& profiles,
std::vector<AutofillProfile*>* matched_profiles); std::vector<AutofillProfile*>* matched_profiles);
......
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