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 #include "components/autofill/core/browser/autofill_type.h"
      6 
      7 #include "base/logging.h"
      8 
      9 namespace autofill {
     10 
     11 AutofillType::AutofillType(ServerFieldType field_type)
     12     : html_type_(HTML_TYPE_UNKNOWN),
     13       html_mode_(HTML_MODE_NONE) {
     14   if ((field_type < NO_SERVER_DATA || field_type >= MAX_VALID_FIELD_TYPE) ||
     15       (field_type >= 15 && field_type <= 19) ||
     16       (field_type >= 25 && field_type <= 29) ||
     17       (field_type >= 44 && field_type <= 50)) {
     18     server_type_ = UNKNOWN_TYPE;
     19   } else {
     20     server_type_ = field_type;
     21   }
     22 }
     23 
     24 AutofillType::AutofillType(HtmlFieldType field_type, HtmlFieldMode mode)
     25     : server_type_(UNKNOWN_TYPE),
     26       html_type_(field_type),
     27       html_mode_(mode) {}
     28 
     29 
     30 AutofillType::AutofillType(const AutofillType& autofill_type) {
     31   *this = autofill_type;
     32 }
     33 
     34 AutofillType& AutofillType::operator=(const AutofillType& autofill_type) {
     35   if (this != &autofill_type) {
     36     this->server_type_ = autofill_type.server_type_;
     37     this->html_type_ = autofill_type.html_type_;
     38     this->html_mode_ = autofill_type.html_mode_;
     39   }
     40 
     41   return *this;
     42 }
     43 
     44 FieldTypeGroup AutofillType::group() const {
     45   switch (server_type_) {
     46     case NAME_FIRST:
     47     case NAME_MIDDLE:
     48     case NAME_LAST:
     49     case NAME_MIDDLE_INITIAL:
     50     case NAME_FULL:
     51     case NAME_SUFFIX:
     52       return NAME;
     53 
     54     case NAME_BILLING_FIRST:
     55     case NAME_BILLING_MIDDLE:
     56     case NAME_BILLING_LAST:
     57     case NAME_BILLING_MIDDLE_INITIAL:
     58     case NAME_BILLING_FULL:
     59     case NAME_BILLING_SUFFIX:
     60       return NAME_BILLING;
     61 
     62     case EMAIL_ADDRESS:
     63       return EMAIL;
     64 
     65     case PHONE_HOME_NUMBER:
     66     case PHONE_HOME_CITY_CODE:
     67     case PHONE_HOME_COUNTRY_CODE:
     68     case PHONE_HOME_CITY_AND_NUMBER:
     69     case PHONE_HOME_WHOLE_NUMBER:
     70       return PHONE_HOME;
     71 
     72     case PHONE_BILLING_NUMBER:
     73     case PHONE_BILLING_CITY_CODE:
     74     case PHONE_BILLING_COUNTRY_CODE:
     75     case PHONE_BILLING_CITY_AND_NUMBER:
     76     case PHONE_BILLING_WHOLE_NUMBER:
     77       return PHONE_BILLING;
     78 
     79     case ADDRESS_HOME_LINE1:
     80     case ADDRESS_HOME_LINE2:
     81     case ADDRESS_HOME_APT_NUM:
     82     case ADDRESS_HOME_CITY:
     83     case ADDRESS_HOME_STATE:
     84     case ADDRESS_HOME_ZIP:
     85     case ADDRESS_HOME_COUNTRY:
     86     case ADDRESS_HOME_STREET_ADDRESS:
     87     case ADDRESS_HOME_SORTING_CODE:
     88     case ADDRESS_HOME_DEPENDENT_LOCALITY:
     89       return ADDRESS_HOME;
     90 
     91     case ADDRESS_BILLING_LINE1:
     92     case ADDRESS_BILLING_LINE2:
     93     case ADDRESS_BILLING_APT_NUM:
     94     case ADDRESS_BILLING_CITY:
     95     case ADDRESS_BILLING_STATE:
     96     case ADDRESS_BILLING_ZIP:
     97     case ADDRESS_BILLING_COUNTRY:
     98     case ADDRESS_BILLING_STREET_ADDRESS:
     99     case ADDRESS_BILLING_SORTING_CODE:
    100     case ADDRESS_BILLING_DEPENDENT_LOCALITY:
    101       return ADDRESS_BILLING;
    102 
    103     case CREDIT_CARD_NAME:
    104     case CREDIT_CARD_NUMBER:
    105     case CREDIT_CARD_EXP_MONTH:
    106     case CREDIT_CARD_EXP_2_DIGIT_YEAR:
    107     case CREDIT_CARD_EXP_4_DIGIT_YEAR:
    108     case CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR:
    109     case CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR:
    110     case CREDIT_CARD_TYPE:
    111     case CREDIT_CARD_VERIFICATION_CODE:
    112       return CREDIT_CARD;
    113 
    114     case COMPANY_NAME:
    115       return COMPANY;
    116 
    117     case PASSWORD:
    118     case ACCOUNT_CREATION_PASSWORD:
    119       return PASSWORD_FIELD;
    120 
    121     case NO_SERVER_DATA:
    122     case EMPTY_TYPE:
    123     case PHONE_FAX_NUMBER:
    124     case PHONE_FAX_CITY_CODE:
    125     case PHONE_FAX_COUNTRY_CODE:
    126     case PHONE_FAX_CITY_AND_NUMBER:
    127     case PHONE_FAX_WHOLE_NUMBER:
    128     case FIELD_WITH_DEFAULT_VALUE:
    129     case MERCHANT_EMAIL_SIGNUP:
    130     case MERCHANT_PROMO_CODE:
    131       return NO_GROUP;
    132 
    133     case MAX_VALID_FIELD_TYPE:
    134       NOTREACHED();
    135       return NO_GROUP;
    136 
    137     case UNKNOWN_TYPE:
    138       break;
    139   }
    140 
    141   switch (html_type_) {
    142     case HTML_TYPE_NAME:
    143     case HTML_TYPE_GIVEN_NAME:
    144     case HTML_TYPE_ADDITIONAL_NAME:
    145     case HTML_TYPE_ADDITIONAL_NAME_INITIAL:
    146     case HTML_TYPE_FAMILY_NAME:
    147       return html_mode_ == HTML_MODE_BILLING ? NAME_BILLING : NAME;
    148 
    149     case HTML_TYPE_ORGANIZATION:
    150       return COMPANY;
    151 
    152     case HTML_TYPE_STREET_ADDRESS:
    153     case HTML_TYPE_ADDRESS_LINE1:
    154     case HTML_TYPE_ADDRESS_LINE2:
    155     case HTML_TYPE_LOCALITY:
    156     case HTML_TYPE_REGION:
    157     case HTML_TYPE_COUNTRY_CODE:
    158     case HTML_TYPE_COUNTRY_NAME:
    159     case HTML_TYPE_POSTAL_CODE:
    160       return html_mode_ == HTML_MODE_BILLING ? ADDRESS_BILLING : ADDRESS_HOME;
    161 
    162     case HTML_TYPE_CREDIT_CARD_NAME:
    163     case HTML_TYPE_CREDIT_CARD_NUMBER:
    164     case HTML_TYPE_CREDIT_CARD_EXP:
    165     case HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR:
    166     case HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR:
    167     case HTML_TYPE_CREDIT_CARD_EXP_MONTH:
    168     case HTML_TYPE_CREDIT_CARD_EXP_YEAR:
    169     case HTML_TYPE_CREDIT_CARD_EXP_2_DIGIT_YEAR:
    170     case HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR:
    171     case HTML_TYPE_CREDIT_CARD_VERIFICATION_CODE:
    172     case HTML_TYPE_CREDIT_CARD_TYPE:
    173       return CREDIT_CARD;
    174 
    175     case HTML_TYPE_TEL:
    176     case HTML_TYPE_TEL_COUNTRY_CODE:
    177     case HTML_TYPE_TEL_NATIONAL:
    178     case HTML_TYPE_TEL_AREA_CODE:
    179     case HTML_TYPE_TEL_LOCAL:
    180     case HTML_TYPE_TEL_LOCAL_PREFIX:
    181     case HTML_TYPE_TEL_LOCAL_SUFFIX:
    182       return html_mode_ == HTML_MODE_BILLING ? PHONE_BILLING : PHONE_HOME;
    183 
    184     case HTML_TYPE_EMAIL:
    185       return EMAIL;
    186 
    187     case HTML_TYPE_UNKNOWN:
    188       break;
    189   }
    190 
    191   return NO_GROUP;
    192 }
    193 
    194 bool AutofillType::IsUnknown() const {
    195   return server_type_ == UNKNOWN_TYPE && html_type_ == HTML_TYPE_UNKNOWN;
    196 }
    197 
    198 ServerFieldType AutofillType::GetStorableType() const {
    199   // Map billing types to the equivalent non-billing types.
    200   switch (server_type_) {
    201     case ADDRESS_BILLING_LINE1:
    202       return ADDRESS_HOME_LINE1;
    203 
    204     case ADDRESS_BILLING_LINE2:
    205       return ADDRESS_HOME_LINE2;
    206 
    207     case ADDRESS_BILLING_APT_NUM:
    208       return ADDRESS_HOME_APT_NUM;
    209 
    210     case ADDRESS_BILLING_CITY:
    211       return ADDRESS_HOME_CITY;
    212 
    213     case ADDRESS_BILLING_STATE:
    214       return ADDRESS_HOME_STATE;
    215 
    216     case ADDRESS_BILLING_ZIP:
    217       return ADDRESS_HOME_ZIP;
    218 
    219     case ADDRESS_BILLING_COUNTRY:
    220       return ADDRESS_HOME_COUNTRY;
    221 
    222     case PHONE_BILLING_WHOLE_NUMBER:
    223       return PHONE_HOME_WHOLE_NUMBER;
    224 
    225     case PHONE_BILLING_NUMBER:
    226       return PHONE_HOME_NUMBER;
    227 
    228     case PHONE_BILLING_CITY_CODE:
    229       return PHONE_HOME_CITY_CODE;
    230 
    231     case PHONE_BILLING_COUNTRY_CODE:
    232       return PHONE_HOME_COUNTRY_CODE;
    233 
    234     case PHONE_BILLING_CITY_AND_NUMBER:
    235       return PHONE_HOME_CITY_AND_NUMBER;
    236 
    237     case NAME_BILLING_FIRST:
    238       return NAME_FIRST;
    239 
    240     case NAME_BILLING_MIDDLE:
    241       return NAME_MIDDLE;
    242 
    243     case NAME_BILLING_LAST:
    244       return NAME_LAST;
    245 
    246     case NAME_BILLING_MIDDLE_INITIAL:
    247       return NAME_MIDDLE_INITIAL;
    248 
    249     case NAME_BILLING_FULL:
    250       return NAME_FULL;
    251 
    252     case NAME_BILLING_SUFFIX:
    253       return NAME_SUFFIX;
    254 
    255     case ADDRESS_BILLING_STREET_ADDRESS:
    256       return ADDRESS_HOME_STREET_ADDRESS;
    257 
    258     case ADDRESS_BILLING_SORTING_CODE:
    259       return ADDRESS_HOME_SORTING_CODE;
    260 
    261     case ADDRESS_BILLING_DEPENDENT_LOCALITY:
    262       return ADDRESS_HOME_DEPENDENT_LOCALITY;
    263 
    264     case UNKNOWN_TYPE:
    265       break;  // Try to parse HTML types instead.
    266 
    267     default:
    268       return server_type_;
    269   }
    270 
    271   switch (html_type_) {
    272     case HTML_TYPE_UNKNOWN:
    273       return UNKNOWN_TYPE;
    274 
    275     case HTML_TYPE_NAME:
    276       return NAME_FULL;
    277 
    278     case HTML_TYPE_GIVEN_NAME:
    279       return NAME_FIRST;
    280 
    281     case HTML_TYPE_ADDITIONAL_NAME:
    282       return NAME_MIDDLE;
    283 
    284     case HTML_TYPE_FAMILY_NAME:
    285       return NAME_LAST;
    286 
    287     case HTML_TYPE_ORGANIZATION:
    288       return COMPANY_NAME;
    289 
    290     case HTML_TYPE_STREET_ADDRESS:
    291       return ADDRESS_HOME_STREET_ADDRESS;
    292 
    293     case HTML_TYPE_ADDRESS_LINE1:
    294       return ADDRESS_HOME_LINE1;
    295 
    296     case HTML_TYPE_ADDRESS_LINE2:
    297       return ADDRESS_HOME_LINE2;
    298 
    299     case HTML_TYPE_LOCALITY:
    300       return ADDRESS_HOME_CITY;
    301 
    302     case HTML_TYPE_REGION:
    303       return ADDRESS_HOME_STATE;
    304 
    305     case HTML_TYPE_COUNTRY_CODE:
    306     case HTML_TYPE_COUNTRY_NAME:
    307       return ADDRESS_HOME_COUNTRY;
    308 
    309     case HTML_TYPE_POSTAL_CODE:
    310       return ADDRESS_HOME_ZIP;
    311 
    312     case HTML_TYPE_CREDIT_CARD_NAME:
    313       return CREDIT_CARD_NAME;
    314 
    315     case HTML_TYPE_CREDIT_CARD_NUMBER:
    316       return CREDIT_CARD_NUMBER;
    317 
    318     case HTML_TYPE_CREDIT_CARD_EXP:
    319       return CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR;
    320 
    321     case HTML_TYPE_CREDIT_CARD_EXP_MONTH:
    322       return CREDIT_CARD_EXP_MONTH;
    323 
    324     case HTML_TYPE_CREDIT_CARD_EXP_YEAR:
    325       return CREDIT_CARD_EXP_4_DIGIT_YEAR;
    326 
    327     case HTML_TYPE_CREDIT_CARD_VERIFICATION_CODE:
    328       return CREDIT_CARD_VERIFICATION_CODE;
    329 
    330     case HTML_TYPE_CREDIT_CARD_TYPE:
    331       return CREDIT_CARD_TYPE;
    332 
    333     case HTML_TYPE_TEL:
    334       return PHONE_HOME_WHOLE_NUMBER;
    335 
    336     case HTML_TYPE_TEL_COUNTRY_CODE:
    337       return PHONE_HOME_COUNTRY_CODE;
    338 
    339     case HTML_TYPE_TEL_NATIONAL:
    340       return PHONE_HOME_CITY_AND_NUMBER;
    341 
    342     case HTML_TYPE_TEL_AREA_CODE:
    343       return PHONE_HOME_CITY_CODE;
    344 
    345     case HTML_TYPE_TEL_LOCAL:
    346     case HTML_TYPE_TEL_LOCAL_PREFIX:
    347     case HTML_TYPE_TEL_LOCAL_SUFFIX:
    348       return PHONE_HOME_NUMBER;
    349 
    350     case HTML_TYPE_EMAIL:
    351       return EMAIL_ADDRESS;
    352 
    353     case HTML_TYPE_ADDITIONAL_NAME_INITIAL:
    354       return NAME_MIDDLE_INITIAL;
    355 
    356     case HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR:
    357       return CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR;
    358 
    359     case HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR:
    360       return CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR;
    361 
    362     case HTML_TYPE_CREDIT_CARD_EXP_2_DIGIT_YEAR:
    363       return CREDIT_CARD_EXP_2_DIGIT_YEAR;
    364 
    365     case HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR:
    366       return CREDIT_CARD_EXP_4_DIGIT_YEAR;
    367   }
    368 
    369   NOTREACHED();
    370   return UNKNOWN_TYPE;
    371 }
    372 
    373 // static
    374 ServerFieldType AutofillType::GetEquivalentBillingFieldType(
    375     ServerFieldType field_type) {
    376   switch (field_type) {
    377     case ADDRESS_HOME_LINE1:
    378       return ADDRESS_BILLING_LINE1;
    379 
    380     case ADDRESS_HOME_LINE2:
    381       return ADDRESS_BILLING_LINE2;
    382 
    383     case ADDRESS_HOME_APT_NUM:
    384       return ADDRESS_BILLING_APT_NUM;
    385 
    386     case ADDRESS_HOME_CITY:
    387       return ADDRESS_BILLING_CITY;
    388 
    389     case ADDRESS_HOME_STATE:
    390       return ADDRESS_BILLING_STATE;
    391 
    392     case ADDRESS_HOME_ZIP:
    393       return ADDRESS_BILLING_ZIP;
    394 
    395     case ADDRESS_HOME_COUNTRY:
    396       return ADDRESS_BILLING_COUNTRY;
    397 
    398     case ADDRESS_HOME_STREET_ADDRESS:
    399       return ADDRESS_BILLING_STREET_ADDRESS;
    400 
    401     case ADDRESS_HOME_SORTING_CODE:
    402       return ADDRESS_BILLING_SORTING_CODE;
    403 
    404     case ADDRESS_HOME_DEPENDENT_LOCALITY:
    405       return ADDRESS_BILLING_DEPENDENT_LOCALITY;
    406 
    407     case PHONE_HOME_WHOLE_NUMBER:
    408       return PHONE_BILLING_WHOLE_NUMBER;
    409 
    410     case PHONE_HOME_NUMBER:
    411       return PHONE_BILLING_NUMBER;
    412 
    413     case PHONE_HOME_CITY_CODE:
    414       return PHONE_BILLING_CITY_CODE;
    415 
    416     case PHONE_HOME_COUNTRY_CODE:
    417       return PHONE_BILLING_COUNTRY_CODE;
    418 
    419     case PHONE_HOME_CITY_AND_NUMBER:
    420       return PHONE_BILLING_CITY_AND_NUMBER;
    421 
    422     case NAME_FIRST:
    423       return NAME_BILLING_FIRST;
    424 
    425     case NAME_MIDDLE:
    426       return NAME_BILLING_MIDDLE;
    427 
    428     case NAME_LAST:
    429       return NAME_BILLING_LAST;
    430 
    431     case NAME_MIDDLE_INITIAL:
    432       return NAME_BILLING_MIDDLE_INITIAL;
    433 
    434     case NAME_FULL:
    435       return NAME_BILLING_FULL;
    436 
    437     case NAME_SUFFIX:
    438       return NAME_BILLING_SUFFIX;
    439 
    440     default:
    441       return field_type;
    442   }
    443 }
    444 
    445 std::string AutofillType::ToString() const {
    446   if (IsUnknown())
    447     return "UNKNOWN_TYPE";
    448 
    449   switch (server_type_) {
    450     case NO_SERVER_DATA:
    451       return "NO_SERVER_DATA";
    452     case UNKNOWN_TYPE:
    453       break;  // Should be handled in the HTML type handling code below.
    454     case EMPTY_TYPE:
    455       return "EMPTY_TYPE";
    456     case NAME_FIRST:
    457       return "NAME_FIRST";
    458     case NAME_MIDDLE:
    459       return "NAME_MIDDLE";
    460     case NAME_LAST:
    461       return "NAME_LAST";
    462     case NAME_MIDDLE_INITIAL:
    463       return "NAME_MIDDLE_INITIAL";
    464     case NAME_FULL:
    465       return "NAME_FULL";
    466     case NAME_SUFFIX:
    467       return "NAME_SUFFIX";
    468     case NAME_BILLING_FIRST:
    469       return "NAME_BILLING_FIRST";
    470     case NAME_BILLING_MIDDLE:
    471       return "NAME_BILLING_MIDDLE";
    472     case NAME_BILLING_LAST:
    473       return "NAME_BILLING_LAST";
    474     case NAME_BILLING_MIDDLE_INITIAL:
    475       return "NAME_BILLING_MIDDLE_INITIAL";
    476     case NAME_BILLING_FULL:
    477       return "NAME_BILLING_FULL";
    478     case NAME_BILLING_SUFFIX:
    479       return "NAME_BILLING_SUFFIX";
    480     case EMAIL_ADDRESS:
    481       return "EMAIL_ADDRESS";
    482     case PHONE_HOME_NUMBER:
    483       return "PHONE_HOME_NUMBER";
    484     case PHONE_HOME_CITY_CODE:
    485       return "PHONE_HOME_CITY_CODE";
    486     case PHONE_HOME_COUNTRY_CODE:
    487       return "PHONE_HOME_COUNTRY_CODE";
    488     case PHONE_HOME_CITY_AND_NUMBER:
    489       return "PHONE_HOME_CITY_AND_NUMBER";
    490     case PHONE_HOME_WHOLE_NUMBER:
    491       return "PHONE_HOME_WHOLE_NUMBER";
    492     case PHONE_FAX_NUMBER:
    493       return "PHONE_FAX_NUMBER";
    494     case PHONE_FAX_CITY_CODE:
    495       return "PHONE_FAX_CITY_CODE";
    496     case PHONE_FAX_COUNTRY_CODE:
    497       return "PHONE_FAX_COUNTRY_CODE";
    498     case PHONE_FAX_CITY_AND_NUMBER:
    499       return "PHONE_FAX_CITY_AND_NUMBER";
    500     case PHONE_FAX_WHOLE_NUMBER:
    501       return "PHONE_FAX_WHOLE_NUMBER";
    502     case ADDRESS_HOME_LINE1:
    503       return "ADDRESS_HOME_LINE1";
    504     case ADDRESS_HOME_LINE2:
    505       return "ADDRESS_HOME_LINE2";
    506     case ADDRESS_HOME_APT_NUM:
    507       return "ADDRESS_HOME_APT_NUM";
    508     case ADDRESS_HOME_CITY:
    509       return "ADDRESS_HOME_CITY";
    510     case ADDRESS_HOME_STATE:
    511       return "ADDRESS_HOME_STATE";
    512     case ADDRESS_HOME_ZIP:
    513       return "ADDRESS_HOME_ZIP";
    514     case ADDRESS_HOME_COUNTRY:
    515       return "ADDRESS_HOME_COUNTRY";
    516     case ADDRESS_BILLING_LINE1:
    517       return "ADDRESS_BILLING_LINE1";
    518     case ADDRESS_BILLING_LINE2:
    519       return "ADDRESS_BILLING_LINE2";
    520     case ADDRESS_BILLING_APT_NUM:
    521       return "ADDRESS_BILLING_APT_NUM";
    522     case ADDRESS_BILLING_CITY:
    523       return "ADDRESS_BILLING_CITY";
    524     case ADDRESS_BILLING_STATE:
    525       return "ADDRESS_BILLING_STATE";
    526     case ADDRESS_BILLING_ZIP:
    527       return "ADDRESS_BILLING_ZIP";
    528     case ADDRESS_BILLING_COUNTRY:
    529       return "ADDRESS_BILLING_COUNTRY";
    530     case CREDIT_CARD_NAME:
    531       return "CREDIT_CARD_NAME";
    532     case CREDIT_CARD_NUMBER:
    533       return "CREDIT_CARD_NUMBER";
    534     case CREDIT_CARD_EXP_MONTH:
    535       return "CREDIT_CARD_EXP_MONTH";
    536     case CREDIT_CARD_EXP_2_DIGIT_YEAR:
    537       return "CREDIT_CARD_EXP_2_DIGIT_YEAR";
    538     case CREDIT_CARD_EXP_4_DIGIT_YEAR:
    539       return "CREDIT_CARD_EXP_4_DIGIT_YEAR";
    540     case CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR:
    541       return "CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR";
    542     case CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR:
    543       return "CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR";
    544     case CREDIT_CARD_TYPE:
    545       return "CREDIT_CARD_TYPE";
    546     case CREDIT_CARD_VERIFICATION_CODE:
    547       return "CREDIT_CARD_VERIFICATION_CODE";
    548     case COMPANY_NAME:
    549       return "COMPANY_NAME";
    550     case FIELD_WITH_DEFAULT_VALUE:
    551       return "FIELD_WITH_DEFAULT_VALUE";
    552     case PHONE_BILLING_NUMBER:
    553       return "PHONE_BILLING_NUMBER";
    554     case PHONE_BILLING_CITY_CODE:
    555       return "PHONE_BILLING_CITY_CODE";
    556     case PHONE_BILLING_COUNTRY_CODE:
    557       return "PHONE_BILLING_COUNTRY_CODE";
    558     case PHONE_BILLING_CITY_AND_NUMBER:
    559       return "PHONE_BILLING_CITY_AND_NUMBER";
    560     case PHONE_BILLING_WHOLE_NUMBER:
    561       return "PHONE_BILLING_WHOLE_NUMBER";
    562     case MERCHANT_EMAIL_SIGNUP:
    563       return "MERCHANT_EMAIL_SIGNUP";
    564     case MERCHANT_PROMO_CODE:
    565       return "MERCHANT_PROMO_CODE";
    566     case PASSWORD:
    567       return "PASSWORD";
    568     case ACCOUNT_CREATION_PASSWORD:
    569       return "ACCOUNT_CREATION_PASSWORD";
    570     case ADDRESS_HOME_STREET_ADDRESS:
    571       return "ADDRESS_HOME_STREET_ADDRESS";
    572     case ADDRESS_BILLING_STREET_ADDRESS:
    573       return "ADDRESS_BILLING_STREET_ADDRESS";
    574     case ADDRESS_HOME_SORTING_CODE:
    575       return "ADDRESS_HOME_SORTING_CODE";
    576     case ADDRESS_BILLING_SORTING_CODE:
    577       return "ADDRESS_BILLING_SORTING_CODE";
    578     case ADDRESS_HOME_DEPENDENT_LOCALITY:
    579       return "ADDRESS_HOME_DEPENDENT_LOCALITY";
    580     case ADDRESS_BILLING_DEPENDENT_LOCALITY:
    581       return "ADDRESS_BILLING_DEPENDENT_LOCALITY";
    582 
    583     case MAX_VALID_FIELD_TYPE:
    584       return std::string();
    585   }
    586 
    587   switch (html_type_) {
    588     case HTML_TYPE_UNKNOWN:
    589       NOTREACHED();
    590       break;
    591     case HTML_TYPE_NAME:
    592       return "HTML_TYPE_NAME";
    593     case HTML_TYPE_GIVEN_NAME:
    594       return "HTML_TYPE_GIVEN_NAME";
    595     case HTML_TYPE_ADDITIONAL_NAME:
    596       return "HTML_TYPE_ADDITIONAL_NAME";
    597     case HTML_TYPE_FAMILY_NAME:
    598       return "HTML_TYPE_FAMILY_NAME";
    599     case HTML_TYPE_ORGANIZATION:
    600       return "HTML_TYPE_ORGANIZATION";
    601     case HTML_TYPE_STREET_ADDRESS:
    602       return "HTML_TYPE_STREET_ADDRESS";
    603     case HTML_TYPE_ADDRESS_LINE1:
    604       return "HTML_TYPE_ADDRESS_LINE1";
    605     case HTML_TYPE_ADDRESS_LINE2:
    606       return "HTML_TYPE_ADDRESS_LINE2";
    607     case HTML_TYPE_LOCALITY:
    608       return "HTML_TYPE_LOCALITY";
    609     case HTML_TYPE_REGION:
    610       return "HTML_TYPE_REGION";
    611     case HTML_TYPE_COUNTRY_CODE:
    612       return "HTML_TYPE_COUNTRY_CODE";
    613     case HTML_TYPE_COUNTRY_NAME:
    614       return "HTML_TYPE_COUNTRY_NAME";
    615     case HTML_TYPE_POSTAL_CODE:
    616       return "HTML_TYPE_POSTAL_CODE";
    617     case HTML_TYPE_CREDIT_CARD_NAME:
    618       return "HTML_TYPE_CREDIT_CARD_NAME";
    619     case HTML_TYPE_CREDIT_CARD_NUMBER:
    620       return "HTML_TYPE_CREDIT_CARD_NUMBER";
    621     case HTML_TYPE_CREDIT_CARD_EXP:
    622       return "HTML_TYPE_CREDIT_CARD_EXP";
    623     case HTML_TYPE_CREDIT_CARD_EXP_MONTH:
    624       return "HTML_TYPE_CREDIT_CARD_EXP_MONTH";
    625     case HTML_TYPE_CREDIT_CARD_EXP_YEAR:
    626       return "HTML_TYPE_CREDIT_CARD_EXP_YEAR";
    627     case HTML_TYPE_CREDIT_CARD_VERIFICATION_CODE:
    628       return "HTML_TYPE_CREDIT_CARD_VERIFICATION_CODE";
    629     case HTML_TYPE_CREDIT_CARD_TYPE:
    630       return "HTML_TYPE_CREDIT_CARD_TYPE";
    631     case HTML_TYPE_TEL:
    632       return "HTML_TYPE_TEL";
    633     case HTML_TYPE_TEL_COUNTRY_CODE:
    634       return "HTML_TYPE_TEL_COUNTRY_CODE";
    635     case HTML_TYPE_TEL_NATIONAL:
    636       return "HTML_TYPE_TEL_NATIONAL";
    637     case HTML_TYPE_TEL_AREA_CODE:
    638       return "HTML_TYPE_TEL_AREA_CODE";
    639     case HTML_TYPE_TEL_LOCAL:
    640       return "HTML_TYPE_TEL_LOCAL";
    641     case HTML_TYPE_TEL_LOCAL_PREFIX:
    642       return "HTML_TYPE_TEL_LOCAL_PREFIX";
    643     case HTML_TYPE_TEL_LOCAL_SUFFIX:
    644       return "HTML_TYPE_TEL_LOCAL_SUFFIX";
    645     case HTML_TYPE_EMAIL:
    646       return "HTML_TYPE_EMAIL";
    647     case HTML_TYPE_ADDITIONAL_NAME_INITIAL:
    648       return "HTML_TYPE_ADDITIONAL_NAME_INITIAL";
    649     case HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR:
    650       return "HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR";
    651     case HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR:
    652       return "HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR";
    653     case HTML_TYPE_CREDIT_CARD_EXP_2_DIGIT_YEAR:
    654       return "HTML_TYPE_CREDIT_CARD_EXP_2_DIGIT_YEAR";
    655     case HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR:
    656       return "HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR";
    657   }
    658 
    659   NOTREACHED();
    660   return std::string();
    661 }
    662 
    663 }  // namespace autofill
    664