1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Use the <code>chrome.autofillPrivate</code> API to add, remove, or update
6 // autofill data from the settings UI.
7 namespace autofillPrivate
{
8 // Fields used as part of an address.
21 // Metadata about an autofill entry (address or credit card) which is used to
22 // render a summary list of all entries.
23 dictionary AutofillMetadata
{
24 // Short summary of the address which is displayed in the UI; an
25 // undefined value means that this entry has just been created on the client
26 // and has not yet been given a summary.
27 DOMString summaryLabel
;
29 // Short, secondary summary of the address which is displalyed in the UI; an
30 // undefined value means that this entry has just been created on the client
31 // and has not yet been given a summary.
32 DOMString? summarySublabel
;
34 // Whether the entry is locally owned by Chrome (as opposed to being a
35 // profile synced down from the server). Non-local entries may not be
39 // For credit cards, whether this is a full copy of the card
43 // An address entry which can be saved in the autofill section of the
45 dictionary AddressEntry
{
46 // Globally unique identifier for this entry.
49 DOMString
[]? fullNames
;
51 DOMString? companyName
;
53 // Street address (multiple lines, newlines preserved).
54 DOMString? addressLines
;
56 // The broadest administrative level in the address, i.e. the province
57 // within which the locality is found; for example, in the US, this would be
58 // the state; in Switzerland it would be the canton; in the UK, the post
60 DOMString? addressLevel1
;
62 // The second administrative level, in addresses with two or more
63 // administrative levels; in the countries with two administrative levels,
64 // this would typically be the city, town, village, or other locality within
65 // which the relevant street address is found.
66 DOMString? addressLevel2
;
68 // The third administrative level, in addresses with three or more
69 // administrative levels.
70 DOMString? addressLevel3
;
72 // Postal code, post code, ZIP code, CEDEX code (if CEDEX, append "CEDEX",
73 // and the arrondissement, if relevant, to the address-level2 field).
74 DOMString? postalCode
;
76 // A sorting code is similar to a postal code. However, whereas a postal
77 // code normally refers to a single geographical location, a sorting code
78 // often does not. Instead, a sorting code is assigned to an organization,
79 // which might be geographically distributed. The most prominent example of
80 // a sorting code system is CEDEX in France.
81 DOMString? sortingCode
;
83 // A two-character string representing the address' country. See
84 // autofill_country.cc for a list of valid codes.
85 DOMString? countryCode
;
87 DOMString
[]? phoneNumbers
;
89 DOMString
[]? emailAddresses
;
91 DOMString? languageCode
;
93 AutofillMetadata? metadata
;
96 // A component to be shown in an address editor. Different countries have
97 // different components to their addresses.
98 dictionary AddressComponent
{
102 // The name of the field.
105 // A hint for the UI regarding whether the input is likely to be long.
108 // A placeholder for the text field to be used when the user has not yet
109 // input a value for the field.
110 DOMString? placeholder
;
113 // A row of address components. Each component in a row should be shown in the
114 // same row in the UI. For example, city, state, and zip code are all included
115 // on the same line for US addresses.
116 dictionary AddressComponentRow
{
117 AddressComponent
[] row
;
120 // The address components for a given country code. Each entry in |components|
121 // constitutes a row in the UI, while each inner array contains the list of
122 // components to use in that row. For example, city, state, and zip code are
123 // all included on the same line for US addresses. This dictionary also
124 // includes the associated language code.
125 dictionary AddressComponents
{
127 AddressComponentRow
[] components
;
129 // The language code.
130 DOMString languageCode
;
133 // A credit card entry which can be saved in the autofill section of the
135 dictionary CreditCardEntry
{
136 // Globally unique identifier for this entry.
139 // Name of the person who owns the credit card.
142 // Credit card number.
143 DOMString? cardNumber
;
145 // Month as 2-character string ("01" = January, "12" = December).
146 DOMString? expirationMonth
;
148 // Year as a 4-character string (as in "2015").
149 DOMString? expirationYear
;
151 AutofillMetadata? metadata
;
154 // Parameters to be passed to validatePhoneNumbers().
155 dictionary ValidatePhoneParams
{
156 // The phone numbers to validate.
157 DOMString
[] phoneNumbers
;
159 // The index into |phoneNumbers| at which the newly-added/edited phone
161 long indexOfNewNumber
;
163 // A two-character string representing the address' country. See
164 // autofill_country.cc for a list of valid codes.
165 DOMString countryCode
;
168 callback GetAddressComponentsCallback
=
169 void(AddressComponents components
);
170 callback ValidatePhoneNumbersCallback
=
171 void(DOMString
[] validatedPhoneNumbers
);
173 interface Functions
{
174 // Saves the given address. If |address| has an empty string as its ID, it
175 // will be assigned a new one and added as a new entry.
177 // |address|: The address entry to save.
178 static
void saveAddress
(AddressEntry address
);
180 // Gets the address components for a given country code.
182 // |countryCode|: A two-character string representing the address' country
183 // whose components should be returned. See autofill_country.cc for a
184 // list of valid codes.
185 // |callback|: Callback which will be called with components.
186 static
void getAddressComponents
(DOMString countryCode
,
187 GetAddressComponentsCallback
callback);
189 // Saves the given credit card. If |card| has an empty string as its
190 // ID, it will be assigned a new one and added as a new entry.
192 // |card|: The card entry to save.
193 static
void saveCreditCard
(CreditCardEntry card
);
195 // Removes the entry (address or credit card) with the given ID.
197 // |guid|: ID of the entry to remove.
198 static
void removeEntry
(DOMString guid
);
200 // Validates a newly-added phone number and invokes the callback with a list
201 // of validated numbers. Note that if the newly-added number was invalid, it
202 // will not be returned in the list of valid numbers.
204 // |params|: The parameters to this function.
205 // |callback|: Callback which will be called with validated phone numbers.
206 static
void validatePhoneNumbers
(ValidatePhoneParams params
,
207 ValidatePhoneNumbersCallback
callback);
209 // Clears the data associated with a wallet card which was saved
210 // locally so that the saved copy is masked (e.g., "Card ending
213 // |guid|: GUID of the credit card to mask.
214 static
void maskCreditCard
(DOMString guid
);
218 // Fired when the address list has changed, meaning that an entry has been
219 // added, removed, or changed.
221 // |entries| The updated list of entries.
222 static
void onAddressListChanged
(AddressEntry
[] entries
);
224 // Fired when the credit card list has changed, meaning that an entry has
225 // been added, removed, or changed.
227 // |entries| The updated list of entries.
228 static
void onCreditCardListChanged
(CreditCardEntry
[] entries
);