OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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_BROWSER_AUTOFILL_TYPE_H_ | |
6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_TYPE_H_ | |
7 | |
8 #include <map> | |
9 #include <set> | |
10 #include <string> | |
11 | |
12 #include "base/strings/string16.h" | |
13 #include "components/autofill/browser/field_types.h" | |
14 | |
15 namespace autofill { | |
16 | |
17 // The high-level description of Autofill types, used to categorize form fields | |
18 // and for associating form fields with form values in the Web Database. | |
19 class AutofillType { | |
20 public: | |
21 enum FieldTypeGroup { | |
22 NO_GROUP, | |
23 NAME, | |
24 EMAIL, | |
25 COMPANY, | |
26 ADDRESS_HOME, | |
27 ADDRESS_BILLING, | |
28 PHONE_HOME, | |
29 PHONE_BILLING, | |
30 CREDIT_CARD, | |
31 }; | |
32 | |
33 explicit AutofillType(AutofillFieldType field_type); | |
34 AutofillType(const AutofillType& autofill_type); | |
35 AutofillType& operator=(const AutofillType& autofill_type); | |
36 | |
37 AutofillFieldType field_type() const; | |
38 FieldTypeGroup group() const; | |
39 | |
40 // Maps |field_type| to a field type that can be directly stored in a profile | |
41 // (in the sense that it makes sense to call |AutofillProfile::SetInfo()| with | |
42 // the returned field type as the first parameter). | |
43 static AutofillFieldType GetEquivalentFieldType(AutofillFieldType field_type); | |
44 | |
45 // Maps |field_type| to a field type from ADDRESS_BILLING FieldTypeGroup if | |
46 // field type is an Address type. | |
47 static AutofillFieldType GetEquivalentBillingFieldType( | |
48 AutofillFieldType field_type); | |
49 | |
50 // Utilities for serializing and deserializing an |AutofillFieldType|. | |
51 static std::string FieldTypeToString(AutofillFieldType field_type); | |
52 static AutofillFieldType StringToFieldType(const std::string& str); | |
53 | |
54 private: | |
55 AutofillFieldType field_type_; | |
56 }; | |
57 | |
58 typedef AutofillType::FieldTypeGroup FieldTypeGroup; | |
59 typedef std::set<AutofillFieldType> FieldTypeSet; | |
60 typedef std::map<base::string16, AutofillFieldType> FieldTypeMap; | |
61 | |
62 } // namespace autofill | |
63 | |
64 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_TYPE_H_ | |
OLD | NEW |