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_LEVEL1, |
| 14 ADDRESS_LEVEL2, |
| 15 ADDRESS_LEVEL3, |
| 16 ADDRESS_LEVEL4, |
| 17 POSTAL_CODE, |
| 18 SORTING_CODE, |
| 19 COUNTRY_CODE |
| 20 }; |
| 21 |
| 22 // Metadata about an autofill entry (address or credit card) which is used to |
| 23 // render a summary list of all entries. |
| 24 dictionary AutofillMetadata { |
| 25 // Short summary of the address which is displayed in the UI; an |
| 26 // undefined value means that this entry has just been created on the client |
| 27 // and has not yet been given a summary. |
| 28 DOMString summaryLabel; |
| 29 |
| 30 // Short, secondary summary of the address which is displalyed in the UI; an |
| 31 // undefined value means that this entry has just been created on the client |
| 32 // and has not yet been given a summary. |
| 33 DOMString? summarySublabel; |
| 34 |
| 35 // Whether the entry is locally owned by Chrome (as opposed to being a |
| 36 // profile synced down from the server). Non-local entries may not be |
| 37 // editable. |
| 38 boolean? isLocal; |
| 39 |
| 40 // For credit cards, whether this is a full copy of the card |
| 41 boolean? isCached; |
| 42 }; |
| 43 |
| 44 // An address entry which can be saved in the autofill section of the |
| 45 // settings UI. |
| 46 dictionary AddressEntry { |
| 47 // Globally unique identifier for this entry. |
| 48 DOMString? guid; |
| 49 |
| 50 DOMString[]? fullNames; |
| 51 |
| 52 DOMString? companyName; |
| 53 |
| 54 // The street address, which may take multiple lines. |
| 55 DOMString? addressLines; |
| 56 |
| 57 // The biggest address level (in USA, the state). |
| 58 DOMString? addressLevel1; |
| 59 |
| 60 // The 2nd-biggest level (in USA, the city). |
| 61 DOMString? addressLevel2; |
| 62 |
| 63 // The 3rd-biggest level (not used in USA). |
| 64 DOMString? addressLevel3; |
| 65 |
| 66 // The 4th-biggest level (not used in USA). |
| 67 DOMString? addressLevel4; |
| 68 |
| 69 DOMString? postalCode; |
| 70 |
| 71 DOMString? sortingCode; |
| 72 |
| 73 DOMString? country; |
| 74 |
| 75 DOMString[]? phoneNumbers; |
| 76 |
| 77 DOMString[]? emailAddresses; |
| 78 |
| 79 DOMString? languageCode; |
| 80 |
| 81 AutofillMetadata? metadata; |
| 82 }; |
| 83 |
| 84 // A component to be shown in an address editor. Different countries have |
| 85 // different components to their addresses. |
| 86 dictionary AddressComponent { |
| 87 // The type of field that this is. |
| 88 AddressField field; |
| 89 |
| 90 // The name of the field. |
| 91 DOMString fieldName; |
| 92 |
| 93 // A hint for the UI regarding whether the input is likely to be long. |
| 94 boolean isLongField; |
| 95 }; |
| 96 |
| 97 // A credit card entry which can be saved in the autofill section of the |
| 98 // settings UI. |
| 99 dictionary CreditCardEntry { |
| 100 // Globally unique identifier for this entry. |
| 101 DOMString? guid; |
| 102 |
| 103 DOMString? cardNumber; |
| 104 |
| 105 long? expirationMonth; |
| 106 |
| 107 long? expirationYear; |
| 108 |
| 109 AutofillMetadata? metadata; |
| 110 }; |
| 111 |
| 112 // Parameters to be passed to validatePhoneNumbers(). |
| 113 dictionary ValidatePhoneParams { |
| 114 // The phone numbers to validate. |
| 115 DOMString[] phoneNumbers; |
| 116 |
| 117 // The index into |phoneNumbers| at which the newly-added/edited phone |
| 118 // number resides. |
| 119 long indexOfNewNumber; |
| 120 |
| 121 // The country code for the numbers. |
| 122 DOMString countryCode; |
| 123 }; |
| 124 |
| 125 callback GetAddressComponentsCallback = |
| 126 void(AddressComponent[][] components); |
| 127 callback ValidatePhoneNumbersCallback = |
| 128 void(DOMString[] validatedPhoneNumbers); |
| 129 |
| 130 interface Functions { |
| 131 // Saves the given address. If |address| has an empty string as its ID, it |
| 132 // will be assigned a new one and added as a new entry. |
| 133 // |
| 134 // |address|: The address entry to save. |
| 135 static void saveAddress(AddressEntry address); |
| 136 |
| 137 // Gets the address components for a given country code. This function |
| 138 // invokes the callback with an array of arrays of AddressComponents. Each |
| 139 // entry in the top-level array constitutes a row in the UI, while each |
| 140 // inner array/ contains the list of components to use in that row. For |
| 141 // example, city, state, and zip code are all included on the same line for |
| 142 // US addresses. |
| 143 // |
| 144 // |countryCode|: The country code for which to fetch the components. |
| 145 // |callback|: Callback which will be called with components. |
| 146 static void getAddressComponents(DOMString countryCode, |
| 147 GetAddressComponentsCallback callback); |
| 148 |
| 149 // Saves the given credit card. If |card| has an empty string as its |
| 150 // ID, it will be assigned a new one and added as a new entry. |
| 151 // |
| 152 // |card|: The card entry to save. |
| 153 static void saveCreditCard(CreditCardEntry card); |
| 154 |
| 155 // Removes the entry (address or credit card) with the given ID. |
| 156 // |
| 157 // |guid|: ID of the entry to remove. |
| 158 static void removeEntry(DOMString guid); |
| 159 |
| 160 // Validates a newly-added phone number and invokes the callback with a list |
| 161 // of validated numbers. Note that if the newly-added number was invalid, it |
| 162 // will not be returned in the list of valid numbers. |
| 163 // |
| 164 // |params|: The parameters to this function. |
| 165 // |callback|: Callback which will be called with validated phone numbers. |
| 166 static DOMString[] validatePhoneNumbers(ValidatePhoneParams params, |
| 167 ValidatePhoneNumbersCallback callback); |
| 168 |
| 169 // Clears the data associated with a wallet card which was saved |
| 170 // locally so that the saved copy is masked (e.g., "Card ending |
| 171 // in 1234"). |
| 172 // |
| 173 // |guid|: GUID of the credit card to mask. |
| 174 static void maskCreditCard(DOMString guid); |
| 175 }; |
| 176 |
| 177 interface Events { |
| 178 // Fired when the address list has changed, meaning that an entry has been |
| 179 // added, removed, or changed. |
| 180 // |
| 181 // |entries| The updated list of entries. |
| 182 static void onAddressListChanged(AddressEntry[] entries); |
| 183 |
| 184 // Fired when the credit card list has changed, meaning that an entry has |
| 185 // been added, removed, or changed. |
| 186 // |
| 187 // |entries| The updated list of entries. |
| 188 static void onCreditCardListChanged(CreditCardEntry[] entries); |
| 189 }; |
| 190 }; |
OLD | NEW |