OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_ |
6 #define COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 | 12 |
13 class Pickle; | 13 class Pickle; |
14 class PickleIterator; | 14 class PickleIterator; |
15 | 15 |
16 namespace autofill { | 16 namespace autofill { |
17 | 17 |
18 // Stores information about a field in a form. | 18 // Stores information about a field in a form. |
19 struct FormFieldData { | 19 struct FormFieldData { |
| 20 enum RoleAttribute { |
| 21 // "presentation" |
| 22 ROLE_ATTRIBUTE_PRESENTATION, |
| 23 // Anything else. |
| 24 ROLE_ATTRIBUTE_OTHER, |
| 25 }; |
| 26 |
20 FormFieldData(); | 27 FormFieldData(); |
21 ~FormFieldData(); | 28 ~FormFieldData(); |
22 | 29 |
23 // Returns true if two form fields are the same, not counting the value. | 30 // Returns true if two form fields are the same, not counting the value. |
24 bool SameFieldAs(const FormFieldData& field) const; | 31 bool SameFieldAs(const FormFieldData& field) const; |
25 | 32 |
26 // Comparison operator exposed for STL map. Uses label, then name to sort. | 33 // Comparison operator exposed for STL map. Uses label, then name to sort. |
27 bool operator<(const FormFieldData& field) const; | 34 bool operator<(const FormFieldData& field) const; |
28 | 35 |
29 // If you add more, be sure to update the comparison operator, SameFieldAs, | 36 // If you add more, be sure to update the comparison operator, SameFieldAs, |
30 // serializing functions (in the .cc file) and the constructor. | 37 // serializing functions (in the .cc file) and the constructor. |
31 base::string16 label; | 38 base::string16 label; |
32 base::string16 name; | 39 base::string16 name; |
33 base::string16 value; | 40 base::string16 value; |
34 std::string form_control_type; | 41 std::string form_control_type; |
35 std::string autocomplete_attribute; | 42 std::string autocomplete_attribute; |
36 size_t max_length; | 43 size_t max_length; |
37 bool is_autofilled; | 44 bool is_autofilled; |
38 bool is_checked; | 45 bool is_checked; |
39 bool is_checkable; | 46 bool is_checkable; |
40 bool is_focusable; | 47 bool is_focusable; |
41 bool should_autocomplete; | 48 bool should_autocomplete; |
| 49 RoleAttribute role; |
42 base::i18n::TextDirection text_direction; | 50 base::i18n::TextDirection text_direction; |
43 | 51 |
44 // For the HTML snippet |<option value="US">United States</option>|, the | 52 // For the HTML snippet |<option value="US">United States</option>|, the |
45 // value is "US" and the contents are "United States". | 53 // value is "US" and the contents are "United States". |
46 std::vector<base::string16> option_values; | 54 std::vector<base::string16> option_values; |
47 std::vector<base::string16> option_contents; | 55 std::vector<base::string16> option_contents; |
48 }; | 56 }; |
49 | 57 |
50 // Serialize and deserialize FormFieldData. These are used when FormData objects | 58 // Serialize and deserialize FormFieldData. These are used when FormData objects |
51 // are serialized and deserialized. | 59 // are serialized and deserialized. |
(...skipping 16 matching lines...) Expand all Loading... |
68 EXPECT_EQ(expected.autocomplete_attribute, actual.autocomplete_attribute); \ | 76 EXPECT_EQ(expected.autocomplete_attribute, actual.autocomplete_attribute); \ |
69 EXPECT_EQ(expected.max_length, actual.max_length); \ | 77 EXPECT_EQ(expected.max_length, actual.max_length); \ |
70 EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \ | 78 EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \ |
71 EXPECT_EQ(expected.is_checked, actual.is_checked); \ | 79 EXPECT_EQ(expected.is_checked, actual.is_checked); \ |
72 EXPECT_EQ(expected.is_checkable, actual.is_checkable); \ | 80 EXPECT_EQ(expected.is_checkable, actual.is_checkable); \ |
73 } while (0) | 81 } while (0) |
74 | 82 |
75 } // namespace autofill | 83 } // namespace autofill |
76 | 84 |
77 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_ | 85 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_ |
OLD | NEW |