Chromium Code Reviews| 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 { | |
|
not at google - send to devlin
2015/04/22 22:24:42
Not used
Kyle Horimoto
2015/04/22 23:27:02
Sorry, I forgot to add in the AddressComponent dic
| |
| 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 displalyed in the UI; an | |
|
not at google - send to devlin
2015/04/22 22:24:42
displayed
Kyle Horimoto
2015/04/22 23:27:02
Done.
| |
| 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; | |
|
not at google - send to devlin
2015/04/22 22:24:42
Will there always be a sublabel?
Kyle Horimoto
2015/04/22 23:27:02
Made it optional.
| |
| 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; | |
|
not at google - send to devlin
2015/04/22 22:24:42
Should some of these entries be optional?
Kyle Horimoto
2015/04/22 23:27:02
You're right - in fact, all of them should be opti
| |
| 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 credit card entry which can be saved in the autofill section of the | |
| 85 // settings UI. | |
| 86 dictionary CreditCardEntry { | |
| 87 // Globally unique identifier for this entry. | |
| 88 DOMString guid; | |
| 89 | |
| 90 DOMString cardNumber; | |
| 91 | |
| 92 long expirationMonth; | |
| 93 | |
| 94 long expirationYear; | |
| 95 | |
| 96 AutofillMetadata metadata; | |
| 97 }; | |
| 98 | |
| 99 callback GetAddressComponentsCallback = | |
| 100 void(AddressComponents[][] components); | |
| 101 callback ValidatePhoneNumbersCallback = | |
| 102 void(DOMString[] validatedPhoneNumbers); | |
| 103 | |
| 104 interface Functions { | |
| 105 // Saves the given address. If |entry| has an empty string as its ID, it | |
| 106 // will be assigned a new one and added as a new entry. | |
| 107 // | |
| 108 // |entry|: The entry to save. | |
| 109 static void saveAddress(AddressEntry entry); | |
| 110 | |
| 111 // Gets the address components for a given country code. This function | |
| 112 // invokes the callback with an array of arrays of AddressComponents. Each | |
| 113 // entry in the top-level array constitutes a row in the UI, while each | |
| 114 // inner array/ contains the list of components to use in that row. For | |
| 115 // example, city, state, and zip code are all included on the same line for | |
| 116 // US addresses. | |
| 117 // | |
| 118 // |countryCode|: The country code for which to fetch the components. | |
| 119 // |callback|: Callback which will be called with components. | |
| 120 static void getAddressComponents(DOMString countryCode, | |
| 121 GetAddressComponentsCallback callback); | |
| 122 | |
| 123 // Saves the given credit card. If |entry| has an empty string as its | |
| 124 // ID, it will be assigned a new one and added as a new entry. | |
| 125 // | |
| 126 // |entry|: The entry to save. | |
| 127 static void saveCreditCard(CreditCardEntry entry); | |
| 128 | |
| 129 // Removes the entry (address or credit card) with the given ID. | |
| 130 // | |
| 131 // |guid|: ID of the entry to remove. | |
| 132 static void removeEntry(DOMString guid); | |
| 133 | |
| 134 // Validates a newly-added phone number and invokes the callback with a list | |
| 135 // of validated numbers. Note that if the newly-added number was invalid, it | |
| 136 // will not be returned in the list of valid numbers. | |
| 137 // | |
| 138 // |phoneNumbers|: The phone numbers to validate. | |
| 139 // |indexOfNewNumber|: The index into |phoneNumbers| at which the new number | |
| 140 // has been added. | |
| 141 // |countryCode|: The country code for the numbers. | |
| 142 // |callback|: Callback which will be called with validated phone numbers. | |
| 143 static DOMString[] validatePhoneNumbers(DOMString[] phoneNumbers, | |
|
not at google - send to devlin
2015/04/22 22:24:42
For large numbers of arguments, better to pass in
Kyle Horimoto
2015/04/22 23:27:02
Done.
| |
| 144 long indexOfNewNumber, DOMString countryCode, | |
| 145 ValidatePhoneNumbersCallback callback); | |
| 146 | |
| 147 // Clears the data associated with a wallet card which was saved | |
| 148 // locally so that the saved copy is masked (e.g., "Card ending | |
| 149 // in 1234"). | |
| 150 // | |
| 151 // |guid|: ID of the entry to mask. | |
| 152 static void maskCreditCard(DOMString guid); | |
| 153 }; | |
| 154 | |
| 155 interface Events { | |
| 156 // Fired when the address list has changed, meaning that an entry has been | |
| 157 // added, removed, or changed. | |
| 158 // | |
| 159 // |entries| The updated list of entries. | |
| 160 static void onAddressListChanged(AddressEntry[] entries); | |
| 161 | |
| 162 // Fired when the credit card list has changed, meaning that an entry has | |
| 163 // been added, removed, or changed. | |
| 164 // | |
| 165 // |entries| The updated list of entries. | |
| 166 static void onAddressListChanged(CreditCardEntry[] entries); | |
|
Dan Beam
2015/04/22 22:13:56
nit: onCreditCardListChanged ;)
Kyle Horimoto
2015/04/22 22:19:37
Done.
| |
| 167 }; | |
| 168 }; | |
| OLD | NEW |