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