Don't preload rarely seen large images
[chromium-blink-merge.git] / components / autofill / core / common / form_field_data.h
blobd43c2bb0c3113f5d9b90fde880b623c9d1beac63
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_
8 #include <vector>
10 #include "base/i18n/rtl.h"
11 #include "base/strings/string16.h"
13 namespace base {
14 class Pickle;
15 class PickleIterator;
18 namespace autofill {
20 // Stores information about a field in a form.
21 struct FormFieldData {
22 enum RoleAttribute {
23 // "presentation"
24 ROLE_ATTRIBUTE_PRESENTATION,
25 // Anything else.
26 ROLE_ATTRIBUTE_OTHER,
29 FormFieldData();
30 ~FormFieldData();
32 // Returns true if two form fields are the same, not counting the value.
33 bool SameFieldAs(const FormFieldData& field) const;
35 // Comparison operator exposed for STL map. Uses label, then name to sort.
36 bool operator<(const FormFieldData& field) const;
38 // If you add more, be sure to update the comparison operator, SameFieldAs,
39 // serializing functions (in the .cc file) and the constructor.
40 base::string16 label;
41 base::string16 name;
42 base::string16 value;
43 std::string form_control_type;
44 std::string autocomplete_attribute;
45 size_t max_length;
46 bool is_autofilled;
47 bool is_checked;
48 bool is_checkable;
49 bool is_focusable;
50 bool should_autocomplete;
51 RoleAttribute role;
52 base::i18n::TextDirection text_direction;
54 // For the HTML snippet |<option value="US">United States</option>|, the
55 // value is "US" and the contents are "United States".
56 std::vector<base::string16> option_values;
57 std::vector<base::string16> option_contents;
60 // Serialize and deserialize FormFieldData. These are used when FormData objects
61 // are serialized and deserialized.
62 void SerializeFormFieldData(const FormFieldData& form_field_data,
63 base::Pickle* serialized);
64 bool DeserializeFormFieldData(base::PickleIterator* pickle_iterator,
65 FormFieldData* form_field_data);
67 // So we can compare FormFieldDatas with EXPECT_EQ().
68 std::ostream& operator<<(std::ostream& os, const FormFieldData& field);
70 // Prefer to use this macro in place of |EXPECT_EQ()| for comparing
71 // |FormFieldData|s in test code.
72 #define EXPECT_FORM_FIELD_DATA_EQUALS(expected, actual) \
73 do { \
74 EXPECT_EQ(expected.label, actual.label); \
75 EXPECT_EQ(expected.name, actual.name); \
76 EXPECT_EQ(expected.value, actual.value); \
77 EXPECT_EQ(expected.form_control_type, actual.form_control_type); \
78 EXPECT_EQ(expected.autocomplete_attribute, actual.autocomplete_attribute); \
79 EXPECT_EQ(expected.max_length, actual.max_length); \
80 EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \
81 EXPECT_EQ(expected.is_checked, actual.is_checked); \
82 EXPECT_EQ(expected.is_checkable, actual.is_checkable); \
83 } while (0)
85 } // namespace autofill
87 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_