Commit 45a84cd2 authored by Matthias Körber's avatar Matthias Körber Committed by Commit Bot

[Autofill] Enable retrieve from cache with field signatures by default

Change-Id: I59f544e93fa573d3a5ab9b7b43c3b9b51e1c4550
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2526062
Commit-Queue: Matthias Körber <koerber@google.com>
Reviewed-by: default avatarChristoph Schwering <schwering@google.com>
Cr-Commit-Position: refs/heads/master@{#826870}
parent bcfea980
......@@ -94,6 +94,7 @@ FormData GetFormData(const TestFormAttributes& test_form_attributes) {
form_data.url = GURL(test_form_attributes.url);
form_data.action = GURL(test_form_attributes.action);
form_data.name = ASCIIToUTF16(test_form_attributes.name);
static int field_count = 0;
if (test_form_attributes.unique_renderer_id)
form_data.unique_renderer_id = *test_form_attributes.unique_renderer_id;
if (test_form_attributes.main_frame_origin)
......@@ -113,6 +114,7 @@ FormData GetFormData(const TestFormAttributes& test_form_attributes) {
field.value = ASCIIToUTF16(*field_description.value);
if (field_description.is_autofilled)
field.is_autofilled = *field_description.is_autofilled;
field.unique_renderer_id = FieldRendererId(field_count++);
field.should_autocomplete = field_description.should_autocomplete;
form_data.fields.push_back(field);
}
......
......@@ -1062,29 +1062,16 @@ void FormStructure::RetrieveFromCache(
const FormStructure& cached_form,
const bool should_keep_cached_value,
const bool only_server_and_autofill_state) {
// TODO(crbug/1101631) Clean up once the experiment is over.
const bool kUseRendererIds = base::FeatureList::IsEnabled(
features::kAutofillRetrieveFromCacheWithRendererIds);
std::map<base::string16, const AutofillField*> cached_fields_by_name;
std::map<FieldRendererId, const AutofillField*> cached_fields_by_id;
for (size_t i = 0; i < cached_form.field_count(); ++i) {
auto* const field = cached_form.field(i);
if (kUseRendererIds)
cached_fields_by_id[field->unique_renderer_id] = field;
else
cached_fields_by_name[field->unique_name()] = field;
cached_fields_by_id[field->unique_renderer_id] = field;
}
for (auto& field : *this) {
const AutofillField* cached_field = nullptr;
if (kUseRendererIds) {
const auto& it = cached_fields_by_id.find(field->unique_renderer_id);
if (it != cached_fields_by_id.end())
cached_field = it->second;
} else {
const auto& it = cached_fields_by_name.find(field->unique_name());
if (it != cached_fields_by_name.end())
cached_field = it->second;
}
const auto& it = cached_fields_by_id.find(field->unique_renderer_id);
if (it != cached_fields_by_id.end())
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
......
......@@ -145,12 +145,6 @@ const base::Feature kAutofillRefillWithRendererIds{
const base::Feature kAutofillNameSectionsWithRendererIds{
"AutofillNameSectionsWithRendererIds", base::FEATURE_DISABLED_BY_DEFAULT};
// When enabled, Autofill will use FieldRendererIds instead of unique_names
// to align forms in FormStructure::RetrieveFromCache().
const base::Feature kAutofillRetrieveFromCacheWithRendererIds{
"AutofillRetrieveFromCacheWithRendererIds",
base::FEATURE_DISABLED_BY_DEFAULT};
// When enabled, autofill suggestions are displayed in the keyboard accessory
// instead of the regular popup.
const base::Feature kAutofillKeyboardAccessory{
......
......@@ -42,7 +42,6 @@ extern const base::Feature kAutofillEnableUIForHonorificPrefixesInSettings;
extern const base::Feature kAutofillExtractAllDatalists;
extern const base::Feature kAutofillFixFillableFieldTypes;
extern const base::Feature kAutofillRefillWithRendererIds;
extern const base::Feature kAutofillRetrieveFromCacheWithRendererIds;
extern const base::Feature kAutofillNameSectionsWithRendererIds;
extern const base::Feature kAutofillKeyboardAccessory;
extern const base::Feature kAutofillLabelAffixRemoval;
......
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