Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / components / autofill / core / common / form_field_data.h
blob2fa3ac50d8532120654dfbfd8b76932c1f341cee
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 // Copied to components/autofill/ios/browser/resources/autofill_controller.js.
23 enum RoleAttribute {
24 // "presentation"
25 ROLE_ATTRIBUTE_PRESENTATION,
26 // Anything else.
27 ROLE_ATTRIBUTE_OTHER,
30 FormFieldData();
31 ~FormFieldData();
33 // Returns true if two form fields are the same, not counting the value.
34 bool SameFieldAs(const FormFieldData& field) const;
36 // Comparison operator exposed for STL map. Uses label, then name to sort.
37 bool operator<(const FormFieldData& field) const;
39 // If you add more, be sure to update the comparison operator, SameFieldAs,
40 // serializing functions (in the .cc file) and the constructor.
41 base::string16 label;
42 base::string16 name;
43 base::string16 value;
44 std::string form_control_type;
45 std::string autocomplete_attribute;
46 size_t max_length;
47 bool is_autofilled;
48 bool is_checked;
49 bool is_checkable;
50 bool is_focusable;
51 bool should_autocomplete;
52 RoleAttribute role;
53 base::i18n::TextDirection text_direction;
55 // For the HTML snippet |<option value="US">United States</option>|, the
56 // value is "US" and the contents are "United States".
57 std::vector<base::string16> option_values;
58 std::vector<base::string16> option_contents;
61 // Serialize and deserialize FormFieldData. These are used when FormData objects
62 // are serialized and deserialized.
63 void SerializeFormFieldData(const FormFieldData& form_field_data,
64 base::Pickle* serialized);
65 bool DeserializeFormFieldData(base::PickleIterator* pickle_iterator,
66 FormFieldData* form_field_data);
68 // So we can compare FormFieldDatas with EXPECT_EQ().
69 std::ostream& operator<<(std::ostream& os, const FormFieldData& field);
71 // Prefer to use this macro in place of |EXPECT_EQ()| for comparing
72 // |FormFieldData|s in test code.
73 #define EXPECT_FORM_FIELD_DATA_EQUALS(expected, actual) \
74 do { \
75 EXPECT_EQ(expected.label, actual.label); \
76 EXPECT_EQ(expected.name, actual.name); \
77 EXPECT_EQ(expected.value, actual.value); \
78 EXPECT_EQ(expected.form_control_type, actual.form_control_type); \
79 EXPECT_EQ(expected.autocomplete_attribute, actual.autocomplete_attribute); \
80 EXPECT_EQ(expected.max_length, actual.max_length); \
81 EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \
82 EXPECT_EQ(expected.is_checked, actual.is_checked); \
83 EXPECT_EQ(expected.is_checkable, actual.is_checkable); \
84 } while (0)
86 } // namespace autofill
88 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_