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 CITY, |
| 14 STATE, |
| 15 DEPENDENT_LOCALITY, |
| 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 // The street address, which may take multiple lines. |
| 54 DOMString? addressLines; |
| 55 |
| 56 DOMString? city; |
| 57 |
| 58 DOMString? state; |
| 59 |
| 60 DOMString? dependentLocality; |
| 61 |
| 62 DOMString? postalCode; |
| 63 |
| 64 DOMString? sortingCode; |
| 65 |
| 66 DOMString? country; |
| 67 |
| 68 DOMString[]? phoneNumbers; |
| 69 |
| 70 DOMString[]? emailAddresses; |
| 71 |
| 72 DOMString? languageCode; |
| 73 |
| 74 AutofillMetadata? metadata; |
| 75 }; |
| 76 |
| 77 // A component to be shown in an address editor. Different countries have |
| 78 // different components to their addresses. |
| 79 dictionary AddressComponent { |
| 80 // The type of field that this is. |
| 81 AddressField field; |
| 82 |
| 83 // The name of the field. |
| 84 DOMString fieldName; |
| 85 |
| 86 // A hint for the UI regarding whether the input is likely to be long. |
| 87 boolean isLongField; |
| 88 }; |
| 89 |
| 90 // The address components for a given country code. Each entry in |components| |
| 91 // constitutes a row in the UI, while each inner array contains the list of |
| 92 // components to use in that row. For example, city, state, and zip code are |
| 93 // all included on the same line for US addresses. This dictionary also |
| 94 // includes the associated language code. |
| 95 dictionary AddressComponents { |
| 96 // The components. |
| 97 AddressComponent[][] components; |
| 98 |
| 99 // The language code. |
| 100 DOMString languageCode; |
| 101 }; |
| 102 |
| 103 // A credit card entry which can be saved in the autofill section of the |
| 104 // settings UI. |
| 105 dictionary CreditCardEntry { |
| 106 // Globally unique identifier for this entry. |
| 107 DOMString? guid; |
| 108 |
| 109 DOMString? cardNumber; |
| 110 |
| 111 long? expirationMonth; |
| 112 |
| 113 long? expirationYear; |
| 114 |
| 115 AutofillMetadata? metadata; |
| 116 }; |
| 117 |
| 118 // Parameters to be passed to validatePhoneNumbers(). |
| 119 dictionary ValidatePhoneParams { |
| 120 // The phone numbers to validate. |
| 121 DOMString[] phoneNumbers; |
| 122 |
| 123 // The index into |phoneNumbers| at which the newly-added/edited phone |
| 124 // number resides. |
| 125 long indexOfNewNumber; |
| 126 |
| 127 // The country code for the numbers. |
| 128 DOMString countryCode; |
| 129 }; |
| 130 |
| 131 callback GetAddressComponentsCallback = |
| 132 void(AddressComponents components); |
| 133 callback ValidatePhoneNumbersCallback = |
| 134 void(DOMString[] validatedPhoneNumbers); |
| 135 |
| 136 interface Functions { |
| 137 // Saves the given address. If |address| has an empty string as its ID, it |
| 138 // will be assigned a new one and added as a new entry. |
| 139 // |
| 140 // |address|: The address entry to save. |
| 141 static void saveAddress(AddressEntry address); |
| 142 |
| 143 // Gets the address components for a given country code. |
| 144 // |
| 145 // |countryCode|: The country code for which to fetch the components. |
| 146 // |callback|: Callback which will be called with components. |
| 147 static void getAddressComponents(DOMString countryCode, |
| 148 GetAddressComponentsCallback callback); |
| 149 |
| 150 // Saves the given credit card. If |card| has an empty string as its |
| 151 // ID, it will be assigned a new one and added as a new entry. |
| 152 // |
| 153 // |card|: The card entry to save. |
| 154 static void saveCreditCard(CreditCardEntry card); |
| 155 |
| 156 // Removes the entry (address or credit card) with the given ID. |
| 157 // |
| 158 // |guid|: ID of the entry to remove. |
| 159 static void removeEntry(DOMString guid); |
| 160 |
| 161 // Validates a newly-added phone number and invokes the callback with a list |
| 162 // of validated numbers. Note that if the newly-added number was invalid, it |
| 163 // will not be returned in the list of valid numbers. |
| 164 // |
| 165 // |params|: The parameters to this function. |
| 166 // |callback|: Callback which will be called with validated phone numbers. |
| 167 static DOMString[] validatePhoneNumbers(ValidatePhoneParams params, |
| 168 ValidatePhoneNumbersCallback callback); |
| 169 |
| 170 // Clears the data associated with a wallet card which was saved |
| 171 // locally so that the saved copy is masked (e.g., "Card ending |
| 172 // in 1234"). |
| 173 // |
| 174 // |guid|: GUID of the credit card to mask. |
| 175 static void maskCreditCard(DOMString guid); |
| 176 }; |
| 177 |
| 178 interface Events { |
| 179 // Fired when the address list has changed, meaning that an entry has been |
| 180 // added, removed, or changed. |
| 181 // |
| 182 // |entries| The updated list of entries. |
| 183 static void onAddressListChanged(AddressEntry[] entries); |
| 184 |
| 185 // Fired when the credit card list has changed, meaning that an entry has |
| 186 // been added, removed, or changed. |
| 187 // |
| 188 // |entries| The updated list of entries. |
| 189 static void onCreditCardListChanged(CreditCardEntry[] entries); |
| 190 }; |
| 191 }; |
OLD | NEW |