0

Add field type overrides for email or loyalty fields.

With this CL, EMAIL_OR_LOYALTY_MEMBERSHIP_ID will override server type
predictions for EMAIL_ADDRESS. The logic is guarded by the flag
AutofillEnableEmailOrLoyaltyCardsFilling.

Bug: 416664590
Change-Id: Ibbee07d1be5702ef28f97a6082a0eeadee0f628e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6563686
Reviewed-by: Jan Keitel <jkeitel@google.com>
Commit-Queue: Norge Vizcay <vizcay@google.com>
Cr-Commit-Position: refs/heads/main@{#1462585}
This commit is contained in:
Norge Vizcay
2025-05-19 23:15:43 -07:00
committed by Chromium LUCI CQ
parent 97b2452e33
commit a84af46251
2 changed files with 29 additions and 0 deletions
components/autofill/core/browser

@ -150,6 +150,13 @@ bool AreCollapsibleLogEvents(const AutofillField::FieldLogEventType& event1,
// want to prioritize local heuristics over the autocomplete type.
bool PreferHeuristicOverHtml(FieldType heuristic_type,
HtmlFieldType html_type) {
if (base::FeatureList::IsEnabled(
features::kAutofillEnableEmailOrLoyaltyCardsFilling) &&
heuristic_type == EMAIL_OR_LOYALTY_MEMBERSHIP_ID &&
html_type == HtmlFieldType::kEmail) {
return true;
}
return base::Contains(kAutofillHeuristicsVsHtmlOverrides,
std::make_pair(heuristic_type, html_type));
}
@ -161,6 +168,12 @@ bool PreferHeuristicOverHtml(FieldType heuristic_type,
// can help the server to "learn" the correct classification for these fields.
bool PreferHeuristicOverServer(FieldType heuristic_type,
FieldType server_type) {
if (base::FeatureList::IsEnabled(
features::kAutofillEnableEmailOrLoyaltyCardsFilling) &&
heuristic_type == EMAIL_OR_LOYALTY_MEMBERSHIP_ID &&
server_type == EMAIL_ADDRESS) {
return true;
}
// Until we gain confidence in the precision of AutofillAI predictions, they
// should not overrule local heuristics. The AutofillAI prediction itself can
// always be retrieved via `GetAutofillAiServerTypePredictions`.

@ -322,6 +322,10 @@ class AutofillLocalHeuristicsOverridesTest
: public testing::TestWithParam<AutofillLocalHeuristicsOverridesParams> {
public:
AutofillLocalHeuristicsOverridesTest() = default;
private:
base::test::ScopedFeatureList feature_{
features::kAutofillEnableEmailOrLoyaltyCardsFilling};
};
// Tests the correctness of local heuristic overrides while computing the
@ -418,6 +422,18 @@ INSTANTIATE_TEST_SUITE_P(
.heuristic_type = ADDRESS_HOME_OVERFLOW,
.expected_result = ADDRESS_HOME_OVERFLOW,
.expected_source = AutofillPredictionSource::kHeuristics},
AutofillLocalHeuristicsOverridesParams{
.html_field_type = HtmlFieldType::kUnrecognized,
.server_type = EMAIL_ADDRESS,
.heuristic_type = EMAIL_OR_LOYALTY_MEMBERSHIP_ID,
.expected_result = EMAIL_OR_LOYALTY_MEMBERSHIP_ID,
.expected_source = AutofillPredictionSource::kHeuristics},
AutofillLocalHeuristicsOverridesParams{
.html_field_type = HtmlFieldType::kEmail,
.server_type = NO_SERVER_DATA,
.heuristic_type = EMAIL_OR_LOYALTY_MEMBERSHIP_ID,
.expected_result = EMAIL_OR_LOYALTY_MEMBERSHIP_ID,
.expected_source = AutofillPredictionSource::kHeuristics},
// Test non-override behaviour.
AutofillLocalHeuristicsOverridesParams{
.html_field_type = HtmlFieldType::kStreetAddress,