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.
5 #ifndef COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_
6 #define COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_
10 #include "base/i18n/rtl.h"
11 #include "base/strings/string16.h"
18 // Stores information about a field in a form.
19 struct FormFieldData
{
23 // Equality tests for identity which does not include |value| or
25 // TODO(dhollowa): These operators need to be revised when we implement field
27 bool operator==(const FormFieldData
& field
) const;
28 bool operator!=(const FormFieldData
& field
) const;
29 // Comparison operator exposed for STL map. Uses label, then name to sort.
30 bool operator<(const FormFieldData
& field
) const;
35 std::string form_control_type
;
36 std::string autocomplete_attribute
;
42 bool should_autocomplete
;
43 base::i18n::TextDirection text_direction
;
45 // For the HTML snippet |<option value="US">United States</option>|, the
46 // value is "US" and the contents are "United States".
47 std::vector
<base::string16
> option_values
;
48 std::vector
<base::string16
> option_contents
;
51 // Serialize and deserialize FormFieldData. These are used when FormData objects
52 // are serialized and deserialized.
53 void SerializeFormFieldData(const FormFieldData
& form_field_data
,
55 bool DeserializeFormFieldData(PickleIterator
* pickle_iterator
,
56 FormFieldData
* form_field_data
);
58 // So we can compare FormFieldDatas with EXPECT_EQ().
59 std::ostream
& operator<<(std::ostream
& os
, const FormFieldData
& field
);
61 // Prefer to use this macro in place of |EXPECT_EQ()| for comparing
62 // |FormFieldData|s in test code.
63 #define EXPECT_FORM_FIELD_DATA_EQUALS(expected, actual) \
65 EXPECT_EQ(expected.label, actual.label); \
66 EXPECT_EQ(expected.name, actual.name); \
67 EXPECT_EQ(expected.value, actual.value); \
68 EXPECT_EQ(expected.form_control_type, actual.form_control_type); \
69 EXPECT_EQ(expected.autocomplete_attribute, actual.autocomplete_attribute); \
70 EXPECT_EQ(expected.max_length, actual.max_length); \
71 EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \
72 EXPECT_EQ(expected.is_checked, actual.is_checked); \
73 EXPECT_EQ(expected.is_checkable, actual.is_checkable); \
76 } // namespace autofill
78 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_