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_FIELD_H_ | |
6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_FIELD_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/strings/string16.h" | |
12 #include "components/autofill/browser/field_types.h" | |
13 #include "components/autofill/core/common/form_field_data.h" | |
14 | |
15 namespace autofill { | |
16 | |
17 class AutofillField : public FormFieldData { | |
18 public: | |
19 enum PhonePart { | |
20 IGNORED = 0, | |
21 PHONE_PREFIX = 1, | |
22 PHONE_SUFFIX = 2, | |
23 }; | |
24 | |
25 AutofillField(); | |
26 AutofillField(const FormFieldData& field, const base::string16& unique_name); | |
27 virtual ~AutofillField(); | |
28 | |
29 const base::string16& unique_name() const { return unique_name_; } | |
30 | |
31 const std::string& section() const { return section_; } | |
32 AutofillFieldType heuristic_type() const { return heuristic_type_; } | |
33 AutofillFieldType server_type() const { return server_type_; } | |
34 const FieldTypeSet& possible_types() const { return possible_types_; } | |
35 PhonePart phone_part() const { return phone_part_; } | |
36 | |
37 // Sets the heuristic type of this field, validating the input. | |
38 void set_section(const std::string& section) { section_ = section; } | |
39 void set_heuristic_type(AutofillFieldType type); | |
40 void set_server_type(AutofillFieldType type); | |
41 void set_possible_types(const FieldTypeSet& possible_types) { | |
42 possible_types_ = possible_types; | |
43 } | |
44 void set_phone_part(PhonePart part) { phone_part_ = part; } | |
45 | |
46 // This function automatically chooses between server and heuristic autofill | |
47 // type, depending on the data available. | |
48 AutofillFieldType type() const; | |
49 | |
50 // Returns true if the value of this field is empty. | |
51 bool IsEmpty() const; | |
52 | |
53 // The unique signature of this field, composed of the field name and the html | |
54 // input type in a 32-bit hash. | |
55 std::string FieldSignature() const; | |
56 | |
57 // Returns true if the field type has been determined (without the text in the | |
58 // field). | |
59 bool IsFieldFillable() const; | |
60 | |
61 void set_default_value(const std::string& value) { default_value_ = value; } | |
62 const std::string& default_value() const { return default_value_; } | |
63 | |
64 private: | |
65 // The unique name of this field, generated by Autofill. | |
66 base::string16 unique_name_; | |
67 | |
68 // The unique identifier for the section (e.g. billing vs. shipping address) | |
69 // that this field belongs to. | |
70 std::string section_; | |
71 | |
72 // The type of the field, as determined by the Autofill server. | |
73 AutofillFieldType server_type_; | |
74 | |
75 // The type of the field, as determined by the local heuristics. | |
76 AutofillFieldType heuristic_type_; | |
77 | |
78 // The set of possible types for this field. | |
79 FieldTypeSet possible_types_; | |
80 | |
81 // Used to track whether this field is a phone prefix or suffix. | |
82 PhonePart phone_part_; | |
83 | |
84 // The default value returned by the Autofill server. | |
85 std::string default_value_; | |
86 | |
87 DISALLOW_COPY_AND_ASSIGN(AutofillField); | |
88 }; | |
89 | |
90 } // namespace autofill | |
91 | |
92 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_FIELD_H_ | |
OLD | NEW |