Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 1 | // Copyright 2013 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 | #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_FIELD_TYPES_H_ |
| 6 | #define COMPONENTS_AUTOFILL_CORE_BROWSER_FIELD_TYPES_H_ |
| 7 | |
Ben Murdoch | 2385ea3 | 2013-08-06 11:01:04 +0100 | [diff] [blame] | 8 | #include <map> |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 9 | #include <set> |
Ben Murdoch | 2385ea3 | 2013-08-06 11:01:04 +0100 | [diff] [blame] | 10 | |
| 11 | #include "base/strings/string16.h" |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 12 | |
| 13 | namespace autofill { |
| 14 | |
| 15 | // NOTE: This list MUST not be modified. The server aggregates and stores these |
| 16 | // types over several versions, so we must remain fully compatible with the |
| 17 | // Autofill server, which is itself backward-compatible. The list must be kept |
| 18 | // up to date with the Autofill server list. |
| 19 | // |
Ben Murdoch | 3240926 | 2013-08-07 11:04:47 +0100 | [diff] [blame] | 20 | // The list of all field types natively understood by the Autofill server. A |
| 21 | // subset of these types is used to store Autofill data in the user's profile. |
| 22 | enum ServerFieldType { |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 23 | // Server indication that it has no data for the requested field. |
| 24 | NO_SERVER_DATA = 0, |
| 25 | // Client indication that the text entered did not match anything in the |
| 26 | // personal data. |
| 27 | UNKNOWN_TYPE = 1, |
| 28 | // The "empty" type indicates that the user hasn't entered anything |
| 29 | // in this field. |
| 30 | EMPTY_TYPE = 2, |
| 31 | // Personal Information categorization types. |
| 32 | NAME_FIRST = 3, |
| 33 | NAME_MIDDLE = 4, |
| 34 | NAME_LAST = 5, |
| 35 | NAME_MIDDLE_INITIAL = 6, |
| 36 | NAME_FULL = 7, |
| 37 | NAME_SUFFIX = 8, |
| 38 | EMAIL_ADDRESS = 9, |
| 39 | PHONE_HOME_NUMBER = 10, |
| 40 | PHONE_HOME_CITY_CODE = 11, |
| 41 | PHONE_HOME_COUNTRY_CODE = 12, |
| 42 | PHONE_HOME_CITY_AND_NUMBER = 13, |
| 43 | PHONE_HOME_WHOLE_NUMBER = 14, |
| 44 | |
| 45 | // Work phone numbers (values [15,19]) are deprecated. |
| 46 | |
| 47 | // Fax numbers (values [20,24]) are deprecated in Chrome, but still supported |
| 48 | // by the server. |
| 49 | PHONE_FAX_NUMBER = 20, |
| 50 | PHONE_FAX_CITY_CODE = 21, |
| 51 | PHONE_FAX_COUNTRY_CODE = 22, |
| 52 | PHONE_FAX_CITY_AND_NUMBER = 23, |
| 53 | PHONE_FAX_WHOLE_NUMBER = 24, |
| 54 | |
| 55 | // Cell phone numbers (values [25, 29]) are deprecated. |
| 56 | |
| 57 | ADDRESS_HOME_LINE1 = 30, |
| 58 | ADDRESS_HOME_LINE2 = 31, |
| 59 | ADDRESS_HOME_APT_NUM = 32, |
| 60 | ADDRESS_HOME_CITY = 33, |
| 61 | ADDRESS_HOME_STATE = 34, |
| 62 | ADDRESS_HOME_ZIP = 35, |
| 63 | ADDRESS_HOME_COUNTRY = 36, |
| 64 | ADDRESS_BILLING_LINE1 = 37, |
| 65 | ADDRESS_BILLING_LINE2 = 38, |
| 66 | ADDRESS_BILLING_APT_NUM = 39, |
| 67 | ADDRESS_BILLING_CITY = 40, |
| 68 | ADDRESS_BILLING_STATE = 41, |
| 69 | ADDRESS_BILLING_ZIP = 42, |
| 70 | ADDRESS_BILLING_COUNTRY = 43, |
| 71 | |
| 72 | // ADDRESS_SHIPPING values [44,50] are deprecated. |
| 73 | |
| 74 | CREDIT_CARD_NAME = 51, |
| 75 | CREDIT_CARD_NUMBER = 52, |
| 76 | CREDIT_CARD_EXP_MONTH = 53, |
| 77 | CREDIT_CARD_EXP_2_DIGIT_YEAR = 54, |
| 78 | CREDIT_CARD_EXP_4_DIGIT_YEAR = 55, |
| 79 | CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR = 56, |
| 80 | CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR = 57, |
| 81 | CREDIT_CARD_TYPE = 58, |
| 82 | CREDIT_CARD_VERIFICATION_CODE = 59, |
| 83 | |
| 84 | COMPANY_NAME = 60, |
| 85 | |
| 86 | // Generic type whose default value is known. |
| 87 | FIELD_WITH_DEFAULT_VALUE = 61, |
| 88 | |
| 89 | PHONE_BILLING_NUMBER = 62, |
| 90 | PHONE_BILLING_CITY_CODE = 63, |
| 91 | PHONE_BILLING_COUNTRY_CODE = 64, |
| 92 | PHONE_BILLING_CITY_AND_NUMBER = 65, |
| 93 | PHONE_BILLING_WHOLE_NUMBER = 66, |
| 94 | |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 95 | NAME_BILLING_FIRST = 67, |
| 96 | NAME_BILLING_MIDDLE = 68, |
| 97 | NAME_BILLING_LAST = 69, |
| 98 | NAME_BILLING_MIDDLE_INITIAL = 70, |
| 99 | NAME_BILLING_FULL = 71, |
| 100 | NAME_BILLING_SUFFIX = 72, |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 101 | |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 102 | // No new types can be added without a corresponding change to the Autofill |
| 103 | // server. |
| 104 | |
| 105 | MAX_VALID_FIELD_TYPE = 73, |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 106 | }; |
| 107 | |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 108 | // The list of all HTML autocomplete field type hints supported by Chrome. |
| 109 | // See [ http://is.gd/whatwg_autocomplete ] for the full list of specced hints. |
| 110 | enum HtmlFieldType { |
| 111 | // Default type. |
| 112 | HTML_TYPE_UNKNOWN, |
| 113 | |
| 114 | // Name types. |
| 115 | HTML_TYPE_NAME, |
| 116 | HTML_TYPE_GIVEN_NAME, |
| 117 | HTML_TYPE_ADDITIONAL_NAME, |
| 118 | HTML_TYPE_FAMILY_NAME, |
| 119 | |
| 120 | // Business types. |
| 121 | HTML_TYPE_ORGANIZATION, |
| 122 | |
| 123 | // Address types. |
| 124 | HTML_TYPE_ADDRESS_LINE1, |
| 125 | HTML_TYPE_ADDRESS_LINE2, |
| 126 | HTML_TYPE_LOCALITY, // For U.S. addresses, corresponds to the city. |
| 127 | HTML_TYPE_REGION, // For U.S. addresses, corresponds to the state. |
| 128 | HTML_TYPE_COUNTRY_CODE, // The ISO 3166-1-alpha-2 country code. |
| 129 | HTML_TYPE_COUNTRY_NAME, // The localized country name. |
| 130 | HTML_TYPE_POSTAL_CODE, |
| 131 | |
| 132 | // Credit card types. |
| 133 | HTML_TYPE_CREDIT_CARD_NAME, |
| 134 | HTML_TYPE_CREDIT_CARD_NUMBER, |
| 135 | HTML_TYPE_CREDIT_CARD_EXP, |
| 136 | HTML_TYPE_CREDIT_CARD_EXP_MONTH, |
| 137 | HTML_TYPE_CREDIT_CARD_EXP_YEAR, |
| 138 | HTML_TYPE_CREDIT_CARD_VERIFICATION_CODE, |
| 139 | HTML_TYPE_CREDIT_CARD_TYPE, |
| 140 | |
| 141 | // Phone number types. |
| 142 | HTML_TYPE_TEL, |
| 143 | HTML_TYPE_TEL_COUNTRY_CODE, |
| 144 | HTML_TYPE_TEL_NATIONAL, |
| 145 | HTML_TYPE_TEL_AREA_CODE, |
| 146 | HTML_TYPE_TEL_LOCAL, |
| 147 | HTML_TYPE_TEL_LOCAL_PREFIX, |
| 148 | HTML_TYPE_TEL_LOCAL_SUFFIX, |
| 149 | |
| 150 | // Email. |
| 151 | HTML_TYPE_EMAIL, |
| 152 | |
| 153 | // Variants of type hints specified in the HTML specification that are |
| 154 | // inferred based on a field's 'maxlength' attribute. |
| 155 | // TODO(isherman): Remove these types, in favor of understanding maxlength |
| 156 | // when filling fields. See also: AutofillField::phone_part_. |
| 157 | HTML_TYPE_ADDITIONAL_NAME_INITIAL, |
| 158 | HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, |
| 159 | HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, |
| 160 | HTML_TYPE_CREDIT_CARD_EXP_2_DIGIT_YEAR, |
| 161 | HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR, |
| 162 | }; |
| 163 | |
| 164 | // The list of all HTML autocomplete field mode hints supported by Chrome. |
| 165 | // See [ http://is.gd/whatwg_autocomplete ] for the full list of specced hints. |
| 166 | enum HtmlFieldMode { |
| 167 | HTML_MODE_NONE, |
| 168 | HTML_MODE_BILLING, |
| 169 | HTML_MODE_SHIPPING, |
| 170 | }; |
| 171 | |
Ben Murdoch | 2385ea3 | 2013-08-06 11:01:04 +0100 | [diff] [blame] | 172 | enum FieldTypeGroup { |
| 173 | NO_GROUP, |
| 174 | NAME, |
| 175 | NAME_BILLING, |
| 176 | EMAIL, |
| 177 | COMPANY, |
| 178 | ADDRESS_HOME, |
| 179 | ADDRESS_BILLING, |
| 180 | PHONE_HOME, |
| 181 | PHONE_BILLING, |
| 182 | CREDIT_CARD, |
| 183 | }; |
| 184 | |
Ben Murdoch | 3240926 | 2013-08-07 11:04:47 +0100 | [diff] [blame] | 185 | typedef std::set<ServerFieldType> ServerFieldTypeSet; |
| 186 | typedef std::map<base::string16, ServerFieldType> ServerFieldTypeMap; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 187 | |
| 188 | } // namespace autofill |
| 189 | |
| 190 | #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FIELD_TYPES_H_ |