OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 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. |
| 9 enum AddressField { |
| 10 FULL_NAME, |
| 11 COMPANY_NAME, |
| 12 ADDRESS_LINES, |
| 13 ADDRESS_LEVEL_1, |
| 14 ADDRESS_LEVEL_2, |
| 15 ADDRESS_LEVEL_3, |
| 16 POSTAL_CODE, |
| 17 SORTING_CODE, |
| 18 COUNTRY_CODE |
| 19 }; |
| 20 |
| 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; |
| 28 |
| 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; |
| 33 |
| 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 |
| 36 // editable. |
| 37 boolean? isLocal; |
| 38 |
| 39 // For credit cards, whether this is a full copy of the card |
| 40 boolean? isCached; |
| 41 }; |
| 42 |
| 43 // An address entry which can be saved in the autofill section of the |
| 44 // settings UI. |
| 45 dictionary AddressEntry { |
| 46 // Globally unique identifier for this entry. |
| 47 DOMString? guid; |
| 48 |
| 49 DOMString[]? fullNames; |
| 50 |
| 51 DOMString? companyName; |
| 52 |
| 53 // Street address (multiple lines, newlines preserved). |
| 54 DOMString? addressLines; |
| 55 |
| 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 |
| 59 // town. |
| 60 DOMString? addressLevel1; |
| 61 |
| 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; |
| 67 |
| 68 // The third administrative level, in addresses with three or more |
| 69 // administrative levels. |
| 70 DOMString? addressLevel3; |
| 71 |
| 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; |
| 75 |
| 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; |
| 82 |
| 83 DOMString? country; |
| 84 |
| 85 DOMString[]? phoneNumbers; |
| 86 |
| 87 DOMString[]? emailAddresses; |
| 88 |
| 89 DOMString? languageCode; |
| 90 |
| 91 AutofillMetadata? metadata; |
| 92 }; |
| 93 |
| 94 // A component to be shown in an address editor. Different countries have |
| 95 // different components to their addresses. |
| 96 dictionary AddressComponent { |
| 97 // The type of field that this is. |
| 98 AddressField field; |
| 99 |
| 100 // The name of the field. |
| 101 DOMString fieldName; |
| 102 |
| 103 // A hint for the UI regarding whether the input is likely to be long. |
| 104 boolean isLongField; |
| 105 }; |
| 106 |
| 107 // The address components for a given country code. Each entry in |components| |
| 108 // constitutes a row in the UI, while each inner array contains the list of |
| 109 // components to use in that row. For example, city, state, and zip code are |
| 110 // all included on the same line for US addresses. This dictionary also |
| 111 // includes the associated language code. |
| 112 dictionary AddressComponents { |
| 113 // The components. |
| 114 AddressComponent[][] components; |
| 115 |
| 116 // The language code. |
| 117 DOMString languageCode; |
| 118 }; |
| 119 |
| 120 // A credit card entry which can be saved in the autofill section of the |
| 121 // settings UI. |
| 122 dictionary CreditCardEntry { |
| 123 // Globally unique identifier for this entry. |
| 124 DOMString? guid; |
| 125 |
| 126 // Name of the person who owns the credit card. |
| 127 DOMString? name; |
| 128 |
| 129 // Credit card number. |
| 130 DOMString? cardNumber; |
| 131 |
| 132 // Month as 2-character string ("01" = January, "12" = December). |
| 133 DOMString? expirationMonth; |
| 134 |
| 135 // Year as a 4-character string (as in "2015"). |
| 136 DOMString? expirationYear; |
| 137 |
| 138 AutofillMetadata? metadata; |
| 139 }; |
| 140 |
| 141 // Parameters to be passed to validatePhoneNumbers(). |
| 142 dictionary ValidatePhoneParams { |
| 143 // The phone numbers to validate. |
| 144 DOMString[] phoneNumbers; |
| 145 |
| 146 // The index into |phoneNumbers| at which the newly-added/edited phone |
| 147 // number resides. |
| 148 long indexOfNewNumber; |
| 149 |
| 150 // The country code for the numbers. |
| 151 DOMString countryCode; |
| 152 }; |
| 153 |
| 154 callback GetAddressComponentsCallback = |
| 155 void(AddressComponents components); |
| 156 callback ValidatePhoneNumbersCallback = |
| 157 void(DOMString[] validatedPhoneNumbers); |
| 158 |
| 159 interface Functions { |
| 160 // Saves the given address. If |address| has an empty string as its ID, it |
| 161 // will be assigned a new one and added as a new entry. |
| 162 // |
| 163 // |address|: The address entry to save. |
| 164 static void saveAddress(AddressEntry address); |
| 165 |
| 166 // Gets the address components for a given country code. |
| 167 // |
| 168 // |countryCode|: The country code for which to fetch the components. |
| 169 // |callback|: Callback which will be called with components. |
| 170 static void getAddressComponents(DOMString countryCode, |
| 171 GetAddressComponentsCallback callback); |
| 172 |
| 173 // Saves the given credit card. If |card| has an empty string as its |
| 174 // ID, it will be assigned a new one and added as a new entry. |
| 175 // |
| 176 // |card|: The card entry to save. |
| 177 static void saveCreditCard(CreditCardEntry card); |
| 178 |
| 179 // Removes the entry (address or credit card) with the given ID. |
| 180 // |
| 181 // |guid|: ID of the entry to remove. |
| 182 static void removeEntry(DOMString guid); |
| 183 |
| 184 // Validates a newly-added phone number and invokes the callback with a list |
| 185 // of validated numbers. Note that if the newly-added number was invalid, it |
| 186 // will not be returned in the list of valid numbers. |
| 187 // |
| 188 // |params|: The parameters to this function. |
| 189 // |callback|: Callback which will be called with validated phone numbers. |
| 190 static DOMString[] validatePhoneNumbers(ValidatePhoneParams params, |
| 191 ValidatePhoneNumbersCallback callback); |
| 192 |
| 193 // Clears the data associated with a wallet card which was saved |
| 194 // locally so that the saved copy is masked (e.g., "Card ending |
| 195 // in 1234"). |
| 196 // |
| 197 // |guid|: GUID of the credit card to mask. |
| 198 static void maskCreditCard(DOMString guid); |
| 199 }; |
| 200 |
| 201 interface Events { |
| 202 // Fired when the address list has changed, meaning that an entry has been |
| 203 // added, removed, or changed. |
| 204 // |
| 205 // |entries| The updated list of entries. |
| 206 static void onAddressListChanged(AddressEntry[] entries); |
| 207 |
| 208 // Fired when the credit card list has changed, meaning that an entry has |
| 209 // been added, removed, or changed. |
| 210 // |
| 211 // |entries| The updated list of entries. |
| 212 static void onCreditCardListChanged(CreditCardEntry[] entries); |
| 213 }; |
| 214 }; |
OLD | NEW |