blob: 0b112183bbcc799bbc4bcae140c83de05380ae69 [file] [log] [blame]
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.autofillPrivate</code> API to add, remove, or update
// autofill data from the settings UI.
namespace autofillPrivate {
// Subset of properties from the user account (signin component, AccountInfo).
dictionary AccountInfo {
DOMString email;
boolean isSyncEnabledForAutofillProfiles;
boolean isEligibleForAddressAccountStorage;
// Controls whether the Autofill Sync toggle should be available (duplicated
// from the Sync Settings page) on the Autofill Settings page.
// TODO(crbug.com/40943238): Remove when toggle becomes available on the Sync
// page for non-syncing users.
boolean isAutofillSyncToggleAvailable;
// Represents the UserSelectableType::kAutofill state (enabled or not).
// TODO(crbug.com/40943238): Remove when toggle becomes available on the Sync
// page for non-syncing users.
boolean isAutofillSyncToggleEnabled;
};
// A copy of FieldType from components/autofill/core/browser/field_types.h.
enum FieldType {
NO_SERVER_DATA,
UNKNOWN_TYPE,
EMPTY_TYPE,
NAME_FIRST,
NAME_MIDDLE,
NAME_LAST,
NAME_MIDDLE_INITIAL,
NAME_FULL,
NAME_SUFFIX,
ALTERNATIVE_FULL_NAME,
ALTERNATIVE_GIVEN_NAME,
ALTERNATIVE_FAMILY_NAME,
EMAIL_ADDRESS,
PHONE_HOME_NUMBER,
PHONE_HOME_CITY_CODE,
PHONE_HOME_COUNTRY_CODE,
PHONE_HOME_CITY_AND_NUMBER,
PHONE_HOME_WHOLE_NUMBER,
ADDRESS_HOME_LINE1,
ADDRESS_HOME_LINE2,
ADDRESS_HOME_APT_NUM,
ADDRESS_HOME_CITY,
ADDRESS_HOME_STATE,
ADDRESS_HOME_ZIP,
ADDRESS_HOME_COUNTRY,
CREDIT_CARD_NAME_FULL,
CREDIT_CARD_NUMBER,
CREDIT_CARD_EXP_MONTH,
CREDIT_CARD_EXP_2_DIGIT_YEAR,
CREDIT_CARD_EXP_4_DIGIT_YEAR,
CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR,
CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR,
CREDIT_CARD_TYPE,
CREDIT_CARD_VERIFICATION_CODE,
COMPANY_NAME,
MERCHANT_EMAIL_SIGNUP,
MERCHANT_PROMO_CODE,
PASSWORD,
ACCOUNT_CREATION_PASSWORD,
ADDRESS_HOME_STREET_ADDRESS,
ADDRESS_HOME_SORTING_CODE,
ADDRESS_HOME_DEPENDENT_LOCALITY,
ADDRESS_HOME_LINE3,
NOT_ACCOUNT_CREATION_PASSWORD,
USERNAME,
USERNAME_AND_EMAIL_ADDRESS,
NEW_PASSWORD,
PROBABLY_NEW_PASSWORD,
NOT_NEW_PASSWORD,
CREDIT_CARD_NAME_FIRST,
CREDIT_CARD_NAME_LAST,
PHONE_HOME_EXTENSION,
CONFIRMATION_PASSWORD,
AMBIGUOUS_TYPE,
SEARCH_TERM,
PRICE,
NOT_PASSWORD,
SINGLE_USERNAME,
NOT_USERNAME,
UPI_VPA,
ADDRESS_HOME_STREET_NAME,
ADDRESS_HOME_HOUSE_NUMBER,
ADDRESS_HOME_SUBPREMISE,
ADDRESS_HOME_OTHER_SUBUNIT,
NAME_LAST_PREFIX,
NAME_LAST_CORE,
NAME_LAST_FIRST,
NAME_LAST_CONJUNCTION,
NAME_LAST_SECOND,
NAME_HONORIFIC_PREFIX,
ADDRESS_HOME_ADDRESS,
ADDRESS_HOME_ADDRESS_WITH_NAME,
ADDRESS_HOME_FLOOR,
PHONE_HOME_CITY_CODE_WITH_TRUNK_PREFIX,
PHONE_HOME_CITY_AND_NUMBER_WITHOUT_TRUNK_PREFIX,
PHONE_HOME_NUMBER_PREFIX,
PHONE_HOME_NUMBER_SUFFIX,
IBAN_VALUE,
CREDIT_CARD_STANDALONE_VERIFICATION_CODE,
NUMERIC_QUANTITY,
ONE_TIME_CODE,
DELIVERY_INSTRUCTIONS,
ADDRESS_HOME_OVERFLOW,
ADDRESS_HOME_LANDMARK,
ADDRESS_HOME_OVERFLOW_AND_LANDMARK,
ADDRESS_HOME_ADMIN_LEVEL2,
ADDRESS_HOME_STREET_LOCATION,
ADDRESS_HOME_BETWEEN_STREETS,
ADDRESS_HOME_BETWEEN_STREETS_OR_LANDMARK,
ADDRESS_HOME_STREET_LOCATION_AND_LOCALITY,
ADDRESS_HOME_STREET_LOCATION_AND_LANDMARK,
ADDRESS_HOME_DEPENDENT_LOCALITY_AND_LANDMARK,
ADDRESS_HOME_BETWEEN_STREETS_1,
ADDRESS_HOME_BETWEEN_STREETS_2,
SINGLE_USERNAME_FORGOT_PASSWORD,
ADDRESS_HOME_APT,
ADDRESS_HOME_APT_TYPE,
ADDRESS_HOME_HOUSE_NUMBER_AND_APT,
SINGLE_USERNAME_WITH_INTERMEDIATE_VALUES,
PASSPORT_NUMBER,
PASSPORT_ISSUING_COUNTRY,
PASSPORT_EXPIRATION_DATE,
PASSPORT_ISSUE_DATE,
LOYALTY_MEMBERSHIP_PROGRAM,
LOYALTY_MEMBERSHIP_PROVIDER,
LOYALTY_MEMBERSHIP_ID,
VEHICLE_LICENSE_PLATE,
VEHICLE_VIN,
VEHICLE_MAKE,
VEHICLE_MODEL,
DRIVERS_LICENSE_REGION,
DRIVERS_LICENSE_NUMBER,
DRIVERS_LICENSE_EXPIRATION_DATE,
DRIVERS_LICENSE_ISSUE_DATE,
VEHICLE_YEAR,
VEHICLE_PLATE_STATE,
EMAIL_OR_LOYALTY_MEMBERSHIP_ID,
NATIONAL_ID_CARD_NUMBER,
NATIONAL_ID_CARD_EXPIRATION_DATE,
NATIONAL_ID_CARD_ISSUE_DATE,
NATIONAL_ID_CARD_ISSUING_COUNTRY,
KNOWN_TRAVELER_NUMBER,
KNOWN_TRAVELER_NUMBER_EXPIRATION_DATE,
REDRESS_NUMBER,
ADDRESS_HOME_ZIP_PREFIX,
ADDRESS_HOME_ZIP_SUFFIX,
FLIGHT_RESERVATION_FLIGHT_NUMBER,
FLIGHT_RESERVATION_TICKET_NUMBER,
FLIGHT_RESERVATION_CONFIRMATION_CODE,
FLIGHT_RESERVATION_PASSENGER_NAME,
FLIGHT_RESERVATION_DEPARTURE_AIRPORT,
FLIGHT_RESERVATION_ARRIVAL_AIRPORT,
MAX_VALID_FIELD_TYPE
};
// The address record type. Describes where the address is stored.
enum AddressRecordType {
// The address is stored in the Chrome infrastructure (locally and
// possibly synced between devices).
LOCAL_OR_SYNCABLE,
// The address is stored in a third party service that is tied
// to user's account.
ACCOUNT,
ACCOUNT_HOME,
ACCOUNT_WORK,
// The address is stored locally. Not synced at all.
ACCOUNT_NAME_EMAIL
};
// The type of data that can be stored for an attribute type.
enum AttributeTypeDataType {
COUNTRY,
DATE,
STRING
};
// Metadata about an autofill entry (address or credit card) which is used to
// render a summary list of all entries.
dictionary AutofillMetadata {
// Short summary of the address/credit card which is displayed in the UI; an
// undefined value means that this entry has just been created on the client
// and has not yet been given a summary.
DOMString summaryLabel;
// Short, secondary summary of the address/credit card which is displayed
// in the UI; an undefined value means that this entry has just been created
// on the client and has not yet been given a summary.
DOMString? summarySublabel;
// For addresses. Describes where the address is stored.
AddressRecordType? recordType;
// For credit cards, whether the entry is locally owned by Chrome (as opposed to
// being synced down from the server). Non-local entries may not be editable.
boolean? isLocal;
// For credit cards, whether this is migratable (both the card number and
// expiration date valid and does not have the duplicated server card).
boolean? isMigratable;
// For credit cards. Indicates whether a card is eligible for virtual cards
// enrollment.
boolean? isVirtualCardEnrollmentEligible;
// For credit cards. Indicates whether a card has been enrolled in virtual
// cards if it is eligible.
boolean? isVirtualCardEnrolled;
};
// Represents single entry of the autofill profile, containing field type and
// the corresponding field value.
dictionary AddressField {
FieldType type;
DOMString value;
};
// An address entry which can be saved in the autofill section of the
// settings UI.
dictionary AddressEntry {
// Globally unique identifier for this entry.
DOMString? guid;
// Fields have to be stored in the array with every field style stored only
// once.
AddressField[] fields;
DOMString? languageCode;
AutofillMetadata? metadata;
};
// An entry representing a country and its code.
dictionary CountryEntry {
// The internationalized name of the country.
DOMString? name;
// A two-character string representing the country.
DOMString? countryCode;
};
// A component to be shown in an address editor. Different countries have
// different components to their addresses.
dictionary AddressComponent {
// The field type.
FieldType field;
// The name of the field.
DOMString fieldName;
// A hint for the UI regarding whether the input is likely to be long.
boolean isLongField;
// Whether this component is required or not.
boolean isRequired;
// A placeholder for the text field to be used when the user has not yet
// input a value for the field.
DOMString? placeholder;
};
// A row of address components. Each component in a row should be shown in the
// same row in the UI. For example, city, state, and zip code are all included
// on the same line for US addresses.
dictionary AddressComponentRow {
AddressComponent[] row;
};
// The address components for a given country code. Each entry in |components|
// constitutes a row in the UI, while each inner array contains the list of
// components to use in that row. For example, city, state, and zip code are
// all included on the same line for US addresses. This dictionary also
// includes the associated language code.
dictionary AddressComponents {
// The components.
AddressComponentRow[] components;
// The language code.
DOMString languageCode;
};
// A credit card entry which can be saved in the autofill section of the
// settings UI.
dictionary CreditCardEntry {
// Globally unique identifier for this entry.
DOMString? guid;
// The card's instrument ID from the GPay server, if applicable.
DOMString? instrumentId;
// Name of the person who owns the credit card.
DOMString? name;
// Credit card number.
DOMString? cardNumber;
// Month as 2-character string ("01" = January, "12" = December).
DOMString? expirationMonth;
// Year as a 4-character string (as in "2015").
DOMString? expirationYear;
// Credit card's nickname.
DOMString? nickname;
// Credit card's network.
DOMString? network;
// Credit card's image source.
DOMString? imageSrc;
// Credit card's masked cvc.
DOMString? cvc;
// Credit card's product terms URL.
DOMString? productTermsUrl;
AutofillMetadata? metadata;
};
// An IBAN entry which can be saved in the autofill section of the
// settings UI.
dictionary IbanEntry {
// Globally unique identifier for this entry.
DOMString? guid;
// The IBAN's instrument ID from the GPay server, if applicable.
DOMString? instrumentId;
// IBAN value.
DOMString? value;
// IBAN's nickname.
DOMString? nickname;
AutofillMetadata? metadata;
};
// Contains the attribute type name and other relevant information about the
// attribute type. It is part of the `EntityInstance` API.
dictionary AttributeType {
// Contains the value of an `AttributeTypeName` on the C++ side.
long typeName;
// The type name as a human readable string.
DOMString typeNameAsString;
// The type of data stored for this attribute type.
AttributeTypeDataType dataType;
};
// Contains the entity type name and other relevant information about the
// entity type. It is part of the `EntityInstance` API.
dictionary EntityType {
// Contains the value of an `EntityTypeName` on the C++ side.
long typeName;
// The type name as a human readable string.
DOMString typeNameAsString;
// The i18n string representation of "Add <entity type>". Used in the entity
// instance adding settings UI. The string cannot be constructed
// dynamically, because the "<entity type>" string might need declension in
// some languages.
DOMString addEntityTypeString;
// The i18n string representation of "Edit <entity type>". Used in the
// entity instance editing settings UI. The string cannot be constructed
// dynamically, because the "<entity type>" string might need declension in
// some languages.
DOMString editEntityTypeString;
// The i18n string representation of "Delete <entity type>". Used in the
// entity instance deletion settings UI. The string cannot be constructed
// dynamically, because the "<entity type>" string might need declension in
// some languages.
DOMString deleteEntityTypeString;
};
// Contains date information: month, day and year.
dictionary DateValue {
// The year of the date valure, repesented as "YYYY". Example: "2016".
DOMString year;
// The month of the date value, without leading zeros. Example: "3" for
// March, "10" for October.
DOMString month;
// The day of the date value, without leading zeros. Example: "3", "30".
DOMString day;
};
// An attribute instance is a typed string value with additional metadata.
// It is associated with an `EntityInstance`.
dictionary AttributeInstance {
// Contains the attribute type name and other relevant information about the
// attribute type.
AttributeType type;
// The attribute instance value. If the `AttributeTypeDataType` is a `DATE`,
// then `value` is a `DateValue`. Otherwise, `value` is a `DOMString`.
(DOMString or DateValue) value;
};
// An entity instance entry which can be saved in the "Autofill with AI"
// section of the settings UI.
dictionary EntityInstance {
// Contains the entity type name and other relevant information about the
// entity type.
EntityType type;
// The attribute instances of this entity instance.
AttributeInstance[] attributeInstances;
// The guid of the entity instance.
DOMString guid;
// The nickname of the entity instance.
DOMString nickname;
};
// Contains the minimum amount of information needed to display an entity
// instance, along with the guid. The guid is needed to retrieve the complete
// information of the entity instance.
dictionary EntityInstanceWithLabels {
// The guid of the entity instance.
DOMString guid;
// The enitity instance label.
DOMString entityInstanceLabel;
// The enitity instance sublabel.
DOMString entityInstanceSubLabel;
};
// A Pay Over Time Issuer entry which can be displayed in the autofill
// section of the settings UI.
dictionary PayOverTimeIssuerEntry {
// Unique identifier for the Pay Over Time issuer.
DOMString? issuerId;
// The Pay Over Time issuer's instrument ID from the GPay server,
// if applicable.
DOMString? instrumentId;
// The Pay Over Time issuer's display name.
DOMString? displayName;
// The Pay Over Time issuer image source.
DOMString? imageSrc;
// The Pay Over Time issuer image source for dark theme.
DOMString? imageSrcDark;
};
callback VoidCallback = void();
callback GetAccountInfoCallback = void(optional AccountInfo accountInfo);
callback GetCountryListCallback = void(CountryEntry[] countries);
callback GetAddressComponentsCallback = void(AddressComponents components);
callback GetAddressListCallback = void(AddressEntry[] entries);
callback GetCreditCardListCallback = void(CreditCardEntry[] entries);
callback GetIbanListCallback = void(IbanEntry[] entries);
callback IsValidIbanCallback = void(boolean isValid);
callback GetCreditCardCallback = void(optional CreditCardEntry card);
callback CheckForDeviceAuthCallback = void(boolean isDeviceAuthAvailable);
callback LoadEntityInstancesCallback = void(EntityInstanceWithLabels[] entries);
callback GetEntityInstanceByGuid = void(EntityInstance entityInstance);
callback GetAllEntityTypesCallback = void(EntityType[] entityTypes);
callback GetAllAttributeTypesForEntityTypeNameCallback =
void(AttributeType[] attributeTypes);
callback GetAutofillAiOptInStatusCallback = void(boolean optedIn);
callback SetAutofillAiOptInStatusCallback = void(boolean success);
callback GetPayOverTimeIssuerListCallback = void(PayOverTimeIssuerEntry[] entries);
interface Functions {
// Gets currently signed-in user profile info, no value is returned if
// the user is not signed-in.
// |callback|: Callback which will be called with the info.
static void getAccountInfo(
GetAccountInfoCallback callback);
// Saves the given address. If |address| has an empty string as its ID, it
// will be assigned a new one and added as a new entry.
// |address|: The address entry to save.
static void saveAddress(AddressEntry address);
// Removes the address with the given ID.
// |guid|: ID of the address to remove.
static void removeAddress(DOMString guid);
// Gets the list of all countries.
// |forAccountStorage|: whether the address profile opened in the editor
// originates in the user's profile.
// |callback|: Callback which will be called with the countries.
static void getCountryList(
boolean forAccountStorage,
GetCountryListCallback callback);
// Gets the address components for a given country code.
// |countryCode|: A two-character string representing the address' country
// whose components should be returned. See autofill_country.cc for a
// list of valid codes.
// |callback|: Callback which will be called with components.
static void getAddressComponents(
DOMString countryCode,
GetAddressComponentsCallback callback);
// Gets the list of addresses.
// |callback|: Callback which will be called with the list of addresses.
static void getAddressList(
GetAddressListCallback callback);
// Saves the given credit card. If |card| has an empty string as its
// ID, it will be assigned a new one and added as a new entry.
// |card|: The card entry to save.
static void saveCreditCard(CreditCardEntry card);
// Saves the given IBAN. If `iban` has an empty string as its ID, it will be
// assigned a new one and added as a new entry.
// |iban|: The IBAN entry to save.
static void saveIban(IbanEntry iban);
// Removes the payments entity with the given ID.
// |guid|: ID of the entity to remove.
static void removePaymentsEntity(DOMString guid);
// Gets the list of credit cards.
// |callback|: Callback which will be called with the list of credit cards.
static void getCreditCardList(
GetCreditCardListCallback callback);
// Gets the list of IBANs.
// |callback|: Callback which will be called with the list of IBANs.
static void getIbanList(
GetIbanListCallback callback);
// Returns true if the given `ibanValue` is a valid IBAN.
// |callback|: Callback which will be called with the result of IBAN
// validation.
static void isValidIban(
DOMString ibanValue, IsValidIbanCallback callback);
// Logs that the server cards edit link was clicked.
static void logServerCardLinkClicked();
// Logs that a server IBAN's edit link was clicked.
static void logServerIbanLinkClicked();
// Enrolls a credit card into virtual cards.
// |cardId|: The server side id of the credit card to be enrolled. Note it
// refers to the legacy server id of credit cards, not the instrument ids.
static void addVirtualCard(DOMString cardId);
// Unenrolls a credit card from virtual cards.
// |cardId|: The server side id of the credit card to be unenrolled. Note
// it refers to the legacy server id of credit cards, not the instrument
// ids.
static void removeVirtualCard(DOMString cardId);
// Gets the list of Pay Over Time Issuers.
// |callback|: Callback which will be called with the list of
// Pay Over Time Issuers.
static void getPayOverTimeIssuerList(
GetPayOverTimeIssuerListCallback callback);
// Authenticates the user via device authentication and if successful, it
// will then flip the mandatory auth toggle.
static void authenticateUserAndFlipMandatoryAuthToggle();
// Returns the local card based on the `guid` provided. The user could
// also be challenged with a reauth if that is enabled. For a successful
// auth, the local card is returned otherwise return a null object.
static void getLocalCard(
DOMString guid, GetCreditCardCallback callback);
// Returns true if there is authentication available on this device
// (biometric or screen lock), false otherwise.
static void checkIfDeviceAuthAvailable(
CheckForDeviceAuthCallback callback);
// Bulk delete all the CVCs (server and local) from the local webdata
// database. For server CVCs, this will also clear them from the Chrome
// sync server and thus other devices.
static void bulkDeleteAllCvcs();
// Sets the Sync Autofill toggle value, which corresponds to
// `syncer::UserSelectableType::kAutofill` in `SyncUserSettings`.
static void setAutofillSyncToggleEnabled(boolean enabled);
// Adds a new entity instance if it doesn't exist yet. Otherwise, it updates
// the entity instance.
static void addOrUpdateEntityInstance(
EntityInstance entityInstance, optional VoidCallback callback);
// Deletes an entity instance by its guid.
static void removeEntityInstance(
DOMString guid, optional VoidCallback callback);
// Returns all of the user's entity instances with labels.
static void loadEntityInstances(LoadEntityInstancesCallback callback);
// Returns the entity instance by its guid.
static void getEntityInstanceByGuid(
DOMString guid, GetEntityInstanceByGuid callback);
// Returns a list of all possible entity types. Used for the user to decide
// what entity instance to add.
static void getAllEntityTypes(GetAllEntityTypesCallback callback);
// Returns a list of all possible attribute types that can be set on an
// entity instance with the respective entity type name. Used for
// adding/editing a new entity instance.
static void getAllAttributeTypesForEntityTypeName(
long entityTypeName,
GetAllAttributeTypesForEntityTypeNameCallback callback);
// Gets the AutofillAI opt-in status for the current user.
static void getAutofillAiOptInStatus(
GetAutofillAiOptInStatusCallback callback);
// Sets the AutofillAI opt-in status for the current user.
static void setAutofillAiOptInStatus(
boolean optedIn,
SetAutofillAiOptInStatusCallback callback);
};
interface Events {
// Fired when the personal data has changed, meaning that an entry has
// been added, removed, or changed.
// `addressEntries`: the updated list of addresses.
// `creditCardEntries`: the updated list of credit cards.
// `ibans`: the updated list of IBANs.
// `payOverTimeIssuers`: the updated list of Pay Over Time issuers
// `accountInfo`: account info if the user is signed-in or no value if not.
static void onPersonalDataChanged(AddressEntry[] addressEntries,
CreditCardEntry[] creditCardEntries,
IbanEntry[] ibans,
PayOverTimeIssuerEntry[] payOverTimeIssuers,
optional AccountInfo accountInfo);
// Fired when the entity instances have changed (additions, updates,
// removals).
static void onEntityInstancesChanged(
EntityInstanceWithLabels[] entityInstancesWithLabels);
};
};