Home | History | Annotate | Download | only in browser
      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 
      8 #include <map>
      9 #include <set>
     10 
     11 #include "base/strings/string16.h"
     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 //
     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 {
     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 
     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,
    101 
    102   // No new types can be added without a corresponding change to the Autofill
    103   // server.
    104 
    105   MAX_VALID_FIELD_TYPE = 73,
    106 };
    107 
    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_STREET_ADDRESS,
    125   HTML_TYPE_ADDRESS_LINE1,
    126   HTML_TYPE_ADDRESS_LINE2,
    127   HTML_TYPE_LOCALITY,      // For U.S. addresses, corresponds to the city.
    128   HTML_TYPE_REGION,        // For U.S. addresses, corresponds to the state.
    129   HTML_TYPE_COUNTRY_CODE,  // The ISO 3166-1-alpha-2 country code.
    130   HTML_TYPE_COUNTRY_NAME,  // The localized country name.
    131   HTML_TYPE_POSTAL_CODE,
    132 
    133   // Credit card types.
    134   HTML_TYPE_CREDIT_CARD_NAME,
    135   HTML_TYPE_CREDIT_CARD_NUMBER,
    136   HTML_TYPE_CREDIT_CARD_EXP,
    137   HTML_TYPE_CREDIT_CARD_EXP_MONTH,
    138   HTML_TYPE_CREDIT_CARD_EXP_YEAR,
    139   HTML_TYPE_CREDIT_CARD_VERIFICATION_CODE,
    140   HTML_TYPE_CREDIT_CARD_TYPE,
    141 
    142   // Phone number types.
    143   HTML_TYPE_TEL,
    144   HTML_TYPE_TEL_COUNTRY_CODE,
    145   HTML_TYPE_TEL_NATIONAL,
    146   HTML_TYPE_TEL_AREA_CODE,
    147   HTML_TYPE_TEL_LOCAL,
    148   HTML_TYPE_TEL_LOCAL_PREFIX,
    149   HTML_TYPE_TEL_LOCAL_SUFFIX,
    150 
    151   // Email.
    152   HTML_TYPE_EMAIL,
    153 
    154   // Variants of type hints specified in the HTML specification that are
    155   // inferred based on a field's 'maxlength' attribute.
    156   // TODO(isherman): Remove these types, in favor of understanding maxlength
    157   // when filling fields.  See also: AutofillField::phone_part_.
    158   HTML_TYPE_ADDITIONAL_NAME_INITIAL,
    159   HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR,
    160   HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR,
    161   HTML_TYPE_CREDIT_CARD_EXP_2_DIGIT_YEAR,
    162   HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR,
    163 };
    164 
    165 // The list of all HTML autocomplete field mode hints supported by Chrome.
    166 // See [ http://is.gd/whatwg_autocomplete ] for the full list of specced hints.
    167 enum HtmlFieldMode {
    168   HTML_MODE_NONE,
    169   HTML_MODE_BILLING,
    170   HTML_MODE_SHIPPING,
    171 };
    172 
    173 enum FieldTypeGroup {
    174   NO_GROUP,
    175   NAME,
    176   NAME_BILLING,
    177   EMAIL,
    178   COMPANY,
    179   ADDRESS_HOME,
    180   ADDRESS_BILLING,
    181   PHONE_HOME,
    182   PHONE_BILLING,
    183   CREDIT_CARD,
    184 };
    185 
    186 typedef std::set<ServerFieldType> ServerFieldTypeSet;
    187 typedef std::map<base::string16, ServerFieldType> ServerFieldTypeMap;
    188 
    189 }  // namespace autofill
    190 
    191 #endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_FIELD_TYPES_H_
    192