Reland "[AutofillAi] Add known traveler number types" This reverts commit 2f4f8e2cd33383226a01c69c46ef6b7fa169c973. Reason for revert: Test fixed Bug: 429109329, 435488489 Original change's description: > Revert "[AutofillAi] Add known traveler number types" > > This reverts commit 704ce37417bc568f118e69184aad6f0b64dc0f49. > > Reason for revert: Causing test failures, see crbug.com/435488489. > > Bug: 429109329 > Original change's description: > > [AutofillAi] Add known traveler number types > > > > Bug: 429109329 > > Change-Id: Ie6934fe86575dcb545e1471c7fa72e5572bcb3b1 > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6798017 > > Auto-Submit: Bruno Braga <brunobraga@google.com> > > Reviewed-by: Jan Keitel <jkeitel@google.com> > > Reviewed-by: Tim <tjudkins@chromium.org> > > Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org> > > Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org> > > Cr-Commit-Position: refs/heads/main@{#1495014} > > Bug: 429109329, 435488489 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Change-Id: I58c693c12ea73b2c53891cef0f0ec3679d331b2d > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6807370 > Owners-Override: Adithya Srinivasan <adithyas@chromium.org> > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> > Commit-Queue: Adithya Srinivasan <adithyas@chromium.org> > Cr-Commit-Position: refs/heads/main@{#1495057} Bug: 429109329 Bug: 429109329, 435488489 Change-Id: I71d421810abe0f7a742e652c27cb0b4bec5feff2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6811574 Commit-Queue: Bruno Braga <brunobraga@google.com> Reviewed-by: Mike West <mkwst@chromium.org> Owners-Override: Mike West <mkwst@chromium.org> Reviewed-by: Jan Keitel <jkeitel@google.com> Cr-Commit-Position: refs/heads/main@{#1495401}
diff --git a/chrome/common/extensions/api/autofill_private.idl b/chrome/common/extensions/api/autofill_private.idl index 5e200638..3eaf103 100644 --- a/chrome/common/extensions/api/autofill_private.idl +++ b/chrome/common/extensions/api/autofill_private.idl
@@ -149,6 +149,8 @@ NATIONAL_ID_CARD_EXPIRATION_DATE, NATIONAL_ID_CARD_ISSUE_DATE, NATIONAL_ID_CARD_ISSUING_COUNTRY, + KNOWN_TRAVELER_NUMBER, + KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE, ADDRESS_HOME_ZIP_PREFIX, ADDRESS_HOME_ZIP_SUFFIX, MAX_VALID_FIELD_TYPE
diff --git a/components/autofill/core/browser/autofill_type_unittest.cc b/components/autofill/core/browser/autofill_type_unittest.cc index 58e7557..1b64d29 100644 --- a/components/autofill/core/browser/autofill_type_unittest.cc +++ b/components/autofill/core/browser/autofill_type_unittest.cc
@@ -342,12 +342,26 @@ ElementsAre(PASSPORT_NAME_TAG)); } + // Some types do not have an entity yet, this is an intermediate state + // between a type being added and the entity schema being updated. + constexpr FieldTypeSet kTemporaryTypesWithoutEntity = { + KNOWN_TRAVELER_NUMBER, KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE}; + for (FieldType field_type : kTemporaryTypesWithoutEntity) { + for (EntityType entity : DenseSet<EntityType>::all()) { + AutofillType autofill_type = AutofillType(field_type); + ASSERT_EQ(autofill_type.GetAutofillAiType(entity), UNKNOWN_TYPE); + } + } + { // Test that GetAutofillAiTypes() is the union of GetAutofillAiType(). FieldTypeSet hit1; FieldTypeSet hit2; for (EntityType entity : DenseSet<EntityType>::all()) { for (FieldType field_type : kAllFieldTypes) { + if (kTemporaryTypesWithoutEntity.contains(field_type)) { + continue; + } AutofillType type = AutofillType(field_type); if (type.GetAutofillAiType(entity) != UNKNOWN_TYPE) { hit1.insert(field_type); @@ -366,6 +380,9 @@ FieldTypeSet hit2; for (EntityType entity : DenseSet<EntityType>::all()) { for (FieldType field_type : kAllFieldTypes) { + if (kTemporaryTypesWithoutEntity.contains(field_type)) { + continue; + } AutofillType type = AutofillType(field_type); if (type.GetAutofillAiType(entity) != UNKNOWN_TYPE) { hit1.insert(field_type); @@ -518,6 +535,18 @@ {DRIVERS_LICENSE_NAME_TAG, PASSPORT_NAME_TAG, VEHICLE_OWNER_TAG}); } + // Some types do not have an entity yet, this is an intermediate state + // between a type being added and the entity schema being updated. + constexpr FieldTypeSet kTemporaryTypesWithoutEntity = { + KNOWN_TRAVELER_NUMBER, KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE}; + for (FieldType field_type : kTemporaryTypesWithoutEntity) { + for (EntityType entity : DenseSet<EntityType>::all()) { + AutofillType autofill_type = AutofillType(field_type); + ASSERT_EQ(autofill_type.GetAutofillAiType(entity), UNKNOWN_TYPE); + } + } + + kNotCovered.insert_all(kTemporaryTypesWithoutEntity); for (FieldType field_type : kAllFieldTypes) { SCOPED_TRACE(testing::Message() << "field_type=" << FieldTypeToStringView(field_type));
diff --git a/components/autofill/core/browser/data_model/addresses/autofill_i18n_api.cc b/components/autofill/core/browser/data_model/addresses/autofill_i18n_api.cc index b92ec198..8f3d906 100644 --- a/components/autofill/core/browser/data_model/addresses/autofill_i18n_api.cc +++ b/components/autofill/core/browser/data_model/addresses/autofill_i18n_api.cc
@@ -245,6 +245,8 @@ case NATIONAL_ID_CARD_EXPIRATION_DATE: case NATIONAL_ID_CARD_ISSUE_DATE: case NATIONAL_ID_CARD_ISSUING_COUNTRY: + case KNOWN_TRAVELER_NUMBER: + case KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE: case MAX_VALID_FIELD_TYPE: return nullptr; }
diff --git a/components/autofill/core/browser/data_model/addresses/autofill_profile.cc b/components/autofill/core/browser/data_model/addresses/autofill_profile.cc index ced0210..1365952 100644 --- a/components/autofill/core/browser/data_model/addresses/autofill_profile.cc +++ b/components/autofill/core/browser/data_model/addresses/autofill_profile.cc
@@ -551,7 +551,7 @@ // When adding field types, ensure that they don't need to be added here and // update the last checked value. - static_assert(FieldType::MAX_VALID_FIELD_TYPE == 203, + static_assert(FieldType::MAX_VALID_FIELD_TYPE == 204, "New field type needs to be reviewed for inclusion in the " "profile comparison logic.");
diff --git a/components/autofill/core/browser/field_type_utils.cc b/components/autofill/core/browser/field_type_utils.cc index faa8f9d9..20c7c11 100644 --- a/components/autofill/core/browser/field_type_utils.cc +++ b/components/autofill/core/browser/field_type_utils.cc
@@ -188,6 +188,8 @@ case NATIONAL_ID_CARD_EXPIRATION_DATE: case NATIONAL_ID_CARD_ISSUE_DATE: case NATIONAL_ID_CARD_ISSUING_COUNTRY: + case KNOWN_TRAVELER_NUMBER: + case KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE: case MAX_VALID_FIELD_TYPE: return false; } @@ -313,6 +315,8 @@ case DRIVERS_LICENSE_NUMBER: case NATIONAL_ID_CARD_NUMBER: case NATIONAL_ID_CARD_ISSUING_COUNTRY: + case KNOWN_TRAVELER_NUMBER: + case KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE: case MAX_VALID_FIELD_TYPE: return false; case CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR: @@ -449,6 +453,8 @@ case NATIONAL_ID_CARD_EXPIRATION_DATE: case NATIONAL_ID_CARD_ISSUE_DATE: case NATIONAL_ID_CARD_ISSUING_COUNTRY: + case KNOWN_TRAVELER_NUMBER: + case KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE: case ADDRESS_HOME_ZIP_PREFIX: case ADDRESS_HOME_ZIP_SUFFIX: case MAX_VALID_FIELD_TYPE:
diff --git a/components/autofill/core/browser/field_types.cc b/components/autofill/core/browser/field_types.cc index b7468bf6..dbcbd8c 100644 --- a/components/autofill/core/browser/field_types.cc +++ b/components/autofill/core/browser/field_types.cc
@@ -173,6 +173,9 @@ {"NATIONAL_ID_CARD_EXPIRATION_DATE", NATIONAL_ID_CARD_EXPIRATION_DATE}, {"NATIONAL_ID_CARD_ISSUE_DATE", NATIONAL_ID_CARD_ISSUE_DATE}, {"NATIONAL_ID_CARD_ISSUING_COUNTRY", NATIONAL_ID_CARD_ISSUING_COUNTRY}, + {"KNOWN_TRAVELER_NUMBER", KNOWN_TRAVELER_NUMBER}, + {"KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE", + KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE}, {"EMAIL_OR_LOYALTY_MEMBERSHIP_ID", EMAIL_OR_LOYALTY_MEMBERSHIP_ID}}); bool IsFillableFieldType(FieldType field_type) { @@ -301,6 +304,8 @@ case NATIONAL_ID_CARD_EXPIRATION_DATE: case NATIONAL_ID_CARD_ISSUE_DATE: case NATIONAL_ID_CARD_ISSUING_COUNTRY: + case KNOWN_TRAVELER_NUMBER: + case KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE: return true; // Not fillable credential fields. @@ -398,6 +403,8 @@ case NATIONAL_ID_CARD_EXPIRATION_DATE: case NATIONAL_ID_CARD_ISSUE_DATE: case NATIONAL_ID_CARD_ISSUING_COUNTRY: + case KNOWN_TRAVELER_NUMBER: + case KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE: return ""; case NUMERIC_QUANTITY: return "Numeric quantity";
diff --git a/components/autofill/core/browser/field_types.h b/components/autofill/core/browser/field_types.h index 332ae7e05..ed4591e4 100644 --- a/components/autofill/core/browser/field_types.h +++ b/components/autofill/core/browser/field_types.h
@@ -524,7 +524,12 @@ NATIONAL_ID_CARD_ISSUE_DATE = 192, NATIONAL_ID_CARD_ISSUING_COUNTRY = 193, - // Types 194 to 200 are not used on the client yet, but will likely be added + // Types corresponding to the "Known traveler" entity from + // components/autofill/core/browser/data_model/autofill_ai/entity_schema.json. + KNOWN_TRAVELER_NUMBER = 194, + KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE = 203, + + // Types 195 to 200 are not used on the client yet, but will likely be added // in the future. // ADDRESS_HOME_ZIP = ADDRESS_HOME_ZIP_PREFIX + separator + @@ -543,7 +548,7 @@ // If the newly added type is a storable type of AutofillProfile, update // AutofillProfile.StorableTypes in // tools/metrics/histograms/metadata/autofill/histograms.xml. - MAX_VALID_FIELD_TYPE = 203, + MAX_VALID_FIELD_TYPE = 204, }; // LINT.ThenChange(//chrome/common/extensions/api/autofill_private.idl) @@ -652,7 +657,7 @@ (187 <= t && t <= 188) || // Types for date of birth, gender, and flight reservation are not // used yet, but will likely be added in the future. - (194 <= t && t <= 200); + (195 <= t && t <= 200); }; return is_invalid(raw_value) ? fallback_value : static_cast<FieldType>(raw_value); // nocheck @@ -815,6 +820,8 @@ case NATIONAL_ID_CARD_ISSUE_DATE: case NATIONAL_ID_CARD_EXPIRATION_DATE: case NATIONAL_ID_CARD_ISSUING_COUNTRY: + case KNOWN_TRAVELER_NUMBER: + case KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE: return FieldTypeGroup::kAutofillAi; case PASSWORD:
diff --git a/components/autofill/core/browser/field_types_unittest.cc b/components/autofill/core/browser/field_types_unittest.cc index 9f2ce86..fd1e594 100644 --- a/components/autofill/core/browser/field_types_unittest.cc +++ b/components/autofill/core/browser/field_types_unittest.cc
@@ -147,6 +147,8 @@ NATIONAL_ID_CARD_EXPIRATION_DATE, NATIONAL_ID_CARD_ISSUE_DATE, NATIONAL_ID_CARD_ISSUING_COUNTRY, + KNOWN_TRAVELER_NUMBER, + KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE, ADDRESS_HOME_ZIP_PREFIX, ADDRESS_HOME_ZIP_SUFFIX, };
diff --git a/components/autofill/core/browser/form_parsing/address_field_parser_ng.cc b/components/autofill/core/browser/form_parsing/address_field_parser_ng.cc index 9856299..ea820135 100644 --- a/components/autofill/core/browser/form_parsing/address_field_parser_ng.cc +++ b/components/autofill/core/browser/form_parsing/address_field_parser_ng.cc
@@ -691,6 +691,8 @@ case NATIONAL_ID_CARD_EXPIRATION_DATE: case NATIONAL_ID_CARD_ISSUE_DATE: case NATIONAL_ID_CARD_ISSUING_COUNTRY: + case KNOWN_TRAVELER_NUMBER: + case KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE: case ADDRESS_HOME_ZIP_PREFIX: case ADDRESS_HOME_ZIP_SUFFIX: case MAX_VALID_FIELD_TYPE:
diff --git a/components/autofill/core/browser/metrics/prediction_quality_metrics.cc b/components/autofill/core/browser/metrics/prediction_quality_metrics.cc index dfba60e..cad7463d 100644 --- a/components/autofill/core/browser/metrics/prediction_quality_metrics.cc +++ b/components/autofill/core/browser/metrics/prediction_quality_metrics.cc
@@ -420,6 +420,8 @@ case NATIONAL_ID_CARD_EXPIRATION_DATE: case NATIONAL_ID_CARD_ISSUE_DATE: case NATIONAL_ID_CARD_ISSUING_COUNTRY: + case KNOWN_TRAVELER_NUMBER: + case KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE: NOTREACHED() << field_type << " type is not in that group."; } break;
diff --git a/components/autofill/core/browser/ui/addresses/autofill_address_util.cc b/components/autofill/core/browser/ui/addresses/autofill_address_util.cc index b9284db5..64d1feb 100644 --- a/components/autofill/core/browser/ui/addresses/autofill_address_util.cc +++ b/components/autofill/core/browser/ui/addresses/autofill_address_util.cc
@@ -429,6 +429,8 @@ case NATIONAL_ID_CARD_EXPIRATION_DATE: case NATIONAL_ID_CARD_ISSUE_DATE: case NATIONAL_ID_CARD_ISSUING_COUNTRY: + case KNOWN_TRAVELER_NUMBER: + case KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE: case MAX_VALID_FIELD_TYPE: case DELIVERY_INSTRUCTIONS: case ADDRESS_HOME_SUBPREMISE:
diff --git a/components/autofill/core/browser/webdata/addresses/autofill_profile_sync_util.cc b/components/autofill/core/browser/webdata/addresses/autofill_profile_sync_util.cc index 9ffa2900..2f06dd1d 100644 --- a/components/autofill/core/browser/webdata/addresses/autofill_profile_sync_util.cc +++ b/components/autofill/core/browser/webdata/addresses/autofill_profile_sync_util.cc
@@ -669,7 +669,7 @@ // When adding field types, ensure that they don't need to be added here and // update the last checked value. // TODO(crbug.com/359768803): Handle alternative names here. - static_assert(FieldType::MAX_VALID_FIELD_TYPE == 203, + static_assert(FieldType::MAX_VALID_FIELD_TYPE == 204, "New field type needs to be reviewed for inclusion in sync"); // The profile may be in a legacy state. By calling |FinalizeAfterImport()|
diff --git a/tools/metrics/histograms/metadata/autofill/enums.xml b/tools/metrics/histograms/metadata/autofill/enums.xml index a4d488f7..909c910 100644 --- a/tools/metrics/histograms/metadata/autofill/enums.xml +++ b/tools/metrics/histograms/metadata/autofill/enums.xml
@@ -903,6 +903,9 @@ value edited"/> <int value="12353" label="NATIONAL_ID_CARD_ISSUING_COUNTRY: Autofilled value accepted"/> + <int value="12416" + label="KNOWN_TRAVELER_NUMBER: Not autofilled or autofilled value edited"/> + <int value="12417" label="KNOWN_TRAVELER_NUMBER: Autofilled value accepted"/> <int value="12864" label="ADDRESS_HOME_ZIP_PREFIX: Not autofilled or autofilled value edited"/> @@ -913,6 +916,11 @@ edited"/> <int value="12929" label="ADDRESS_HOME_ZIP_SUFFIX: Autofilled value accepted"/> + <int value="12992" + label="KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE: Not autofilled or + autofilled value edited"/> + <int value="12993" + label="KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE: Autofilled value accepted"/> </enum> <enum name="AutofillDeveloperEngagement"> @@ -1230,10 +1238,14 @@ <int value="3073" label="NATIONAL_ID_CARD_ISSUE_DATE: accepted"/> <int value="3088" label="NATIONAL_ID_CARD_ISSUING_COUNTRY: edited"/> <int value="3089" label="NATIONAL_ID_CARD_ISSUING_COUNTRY: accepted"/> + <int value="3104" label="KNOWN_TRAVELER_NUMBER: edited"/> + <int value="3105" label="KNOWN_TRAVELER_NUMBER: accepted"/> <int value="3216" label="ADDRESS_HOME_ZIP_PREFIX: edited"/> <int value="3217" label="ADDRESS_HOME_ZIP_PREFIX: accepted"/> <int value="3232" label="ADDRESS_HOME_ZIP_SUFFIX: edited"/> <int value="3233" label="ADDRESS_HOME_ZIP_SUFFIX: accepted"/> + <int value="3248" label="KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE: edited"/> + <int value="3249" label="KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE: accepted"/> </enum> <enum name="AutofillEmailOrLoyaltyCardAcceptanceMetricValue"> @@ -2096,8 +2108,10 @@ <int value="191" label="NATIONAL_ID_CARD_EXPIRATION_DATE"/> <int value="192" label="NATIONAL_ID_CARD_ISSUE_DATE"/> <int value="193" label="NATIONAL_ID_CARD_ISSUING_COUNTRY"/> + <int value="194" label="KNOWN_TRAVELER_NUMBER"/> <int value="201" label="ADDRESS_HOME_ZIP_PREFIX"/> <int value="202" label="ADDRESS_HOME_ZIP_SUFFIX"/> + <int value="203" label="KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE"/> </enum> <enum name="AutofillFilledCardInformationBubbleFieldClicked"> @@ -3761,10 +3775,14 @@ <int value="769" label="NATIONAL_ID_CARD_ISSUE_DATE: Accepted"/> <int value="772" label="NATIONAL_ID_CARD_ISSUING_COUNTRY: Ignored"/> <int value="773" label="NATIONAL_ID_CARD_ISSUING_COUNTRY: Accepted"/> + <int value="776" label="KNOWN_TRAVELER_NUMBER: Ignored"/> + <int value="777" label="KNOWN_TRAVELER_NUMBER: Accepted"/> <int value="804" label="ADDRESS_HOME_ZIP_PREFIX: Ignored"/> <int value="805" label="ADDRESS_HOME_ZIP_PREFIX: Accepted"/> <int value="808" label="ADDRESS_HOME_ZIP_SUFFIX: Ignored"/> <int value="809" label="ADDRESS_HOME_ZIP_SUFFIX: Accepted"/> + <int value="812" label="KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE: Ignored"/> + <int value="813" label="KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE: Accepted"/> </enum> <!-- LINT.IfChange(FormSubmissionOutcomeIOS) -->
diff --git a/tools/metrics/histograms/metadata/autofill/histograms.xml b/tools/metrics/histograms/metadata/autofill/histograms.xml index 1fcf60b..1c3e8a7b 100644 --- a/tools/metrics/histograms/metadata/autofill/histograms.xml +++ b/tools/metrics/histograms/metadata/autofill/histograms.xml
@@ -490,6 +490,8 @@ <variant name="EMAIL_OR_LOYALTY_MEMBERSHIP_ID"/> <variant name="EMPTY_TYPE"/> <variant name="IBAN_VALUE"/> + <variant name="KNOWN_TRAVELER_NUMBER"/> + <variant name="KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE"/> <variant name="LOYALTY_MEMBERSHIP_ID"/> <variant name="LOYALTY_MEMBERSHIP_PROGRAM"/> <variant name="LOYALTY_MEMBERSHIP_PROVIDER"/>
diff --git a/tools/typescript/definitions/autofill_private.d.ts b/tools/typescript/definitions/autofill_private.d.ts index cc782f46..22f207db 100644 --- a/tools/typescript/definitions/autofill_private.d.ts +++ b/tools/typescript/definitions/autofill_private.d.ts
@@ -145,6 +145,8 @@ NATIONAL_ID_CARD_EXPIRATION_DATE, NATIONAL_ID_CARD_ISSUE_DATE, NATIONAL_ID_CARD_ISSUING_COUNTRY, + KNOWN_TRAVELER_NUMBER, + KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE, ADDRESS_HOME_ZIP_PREFIX, ADDRESS_HOME_ZIP_SUFFIX, }