Skip to content

Commit

Permalink
Reporting |user_typed_into_field| no matter whether users type or not
Browse files Browse the repository at this point in the history
This CL does three things:
1. We report |user_typed_into_field| no matter whether  users type or
not.
2. Add a test case that a field is not autofilled and not typed by
users.
3. Add values to enum types of HtmlFieldMode and HtmlFieldType to match
with tools/metrics/histograms/enums.xml

(cherry picked from commit 9ddc05e)

Bug: 1325851,1410898
Change-Id: Ibc985aa7eb2d70855e26734b7678d99b89d73c4a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4204855
Commit-Queue: Lan Wei <lanwei@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1099232}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4213933
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Auto-Submit: Lan Wei <lanwei@chromium.org>
Reviewed-by: Lan Wei <lanwei@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/branch-heads/5563@{#95}
Cr-Branched-From: 3ac59a6-refs/heads/main@{#1097615}
  • Loading branch information
LanWei22 authored and Chromium LUCI CQ committed Feb 1, 2023
1 parent 51496a1 commit c1e7c21
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 72 deletions.
13 changes: 6 additions & 7 deletions components/autofill/core/browser/metrics/autofill_metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2562,7 +2562,8 @@ void AutofillMetrics::FormInteractionsUkmLogger::
suggestion_was_shown |= event->suggestion_is_shown;
if (suggestion_was_shown == OptionalBoolean::kTrue &&
suggestion_was_accepted == OptionalBoolean::kUndefined) {
// Only switch from unknown to false on the first suggestion.
// Initialize suggestion_was_accepted to a defined value when the first
// time the suggestion is shown.
suggestion_was_accepted = OptionalBoolean::kFalse;
}
}
Expand All @@ -2578,7 +2579,8 @@ void AutofillMetrics::FormInteractionsUkmLogger::
had_value_after_filling = event->had_value_after_filling;
if (was_autofilled == OptionalBoolean::kTrue &&
filled_value_was_modified == OptionalBoolean::kUndefined) {
// Only switch from unknown to false on the first filling.
// Initialize filled_value_was_modified to a defined value when the
// field is filled for the first time.
filled_value_was_modified = OptionalBoolean::kFalse;
}
++autofill_count;
Expand Down Expand Up @@ -2658,7 +2660,8 @@ void AutofillMetrics::FormInteractionsUkmLogger::
AutofillMetrics::FieldGlobalIdToHash64Bit(field.global_id()))
.SetFieldSignature(HashFieldSignature(field.GetFieldSignature()))
.SetWasFocused(OptionalBooleanToBool(was_focused))
.SetIsFocusable(field.IsFocusable());
.SetIsFocusable(field.IsFocusable())
.SetUserTypedIntoField(OptionalBooleanToBool(user_typed_into_field));

if (was_focused == OptionalBoolean::kTrue) {
builder
Expand All @@ -2680,10 +2683,6 @@ void AutofillMetrics::FormInteractionsUkmLogger::
.SetWasRefill(autofill_count > 1);
}

if (user_typed_into_field == OptionalBoolean::kTrue) {
builder.SetUserTypedIntoField(OptionalBooleanToBool(user_typed_into_field));
}

if (filled_value_was_modified != OptionalBoolean::kUndefined) {
builder.SetFilledValueWasModified(
OptionalBooleanToBool(filled_value_was_modified));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10391,10 +10391,11 @@ TEST_F(AutofillMetricsFromLogEventsTest, AddressSubmittedFormLogEvents) {
// Create a profile.
RecreateProfile(/*is_server=*/false);
FormData form = CreateForm({CreateField("State", "state", "", "text"),
CreateField("Street", "street", "", "text")});
CreateField("Street", "street", "", "text"),
CreateField("Number", "", "", "text")});

std::vector<ServerFieldType> field_types = {ADDRESS_HOME_STATE,
ADDRESS_HOME_STREET_ADDRESS};
std::vector<ServerFieldType> field_types = {
ADDRESS_HOME_STATE, ADDRESS_HOME_STREET_ADDRESS, NO_SERVER_DATA};

autofill_manager().AddSeenForm(form, field_types);

Expand All @@ -10413,7 +10414,8 @@ TEST_F(AutofillMetricsFromLogEventsTest, AddressSubmittedFormLogEvents) {
autofill_manager().AddSeenForm(form, field_types);

{
// Simulating submission with filled local data.
// Simulating submission with filled local data. The third field cannot be
// autofilled because its type cannot be predicated.
autofill_manager().OnAskForValuesToFillTest(
form, form.fields[0], gfx::RectF(), AutoselectFirstSuggestion(false),
FormElementWasClicked(true));
Expand All @@ -10428,13 +10430,15 @@ TEST_F(AutofillMetricsFromLogEventsTest, AddressSubmittedFormLogEvents) {

entries =
test_ukm_recorder_->GetEntriesByName(UkmFieldInfoType::kEntryName);
ASSERT_EQ(2u, entries.size());
ASSERT_EQ(3u, entries.size());

for (size_t i = 0; i < entries.size(); ++i) {
SCOPED_TRACE(testing::Message() << i);
using UFIT = UkmFieldInfoType;
const auto* const entry = entries[i];

SkipStatus status =
i == 2 ? SkipStatus::kNoFillableGroup : SkipStatus::kNotSkipped;
std::map<std::string, int64_t> expected = {
{UFIT::kFormSessionIdentifierName,
AutofillMetrics::FormGlobalIdToHash64Bit(form.global_id())},
Expand All @@ -10445,20 +10449,21 @@ TEST_F(AutofillMetricsFromLogEventsTest, AddressSubmittedFormLogEvents) {
Collapse(CalculateFieldSignatureForField(form.fields[i])).value()},
{UFIT::kWasFocusedName, i == 0},
{UFIT::kIsFocusableName, true},
{UFIT::kWasAutofilledName, true},
{UFIT::kWasAutofilledName, i != 2},
{UFIT::kAutofillSkippedStatusName,
DenseSet<SkipStatus>{SkipStatus::kNotSkipped}.to_uint64()},
DenseSet<SkipStatus>{status}.to_uint64()},
{UFIT::kWasRefillName, false},
{UFIT::kHadValueBeforeFillingName, false},
{UFIT::kFilledValueWasModifiedName, false},
{UFIT::kHadTypedOrFilledValueAtSubmissionName, true},
{UFIT::kUserTypedIntoFieldName, i == 0},
{UFIT::kHadTypedOrFilledValueAtSubmissionName, i != 2},
};
if (i == 0) {
expected[UFIT::kSuggestionWasAvailableName] = true;
expected[UFIT::kSuggestionWasShownName] = true;
expected[UFIT::kSuggestionWasAcceptedName] = true;
expected[UFIT::kUserTypedIntoFieldName] = true;
expected[UFIT::kFilledValueWasModifiedName] = true;
}
if (i != 2) {
expected[UFIT::kFilledValueWasModifiedName] = i == 0;
}

EXPECT_EQ(expected.size(), entry->metrics.size());
Expand Down Expand Up @@ -10552,6 +10557,7 @@ TEST_F(AutofillMetricsFromLogEventsTest, AutofillFieldInfoMetricsFieldType) {
{UFIT::kIsFocusableName, true},
{UFIT::kRankInFieldSignatureGroupName, 1},
{UFIT::kWasFocusedName, false},
{UFIT::kUserTypedIntoFieldName, false},
};
if (heuristic_types[i] != UNKNOWN_TYPE) {
expected.merge(std::map<std::string, int64_t>({
Expand Down
108 changes: 54 additions & 54 deletions components/autofill/core/common/mojom/autofill_types.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -14,95 +14,95 @@ import "url/mojom/url.mojom";
// The list of all HTML autocomplete field mode hints supported by Chrome.
// See [ http://is.gd/whatwg_autocomplete ] for the full list of specced hints.
enum HtmlFieldMode {
kNone,
kBilling,
kShipping,
kNone = 0,
kBilling = 1,
kShipping = 2,
};

// The list of all HTML autocomplete field type hints supported by Chrome.
// See [ http://is.gd/whatwg_autocomplete ] for the full list of specced hints.
enum HtmlFieldType {
// Default type.
kUnspecified,
kUnspecified = 0,

// Name types.
kName,
kHonorificPrefix,
kGivenName,
kAdditionalName,
kFamilyName,
kName = 1,
kHonorificPrefix = 2,
kGivenName = 3,
kAdditionalName = 4,
kFamilyName = 5,

// Business types.
kOrganization,
kOrganization = 6,

// Address types.
kStreetAddress,
kAddressLine1,
kAddressLine2,
kAddressLine3,
kAddressLevel1, // For U.S. addresses, corresponds to the state.
kAddressLevel2, // For U.S. addresses, corresponds to the city.
kAddressLevel3, // An area that is more specific than LEVEL2.
kCountryCode, // The ISO 3166-1-alpha-2 country code.
kCountryName, // The localized country name.
kPostalCode,
kFullAddress, // The complete address, formatted for display.
kStreetAddress = 7,
kAddressLine1 = 8,
kAddressLine2 = 9,
kAddressLine3 = 10,
kAddressLevel1 = 11, // For U.S. addresses, corresponds to the state.
kAddressLevel2 = 12, // For U.S. addresses, corresponds to the city.
kAddressLevel3 = 13, // An area that is more specific than LEVEL2.
kCountryCode = 14, // The ISO 3166-1-alpha-2 country code.
kCountryName = 15, // The localized country name.
kPostalCode = 16,
kFullAddress = 17, // The complete address, formatted for display.

// Credit card types.
kCreditCardNameFull,
kCreditCardNameFirst,
kCreditCardNameLast,
kCreditCardNumber,
kCreditCardExp,
kCreditCardExpMonth,
kCreditCardExpYear,
kCreditCardVerificationCode,
kCreditCardType,
kCreditCardNameFull = 18,
kCreditCardNameFirst = 19,
kCreditCardNameLast = 20,
kCreditCardNumber = 21,
kCreditCardExp = 22,
kCreditCardExpMonth = 23,
kCreditCardExpYear = 24,
kCreditCardVerificationCode = 25,
kCreditCardType = 26,

// Phone number types.
kTel,
kTelCountryCode,
kTelNational,
kTelAreaCode,
kTelLocal,
kTelLocalPrefix,
kTelLocalSuffix,
kTelExtension,
kTel = 27,
kTelCountryCode = 28,
kTelNational = 29,
kTelAreaCode = 30,
kTelLocal = 31,
kTelLocalPrefix = 32,
kTelLocalSuffix = 33,
kTelExtension = 34,

// Email.
kEmail,
kEmail = 35,

// Birthdate.
kBirthdateDay,
kBirthdateMonth,
kBirthdateYear,
kBirthdateDay = 36,
kBirthdateMonth = 37,
kBirthdateYear = 38,

// Transaction details.
kTransactionAmount,
kTransactionCurrency,
kTransactionAmount = 39,
kTransactionCurrency = 40,

// Variants of type hints specified in the HTML specification that are
// inferred based on a field's 'maxlength' attribute.
kAdditionalNameInitial,
kCreditCardExpDate2DigitYear,
kCreditCardExpDate4DigitYear,
kCreditCardExp2DigitYear,
kCreditCardExp4DigitYear,
kAdditionalNameInitial = 41,
kCreditCardExpDate2DigitYear = 42,
kCreditCardExpDate4DigitYear = 43,
kCreditCardExp2DigitYear = 44,
kCreditCardExp4DigitYear = 45,

// Universal Payment Interface - Virtual Payment Address.
kUpiVpa,
kUpiVpa = 46,

// Phone number verification one-time-codes.
kOneTimeCode,
kOneTimeCode = 47,

// Promo code for merchant sites.
kMerchantPromoCode,
kMerchantPromoCode = 48,

// International Bank Account Number (IBAN) for banking and merchant sites.
kIban,
kIban = 49,

// Non-standard autocomplete types.
kUnrecognized,
kUnrecognized = 50,
};

// Events observed by the Password Manager that indicate either that a form is
Expand Down

0 comments on commit c1e7c21

Please sign in to comment.