// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module autofill.mojom;
import "mojo/public/mojom/base/text_direction.mojom";
import "mojo/public/mojom/base/time.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "url/mojom/url.mojom";
// The form control types supported by Autofill: a subset of
// blink::mojom::FormControlType plus kContentEditable.
// Do not modify the integer values because they are used UKM metrics.
enum FormControlType {
kContentEditable = 0,
kInputCheckbox = 1,
kInputEmail = 2,
kInputMonth = 3,
kInputNumber = 4,
kInputPassword = 5,
kInputRadio = 6,
kInputSearch = 7,
kInputTelephone = 8,
kInputText = 9,
kInputUrl = 10,
kSelectOne = 11,
kSelectMultiple = 12,
kSelectList = 13,
kTextArea = 14,
};
// 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 = 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 = 0,
// Name types.
kName = 1,
kHonorificPrefix = 2,
kGivenName = 3,
kAdditionalName = 4,
kFamilyName = 5,
// Business types.
kOrganization = 6,
// Address types.
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 is deprecated.
// Credit card types.
kCreditCardNameFull = 18,
kCreditCardNameFirst = 19,
kCreditCardNameLast = 20,
kCreditCardNumber = 21,
kCreditCardExp = 22,
kCreditCardExpMonth = 23,
kCreditCardExpYear = 24,
kCreditCardVerificationCode = 25,
kCreditCardType = 26,
// Phone number types.
kTel = 27,
kTelCountryCode = 28,
kTelNational = 29,
kTelAreaCode = 30,
kTelLocal = 31,
kTelLocalPrefix = 32,
kTelLocalSuffix = 33,
kTelExtension = 34,
// Email.
kEmail = 35,
// Birthdate.
kBirthdateDay = 36,
kBirthdateMonth = 37,
kBirthdateYear = 38,
// Transaction details.
kTransactionAmount = 39,
kTransactionCurrency = 40,
// Variants of type hints specified in the HTML specification that are
// inferred based on a field's 'maxlength' attribute.
kAdditionalNameInitial = 41,
kCreditCardExpDate2DigitYear = 42,
kCreditCardExpDate4DigitYear = 43,
kCreditCardExp2DigitYear = 44,
kCreditCardExp4DigitYear = 45,
// kUpiVpa = 46 is deprecated.
// Phone number verification one-time-codes.
kOneTimeCode = 47,
// Promo code for merchant sites.
kMerchantPromoCode = 48,
// International Bank Account Number (IBAN) for banking and merchant sites.
kIban = 49,
// Non-standard autocomplete types.
kUnrecognized = 50,
};
// Events observed by the Password Manager that indicate either that a form is
// potentially being submitted, or that a form has already been successfully
// submitted. Recorded into a UMA histogram, so order of enumerators should
// not be changed.
enum SubmissionIndicatorEvent {
NONE = 0,
HTML_FORM_SUBMISSION = 1,
SAME_DOCUMENT_NAVIGATION = 2,
XHR_SUCCEEDED = 3,
FRAME_DETACHED = 4,
// DEPRECATED_MANUAL_SAVE,
// DEPRECATED_DOM_MUTATION_AFTER_XHR = 6,
// DEPRECATED_PROVISIONALLY_SAVED_FORM_ON_START_PROVISIONAL_LOAD,
// DEPRECATED_FILLED_FORM_ON_START_PROVISIONAL_LOAD,
// DEPRECATED_FILLED_INPUT_ELEMENTS_ON_START_PROVISIONAL_LOAD,
PROBABLE_FORM_SUBMISSION = 10,
CHANGE_PASSWORD_FORM_CLEARED = 11,
DOM_MUTATION_AFTER_AUTOFILL = 12,
};
// These values are persisted to UMA logs. Entries should not be renumbered
// and numeric values should never be reused. This indicates the source of
// a submission firing event.
enum SubmissionSource {
// No submission signal was detected.
NONE = 0,
// After a same document navigation finished, the last interacted form became
// inaccessible or was removed.
SAME_DOCUMENT_NAVIGATION = 1,
// Immediately after a successful XHR, the last interacted form became
// inaccessible or was removed.
XHR_SUCCEEDED = 2,
// The subframe or non-primary main frame containing the form was detached.
FRAME_DETACHED = 3,
// A mainframe navigation was started which was initiated in the content area
// (i.e. not clicking on a bookmark or typing a URL in the omnibar), not by
// a link click. Only observed after the user interacted with a form.
PROBABLY_FORM_SUBMITTED = 4,
// Normal form submission (i.e. user presses the submit button and no
// JavaScript is involved). Observed via RenderFrameObserver::WillSubmitForm.
FORM_SUBMISSION = 5,
// The form or field was hidden or removed after autofilling it. Autofill
// ignores such submissions on non-WebView because mutations of the form can
// happen for other reasons than submission. PWM however considers this a
// valid source since mutations of password forms are more rare.
DOM_MUTATION_AFTER_AUTOFILL = 6,
};
enum FocusedFieldType {
kUnknown,
kUnfillableElement,
kFillableTextArea,
kFillableSearchField,
kFillableNonSearchField,
kFillableWebauthnTaggedField,
kFillableUsernameField,
kFillablePasswordField,
};
// Describes how a form button is implemented in HTML source. Should be
// synced with |ButtonTitleType| in
// components/autofill/core/browser/proto/server.proto.
enum ButtonTitleType {
NONE = 0,
BUTTON_ELEMENT_SUBMIT_TYPE = 1, // <button type='submit'>
BUTTON_ELEMENT_BUTTON_TYPE = 2, // <button type='button'>
INPUT_ELEMENT_SUBMIT_TYPE = 3, // <input type='submit'>
INPUT_ELEMENT_BUTTON_TYPE = 4, // <input type='button'>
HYPERLINK = 5, // e.g. <a class='button'>
DIV = 6, // e.g. <div id='submit'>
SPAN = 7 // e.g. <span name='btn'>
};
// Describes various criteria (e.g. there are empty fields in the form) that
// affect whether a form is ready for submission. Don't change IDs as they are
// used for metrics.
// TODO(crbug.com/40209736): Basically, the browser needs just a boolean: submit
// or not. Once related projects (crbug.com/1393043, crbug.com/1319364) are
// done or archived, this enum can be removed.
enum SubmissionReadinessState {
// No information received. Supposed to be unused on Android.
kNoInformation = 0,
// Error occurred while assessing submission readiness. Ideally, Chrome
// should not report such votes. Otherwise, |CalculateSubmissionReadiness|
// should be corrected.
kError = 1,
// Various blockers of forms submission.
// There is only a sole password field.
// TODO(crbug.com/40223173): For now this entry doesn't trigger submission,
// but ideally Touch-To-Fill should be able to log a user in with just one
// tap, i.e. TTF should submit both single username and single password
// forms.
kNoUsernameField = 2,
// There are fields between username and password fields.
kFieldBetweenUsernameAndPassword = 3,
// There is a field right after the password field by focus traversal.
kFieldAfterPasswordField = 4,
// There are other empty fields. If the |kFieldBetweenUsernameAndPassword| or
// |kFieldAfterPasswordField| criteria are matched, they should be reported,
// not this one.
kEmptyFields = 5,
// No empty fields and there are more than two visible fields.
kMoreThanTwoFields = 6,
// The most conservative criterion for submission.
// There are only two visible fields: username and password.
kTwoFields = 7,
// There is only a sole username field.
// TODO(crbug.com/40223173): For now this entry doesn't trigger submission,
// but ideally Touch-To-Fill should be able to log a user in with just one
// tap, i.e. TTF should submit both single username and single password
// forms.
kNoPasswordField = 8,
// A child frame which is likely to be CAPTCHA was detected within the
// password form. Do not trigger submission in this case.
kLikelyHasCaptcha = 9,
};
// autofill::FrameToken (components/autofill/core/common/unique_ids.h)
struct FrameToken {
// The token wrapped by a LocalFrameToken or a RemoteFrameToken.
mojo_base.mojom.UnguessableToken token;
// Indicates whether |token| represents a LocalFrameToken.
bool is_local;
};
// autofill::FrameTokenWithPredecessor
// (components/autofill/core/common/form_data.h)
struct FrameTokenWithPredecessor {
FrameToken token;
int32 predecessor;
};
// autofill::FormRendererId (components/autofill/core/common/unique_ids.h)
struct FormRendererId {
uint64 id;
};
// autofill::FieldRendererId (components/autofill/core/common/unique_ids.h)
struct FieldRendererId {
uint64 id;
};
// autofill::SelectOption (components/autofill/core/common/form_field_data.h)
struct SelectOption {
mojo_base.mojom.String16 value;
mojo_base.mojom.String16 text;
};
// autofill::Section::Autocomplete
// (components/autofill/core/common/form_field_data.h)
struct SectionAutocomplete {
string section;
HtmlFieldMode html_field_mode;
};
// autofill::Section::FieldIdentifier
// (components/autofill/core/common/form_field_data.h)
struct SectionFieldIdentifier {
string field_name;
uint64 local_frame_id;
FieldRendererId field_renderer_id;
};
// autofill::Section::SectionValue
// (components/autofill/core/common/form_field_data.h)
union SectionValue {
bool default_section;
SectionAutocomplete autocomplete;
SectionFieldIdentifier field_identifier;
};
// autofill::Section (components/autofill/core/common/form_field_data.h)
struct Section {
SectionValue value;
};
// autofill::AutocompleteParsingResult
// (components/autofill/core/common/autocomplete_parsing_util.h)
struct AutocompleteParsingResult {
string section;
HtmlFieldMode mode;
HtmlFieldType field_type;
bool webauthn;
};
// autofill::FormFieldData (components/autofill/core/common/form_field_data.h)
struct FormFieldData {
enum CheckStatus {
kNotCheckable,
kCheckableButUnchecked,
kChecked,
};
// Copied to components/autofill/ios/browser/resources/autofill_controller.js.
enum RoleAttribute {
// "presentation"
kPresentation,
// Anything else.
kOther,
};
// From which source the label is inferred.
enum LabelSource {
kUnknown, // No label.
kLabelTag, // <label> sibling/ancestor.
kPTag, // <p> sibling.
kDivTable, // <div> ancestor.
kTdTag, // <td> sibling.
kDdTag, // <dd> sibling.
kLiTag, // <li> ancestor.
kPlaceHolder, // placeholder attribute.
kAriaLabel, // aria-label attribute.
kCombined, // Text node sibling (includes <b>, etc).
kValue, // value attribute.
kForId, // <label> for-attribute that links to an control
// via it's id attribute.
kForName, // <label> for-attribute that links to an control
// viait's name attribute.
kForShadowHostId, // <label> for-attribute that links to an control
// (inside a shadow DOM) via it's id attribute.
kForShadowHostName, // <label> for-attribute that links to an control
// (inside a shadow DOM) via it's name attribute.
kOverlayingLabel, // Succeeding DOM node overlaying the input.
};
mojo_base.mojom.String16 label;
mojo_base.mojom.String16 name;
mojo_base.mojom.String16 id_attribute;
mojo_base.mojom.String16 name_attribute;
mojo_base.mojom.String16 value;
mojo_base.mojom.String16 selected_text;
FormControlType form_control_type;
string autocomplete_attribute;
AutocompleteParsingResult? parsed_autocomplete;
mojo_base.mojom.String16 placeholder;
mojo_base.mojom.String16 css_classes;
mojo_base.mojom.String16 aria_label;
mojo_base.mojom.String16 aria_description;
FieldRendererId renderer_id;
FormRendererId host_form_id;
uint32 properties_mask;
int32 form_control_ax_id;
uint64 max_length;
bool is_user_edited;
bool is_autofilled;
Section section;
CheckStatus check_status;
bool is_focusable;
bool is_visible;
bool should_autocomplete;
RoleAttribute role;
mojo_base.mojom.TextDirection text_direction;
bool is_enabled;
bool is_readonly;
mojo_base.mojom.String16 user_input;
bool allows_writing_suggestions;
array<SelectOption> options;
LabelSource label_source;
gfx.mojom.RectF bounds;
array<SelectOption> datalist_options;
bool force_override;
};
// autofill::FormFieldData::FillData
// (components/autofill/core/common/form_field_filling_data.h)
struct FormFieldData_FillData {
mojo_base.mojom.String16 value;
FieldRendererId renderer_id;
FormRendererId host_form_id;
bool is_autofilled;
bool force_override;
};
// autofill::ButtonTitleInfo (components/autofill/core/common/form_data.h)
struct ButtonTitleInfo {
mojo_base.mojom.String16 title;
ButtonTitleType type;
};
// autofill::FormData (components/autofill/core/common/form_data.h)
struct FormData {
mojo_base.mojom.String16 id_attribute;
mojo_base.mojom.String16 name_attribute;
mojo_base.mojom.String16 name;
array<ButtonTitleInfo> button_titles;
url.mojom.Url action;
bool is_action_empty;
FormRendererId renderer_id;
array<FrameTokenWithPredecessor> child_frames;
SubmissionIndicatorEvent submission_event;
array<FormFieldData> fields;
array<FieldRendererId> username_predictions;
bool is_gaia_with_skip_save_password_form;
bool likely_contains_captcha;
};
// autofill::FormFieldDataPredictions
// (components/autofill/core/common/form_field_data_predictions.h)
struct FormFieldDataPredictions {
string host_form_signature;
string signature;
string heuristic_type;
// Empty if server predictions have not arrived, yet.
string? server_type;
string html_type;
string overall_type;
string parseable_name;
string section;
// See AutofillField for information on the ranks.
uint32 rank;
uint32 rank_in_signature_group;
uint32 rank_in_host_form;
uint32 rank_in_host_form_signature_group;
};
// autofill::FormDataPredictions
// (components/autofill/core/common/form_data_predictions.h)
struct FormDataPredictions {
FormData data;
string signature;
string alternative_signature;
array<FormFieldDataPredictions> fields;
};
// autofill::PasswordAndMetadata
// (components/autofill/core/common/password_form_fill_data.h)
struct PasswordAndMetadata {
mojo_base.mojom.String16 username_value;
mojo_base.mojom.String16 password_value;
string realm;
bool uses_account_store;
};
// autofill::PasswordFormFillData
// (components/autofill/core/common/password_form_fill_data.h)
struct PasswordFormFillData {
FormRendererId form_renderer_id;
url.mojom.Url url;
FieldRendererId username_element_renderer_id;
FieldRendererId password_element_renderer_id;
bool username_may_use_prefilled_placeholder;
PasswordAndMetadata preferred_login;
array<PasswordAndMetadata> additional_logins;
bool wait_for_username;
array<FieldRendererId> suggestion_banned_fields;
};
// autofill::PasswordFormGenerationData
// (components/autofill/core/common/password_form_generation_data.h)
struct PasswordFormGenerationData {
FieldRendererId new_password_renderer_id;
FieldRendererId confirmation_password_renderer_id;
};
// autofill::password_generation::PasswordGenerationUIData
// (components/autofill/core/common/password_generation_util.h)
struct PasswordGenerationUIData {
gfx.mojom.RectF bounds;
int32 max_length;
mojo_base.mojom.String16 generation_element;
FieldRendererId generation_element_id;
bool is_generation_element_password_type;
mojo_base.mojom.TextDirection text_direction;
FormData form_data;
bool input_field_empty;
};
// autofill::PasswordSuggestionRequest
// (components/autofill/core/common/password_form_fill_data.h)
struct PasswordSuggestionRequest {
FieldRendererId element_id;
FormData form_data;
AutofillSuggestionTriggerSource trigger_source;
uint64 username_field_index;
uint64 password_field_index;
mojo_base.mojom.TextDirection text_direction;
mojo_base.mojom.String16 typed_username;
bool show_webauthn_credentials;
gfx.mojom.RectF bounds;
};
// autofill::ParsingResult
// (components/autofill/core/common/password_form_fill_data.h)
struct ParsingResult {
FieldRendererId username_renderer_id;
FieldRendererId password_renderer_id;
FieldRendererId new_password_renderer_id;
FieldRendererId confirm_password_renderer_id;
};
// Represents whether suggestions are available for Autofill/Autocomplete.
enum AutofillSuggestionAvailability {
// There are no available suggestions, neither autofill nor autocomplete, for
// the input.
kNoSuggestions,
// There are available autofill suggestions for the input. Autofill fills in
// an entire form.
kAutofillAvailable,
// There are available autocomplete suggestions for the input. Autocomplete
// only fills in a single input.
kAutocompleteAvailable,
};
// Represents whether an autofill action, which is an operation that changes a
// form, will persist (kFill) or will be cleared later (kPreview).
enum ActionPersistence {
kFill, // The action is filled.
kPreview, // The action is previewed and will be cleared afterwards.
};
// The possible actions that Autofill can perform on forms.
enum FormActionType {
kFill, // Autofill should fill the form.
kUndo, // Autofill should undo some previous fill operation on the form.
};
// The possible actions that Autofill can perform on fields.
enum FieldActionType {
kReplaceAll, // Replace the field's current value.
kReplaceSelection, // Replace only the currently selected text.
kSelectAll, // Selects all the text within this field.
};
// Describes which action triggered Autofill suggestions. This has implications
// how the suggestions behave, as described below.
// Some further properties of suggestions are implied by the source. See
// components/autofill/content/renderer/suggestion_properties.h.
// Suggestions are primarily triggered through Blink events in the renderer.
// This then invokes `AutofillManager::OnAskForValuesToFill()` in the browser
// process. In some cases, suggestions get updated. This happens solely in the
// browser process.
// Must stay in sync with AutofillSuggestionTriggerSource in
// histograms/enums.xml. Do not reorder or remove items.
enum AutofillSuggestionTriggerSource {
// Used as a default value and cannot be used to trigger suggestions.
kUnspecified,
// Suggestions triggered by either:
// - Clicking or tapping a text input (TAB key doesn't count).
// - Focusing a text input using a screen reader.
// Suggestion of this type can trigger FastCheckout or TouchToFill.
kFormControlElementClicked,
// Suggestions triggered by focusing a textarea without click or tab
// interaction. Currently, this is only triggered on Desktop platforms and
// only generates Compose suggestions.
kTextareaFocusedWithoutClick,
// Suggestions triggered as above except that the target is a
// contenteditable element rather than a form control element.
kContentEditableClicked,
// Suggestions triggered by modifying the content of a text input.
kTextFieldDidChange,
// Suggestions triggered by pressing the down key on a text input. This auto
// selects the first suggestion.
kTextFieldDidReceiveKeyDown,
// Suggestions triggered by the clicking onto the "triangle" on an
// <input list=...> to show <datalist> suggestions. While this also counts
// as a kFormControlElementClicked event, it is triggered slightly later.
// As of crrev.com/c/107353005, prefix matching for such suggestions is
// skipped, to make them behave more like a <select>.
// TODO(crbug.com/40100455): It's unclear if this is still necessary.
kOpenTextDataListChooser,
// Credit card suggestions offer users with Sync transport eligiblity an
// option to display cards from their account. This causes the suggestions to
// update. The updated suggested are considered to have this trigger source.
kShowCardsFromAccount,
// The suggestion triggering logic through Blink events (e.g.
// `kFormControlElementClicked`) is shared with the password manager. However,
// the trigger source is not propagated to the password manager specific
// code (password_autofill_agent.cc and onwards to the browser process).
// On the browser process side, all password suggestions are treated as
// `kPasswordManager`. On the renderer side, `kPasswordManager` is unused.
kPasswordManager,
// Since iOS has no renderer, it has separate suggestion triggering logic.
// This code currently doesn't distinguish between different suggestion
// trigger sources. They are all treated as `kiOS`. See crbug.com/1448447.
kiOS,
// Suggestions triggered by selecting the Autofill address manual fallback
// entry from the Chrome context menu. This trigger source is also used to
// reopen the Autofill popup after the user closed a dialog opened from the
// popup.
kManualFallbackAddress,
// Suggestions triggered by selecting the Autofill payment methods manual
// fallback entry from the Chrome context menu.
kManualFallbackPayments,
// Suggestions triggered by selecting the Autofill password manager manual
// fallback entry from the Chrome context menu.
kManualFallbackPasswords,
// Suggestions triggered by selecting the Plus Address manual fallback entry
// from the Chrome context menu.
kManualFallbackPlusAddresses,
// Suggestions are triggered after the user the user closed a dialog. For
// example, this can be profile edit or delete dialog. This trigger source
// is used only if the suggestions were triggered manually via the Chrome
// context menu.
kShowPromptAfterDialogClosedNonManualFallback,
// The compose saved state notification is triggered when the compose dialog
// loses focus and is closed.
kComposeDialogLostFocus,
// The compose proactive nudge is triggered after a delay by the compose
// manager.
kComposeDelayedProactiveNudge,
// Password manager renderer received password suggestions from the browser
// after the field was focused (likely due to autofocus on the page load).
kPasswordManagerProcessedFocusedField,
// Prediction improvements was invoked.
kPredictionImprovements,
};