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 except to keep it synchronized with the
     16 // Autofill server's version.  The server aggregates and stores these types over
     17 // several versions, so we must remain fully compatible with the Autofill
     18 // server, which is itself backward-compatible.  The list must be kept up to
     19 // date with the Autofill server list.
     20 //
     21 // The list of all field types natively understood by the Autofill server.  A
     22 // subset of these types is used to store Autofill data in the user's profile.
     23 enum ServerFieldType {
     24   // Server indication that it has no data for the requested field.
     25   NO_SERVER_DATA = 0,
     26   // Client indication that the text entered did not match anything in the
     27   // personal data.
     28   UNKNOWN_TYPE = 1,
     29   // The "empty" type indicates that the user hasn't entered anything
     30   // in this field.
     31   EMPTY_TYPE = 2,
     32   // Personal Information categorization types.
     33   NAME_FIRST = 3,
     34   NAME_MIDDLE = 4,
     35   NAME_LAST = 5,
     36   NAME_MIDDLE_INITIAL = 6,
     37   NAME_FULL = 7,
     38   NAME_SUFFIX = 8,
     39   EMAIL_ADDRESS = 9,
     40   PHONE_HOME_NUMBER = 10,
     41   PHONE_HOME_CITY_CODE = 11,
     42   PHONE_HOME_COUNTRY_CODE = 12,
     43   PHONE_HOME_CITY_AND_NUMBER = 13,
     44   PHONE_HOME_WHOLE_NUMBER = 14,
     45 
     46   // Work phone numbers (values [15,19]) are deprecated.
     47 
     48   // Fax numbers (values [20,24]) are deprecated in Chrome, but still supported
     49   // by the server.
     50   PHONE_FAX_NUMBER = 20,
     51   PHONE_FAX_CITY_CODE = 21,
     52   PHONE_FAX_COUNTRY_CODE = 22,
     53   PHONE_FAX_CITY_AND_NUMBER = 23,
     54   PHONE_FAX_WHOLE_NUMBER = 24,
     55 
     56   // Cell phone numbers (values [25, 29]) are deprecated.
     57 
     58   ADDRESS_HOME_LINE1 = 30,
     59   ADDRESS_HOME_LINE2 = 31,
     60   ADDRESS_HOME_APT_NUM = 32,
     61   ADDRESS_HOME_CITY = 33,
     62   ADDRESS_HOME_STATE = 34,
     63   ADDRESS_HOME_ZIP = 35,
     64   ADDRESS_HOME_COUNTRY = 36,
     65   ADDRESS_BILLING_LINE1 = 37,
     66   ADDRESS_BILLING_LINE2 = 38,
     67   ADDRESS_BILLING_APT_NUM = 39,
     68   ADDRESS_BILLING_CITY = 40,
     69   ADDRESS_BILLING_STATE = 41,
     70   ADDRESS_BILLING_ZIP = 42,
     71   ADDRESS_BILLING_COUNTRY = 43,
     72 
     73   // ADDRESS_SHIPPING values [44,50] are deprecated.
     74 
     75   CREDIT_CARD_NAME = 51,
     76   CREDIT_CARD_NUMBER = 52,
     77   CREDIT_CARD_EXP_MONTH = 53,
     78   CREDIT_CARD_EXP_2_DIGIT_YEAR = 54,
     79   CREDIT_CARD_EXP_4_DIGIT_YEAR = 55,
     80   CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR = 56,
     81   CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR = 57,
     82   CREDIT_CARD_TYPE = 58,
     83   CREDIT_CARD_VERIFICATION_CODE = 59,
     84 
     85   COMPANY_NAME = 60,
     86 
     87   // Generic type whose default value is known.
     88   FIELD_WITH_DEFAULT_VALUE = 61,
     89 
     90   PHONE_BILLING_NUMBER = 62,
     91   PHONE_BILLING_CITY_CODE = 63,
     92   PHONE_BILLING_COUNTRY_CODE = 64,
     93   PHONE_BILLING_CITY_AND_NUMBER = 65,
     94   PHONE_BILLING_WHOLE_NUMBER = 66,
     95 
     96   NAME_BILLING_FIRST = 67,
     97   NAME_BILLING_MIDDLE = 68,
     98   NAME_BILLING_LAST = 69,
     99   NAME_BILLING_MIDDLE_INITIAL = 70,
    100   NAME_BILLING_FULL = 71,
    101   NAME_BILLING_SUFFIX = 72,
    102 
    103   // Field types for options generally found in merchant buyflows. Given that
    104   // these are likely to be filled out differently on a case by case basis,
    105   // they are here primarily for use by Autocheckout.
    106   MERCHANT_EMAIL_SIGNUP = 73,
    107   MERCHANT_PROMO_CODE = 74,
    108 
    109   // Field types for the password fields. PASSWORD is the default type for all
    110   // password fields. ACCOUNT_CREATION_PASSWORD is the first password field in
    111   // an account creation form and will trigger password generation.
    112   PASSWORD = 75,
    113   ACCOUNT_CREATION_PASSWORD = 76,
    114 
    115   // Includes all of the lines of a street address, including newlines, e.g.
    116   //   123 Main Street,
    117   //   Apt. #42
    118   ADDRESS_HOME_STREET_ADDRESS = 77,
    119   ADDRESS_BILLING_STREET_ADDRESS = 78,
    120 
    121   // A sorting code is similar to a postal code. However, whereas a postal code
    122   // normally refers to a single geographical location, a sorting code often
    123   // does not. Instead, a sorting code is assigned to an organization, which
    124   // might be geographically distributed. The most prominent example of a
    125   // sorting code system is CEDEX in France.
    126   ADDRESS_HOME_SORTING_CODE = 79,
    127   ADDRESS_BILLING_SORTING_CODE = 80,
    128 
    129   // A dependent locality is a subunit of a locality, where a "locality" is
    130   // roughly equivalent to a city. Examples of dependent localities include
    131   // inner-city districts and suburbs.
    132   ADDRESS_HOME_DEPENDENT_LOCALITY = 81,
    133   ADDRESS_BILLING_DEPENDENT_LOCALITY = 82,
    134 
    135   // No new types can be added without a corresponding change to the Autofill
    136   // server.
    137 
    138   MAX_VALID_FIELD_TYPE = 83,
    139 };
    140 
    141 // The list of all HTML autocomplete field type hints supported by Chrome.
    142 // See [ http://is.gd/whatwg_autocomplete ] for the full list of specced hints.
    143 enum HtmlFieldType {
    144   // Default type.
    145   HTML_TYPE_UNKNOWN,
    146 
    147   // Name types.
    148   HTML_TYPE_NAME,
    149   HTML_TYPE_GIVEN_NAME,
    150   HTML_TYPE_ADDITIONAL_NAME,
    151   HTML_TYPE_FAMILY_NAME,
    152 
    153   // Business types.
    154   HTML_TYPE_ORGANIZATION,
    155 
    156   // Address types.
    157   HTML_TYPE_STREET_ADDRESS,
    158   HTML_TYPE_ADDRESS_LINE1,
    159   HTML_TYPE_ADDRESS_LINE2,
    160   HTML_TYPE_LOCALITY,      // For U.S. addresses, corresponds to the city.
    161   HTML_TYPE_REGION,        // For U.S. addresses, corresponds to the state.
    162   HTML_TYPE_COUNTRY_CODE,  // The ISO 3166-1-alpha-2 country code.
    163   HTML_TYPE_COUNTRY_NAME,  // The localized country name.
    164   HTML_TYPE_POSTAL_CODE,
    165 
    166   // Credit card types.
    167   HTML_TYPE_CREDIT_CARD_NAME,
    168   HTML_TYPE_CREDIT_CARD_NUMBER,
    169   HTML_TYPE_CREDIT_CARD_EXP,
    170   HTML_TYPE_CREDIT_CARD_EXP_MONTH,
    171   HTML_TYPE_CREDIT_CARD_EXP_YEAR,
    172   HTML_TYPE_CREDIT_CARD_VERIFICATION_CODE,
    173   HTML_TYPE_CREDIT_CARD_TYPE,
    174 
    175   // Phone number types.
    176   HTML_TYPE_TEL,
    177   HTML_TYPE_TEL_COUNTRY_CODE,
    178   HTML_TYPE_TEL_NATIONAL,
    179   HTML_TYPE_TEL_AREA_CODE,
    180   HTML_TYPE_TEL_LOCAL,
    181   HTML_TYPE_TEL_LOCAL_PREFIX,
    182   HTML_TYPE_TEL_LOCAL_SUFFIX,
    183 
    184   // Email.
    185   HTML_TYPE_EMAIL,
    186 
    187   // Variants of type hints specified in the HTML specification that are
    188   // inferred based on a field's 'maxlength' attribute.
    189   // TODO(isherman): Remove these types, in favor of understanding maxlength
    190   // when filling fields.  See also: AutofillField::phone_part_.
    191   HTML_TYPE_ADDITIONAL_NAME_INITIAL,
    192   HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR,
    193   HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR,
    194   HTML_TYPE_CREDIT_CARD_EXP_2_DIGIT_YEAR,
    195   HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR,
    196 };
    197 
    198 // The list of all HTML autocomplete field mode hints supported by Chrome.
    199 // See [ http://is.gd/whatwg_autocomplete ] for the full list of specced hints.
    200 enum HtmlFieldMode {
    201   HTML_MODE_NONE,
    202   HTML_MODE_BILLING,
    203   HTML_MODE_SHIPPING,
    204 };
    205 
    206 enum FieldTypeGroup {
    207   NO_GROUP,
    208   NAME,
    209   NAME_BILLING,
    210   EMAIL,
    211   COMPANY,
    212   ADDRESS_HOME,
    213   ADDRESS_BILLING,
    214   PHONE_HOME,
    215   PHONE_BILLING,
    216   CREDIT_CARD,
    217   PASSWORD_FIELD,
    218 };
    219 
    220 typedef std::set<ServerFieldType> ServerFieldTypeSet;
    221 typedef std::map<base::string16, ServerFieldType> ServerFieldTypeMap;
    222 
    223 }  // namespace autofill
    224 
    225 #endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_FIELD_TYPES_H_
    226