[Autofill] Use field signatures as a fallback to retrieve cached fields.
The usage of Java script in forms can result in unstable renderer ids and therefore cache misses. This is mitigated by using unique-only field signatures as a fallback. Change-Id: Icae0f719c8ad1ea4de9dd9ab142b0d6aa746b2ab Bug: 1087386, 1091401 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2396141 Reviewed-by: Christoph Schwering <schwering@google.com> Commit-Queue: Matthias Körber <koerber@google.com> Cr-Commit-Position: refs/heads/master@{#805806}
This commit is contained in:

committed by
Commit Bot

parent
04e7944199
commit
2ef0a52af2
components/autofill/core
@ -1115,6 +1115,30 @@ void FormStructure::RetrieveFromCache(
|
||||
cached_field = it->second;
|
||||
}
|
||||
|
||||
// If the unique renderer id (or the name) is not stable due to some Java
|
||||
// Script magic in the website, use the field signature as a fallback
|
||||
// solution to find the field in the cached form.
|
||||
// TODO(crbug.com/1125624): Remove feature check once trial ended.
|
||||
if (!cached_field &&
|
||||
base::FeatureList::IsEnabled(
|
||||
features::kAutofillRetrieveFromCacheWithFieldSignatureAsFallback)) {
|
||||
// Iterates over the fields to find the field with the same form
|
||||
// signature.
|
||||
for (size_t i = 0; i < cached_form.field_count(); ++i) {
|
||||
auto* const cfield = cached_form.field(i);
|
||||
if (field->GetFieldSignature() == cfield->GetFieldSignature()) {
|
||||
// If there are multiple matches, do not retrieve the field and stop
|
||||
// the process.
|
||||
if (cached_field) {
|
||||
cached_field = nullptr;
|
||||
break;
|
||||
} else {
|
||||
cached_field = cfield;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cached_field) {
|
||||
if (!only_server_and_autofill_state) {
|
||||
// Transfer attributes of the cached AutofillField to the newly created
|
||||
|
@ -159,6 +159,13 @@ const base::Feature kAutofillRetrieveFromCacheWithRendererIds{
|
||||
"AutofillRetrieveFromCacheWithRendererIds",
|
||||
base::FEATURE_DISABLED_BY_DEFAULT};
|
||||
|
||||
// When enabled, Autofill will try to retrieve cached fields by signatures as a
|
||||
// fallback that is useful if unique renderer ids are unstable.
|
||||
// TODO(crbug.com/1125624): Remove experiment once trial ended.
|
||||
const base::Feature kAutofillRetrieveFromCacheWithFieldSignatureAsFallback{
|
||||
"AutofillRetrieveFromCacheWithFieldSignatureAsFallback",
|
||||
base::FEATURE_DISABLED_BY_DEFAULT};
|
||||
|
||||
// When enabled, autofill suggestions are displayed in the keyboard accessory
|
||||
// instead of the regular popup.
|
||||
const base::Feature kAutofillKeyboardAccessory{
|
||||
|
@ -45,6 +45,8 @@ extern const base::Feature kAutofillFixFillableFieldTypes;
|
||||
extern const base::Feature kAutofillImportPrefilledCountryAndStateValues;
|
||||
extern const base::Feature kAutofillKeepInitialFormValuesInCache;
|
||||
extern const base::Feature kAutofillRetrieveFromCacheWithRendererIds;
|
||||
extern const base::Feature
|
||||
kAutofillRetrieveFromCacheWithFieldSignatureAsFallback;
|
||||
extern const base::Feature kAutofillKeyboardAccessory;
|
||||
extern const base::Feature kAutofillLabelAffixRemoval;
|
||||
extern const base::Feature kAutofillPruneSuggestions;
|
||||
|
Reference in New Issue
Block a user