Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: components/autofill/core/common/form_field_data.h

Issue 2022123002: Merge autofill::FormFieldData::is_checkable and is_checked (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 11 matching lines...) Expand all
22 // Stores information about a field in a form. 22 // Stores information about a field in a form.
23 struct FormFieldData { 23 struct FormFieldData {
24 // Copied to components/autofill/ios/browser/resources/autofill_controller.js. 24 // Copied to components/autofill/ios/browser/resources/autofill_controller.js.
25 enum RoleAttribute { 25 enum RoleAttribute {
26 // "presentation" 26 // "presentation"
27 ROLE_ATTRIBUTE_PRESENTATION, 27 ROLE_ATTRIBUTE_PRESENTATION,
28 // Anything else. 28 // Anything else.
29 ROLE_ATTRIBUTE_OTHER, 29 ROLE_ATTRIBUTE_OTHER,
30 }; 30 };
31 31
32 enum CheckStatus {
33 NOT_CHECKABLE,
34 CHECKABLE_BUT_UNCHECKED,
35 CHECKED,
36 };
37
32 FormFieldData(); 38 FormFieldData();
33 FormFieldData(const FormFieldData& other); 39 FormFieldData(const FormFieldData& other);
34 ~FormFieldData(); 40 ~FormFieldData();
35 41
36 // Returns true if two form fields are the same, not counting the value. 42 // Returns true if two form fields are the same, not counting the value.
37 bool SameFieldAs(const FormFieldData& field) const; 43 bool SameFieldAs(const FormFieldData& field) const;
38 44
39 // Comparison operator exposed for STL map. Uses label, then name to sort. 45 // Comparison operator exposed for STL map. Uses label, then name to sort.
40 bool operator<(const FormFieldData& field) const; 46 bool operator<(const FormFieldData& field) const;
41 47
42 // If you add more, be sure to update the comparison operator, SameFieldAs, 48 // If you add more, be sure to update the comparison operator, SameFieldAs,
43 // serializing functions (in the .cc file) and the constructor. 49 // serializing functions (in the .cc file) and the constructor.
44 base::string16 label; 50 base::string16 label;
45 base::string16 name; 51 base::string16 name;
46 base::string16 value; 52 base::string16 value;
47 std::string form_control_type; 53 std::string form_control_type;
48 std::string autocomplete_attribute; 54 std::string autocomplete_attribute;
49 base::string16 placeholder; 55 base::string16 placeholder;
50 // Note: we use uint64_t instead of size_t because this struct is sent over 56 // Note: we use uint64_t instead of size_t because this struct is sent over
51 // IPC which could span 32 & 64 bit processes. We chose uint64_t instead of 57 // IPC which could span 32 & 64 bit processes. We chose uint64_t instead of
52 // uint32_t to maintain compatibility with old code which used size_t 58 // uint32_t to maintain compatibility with old code which used size_t
53 // (base::Pickle used to serialize that as 64 bit). 59 // (base::Pickle used to serialize that as 64 bit).
54 uint64_t max_length; 60 uint64_t max_length;
55 bool is_autofilled; 61 bool is_autofilled;
56 bool is_checked; 62 CheckStatus check_status;
57 bool is_checkable;
58 bool is_focusable; 63 bool is_focusable;
59 bool should_autocomplete; 64 bool should_autocomplete;
60 RoleAttribute role; 65 RoleAttribute role;
61 base::i18n::TextDirection text_direction; 66 base::i18n::TextDirection text_direction;
62 67
63 // For the HTML snippet |<option value="US">United States</option>|, the 68 // For the HTML snippet |<option value="US">United States</option>|, the
64 // value is "US" and the contents are "United States". 69 // value is "US" and the contents are "United States".
65 std::vector<base::string16> option_values; 70 std::vector<base::string16> option_values;
66 std::vector<base::string16> option_contents; 71 std::vector<base::string16> option_contents;
67 }; 72 };
68 73
69 // Serialize and deserialize FormFieldData. These are used when FormData objects 74 // Serialize and deserialize FormFieldData. These are used when FormData objects
70 // are serialized and deserialized. 75 // are serialized and deserialized.
71 void SerializeFormFieldData(const FormFieldData& form_field_data, 76 void SerializeFormFieldData(const FormFieldData& form_field_data,
72 base::Pickle* serialized); 77 base::Pickle* serialized);
73 bool DeserializeFormFieldData(base::PickleIterator* pickle_iterator, 78 bool DeserializeFormFieldData(base::PickleIterator* pickle_iterator,
74 FormFieldData* form_field_data); 79 FormFieldData* form_field_data);
75 80
76 // So we can compare FormFieldDatas with EXPECT_EQ(). 81 // So we can compare FormFieldDatas with EXPECT_EQ().
77 std::ostream& operator<<(std::ostream& os, const FormFieldData& field); 82 std::ostream& operator<<(std::ostream& os, const FormFieldData& field);
78 83
84 bool IsCheckable(const FormFieldData::CheckStatus& check_status);
85 bool IsChecked(const FormFieldData::CheckStatus& check_status);
86 void SetCheckStatus(FormFieldData* form_field_data,
87 bool isCheckable,
88 bool isChecked);
89
79 // Prefer to use this macro in place of |EXPECT_EQ()| for comparing 90 // Prefer to use this macro in place of |EXPECT_EQ()| for comparing
80 // |FormFieldData|s in test code. 91 // |FormFieldData|s in test code.
81 #define EXPECT_FORM_FIELD_DATA_EQUALS(expected, actual) \ 92 #define EXPECT_FORM_FIELD_DATA_EQUALS(expected, actual) \
82 do { \ 93 do { \
83 EXPECT_EQ(expected.label, actual.label); \ 94 EXPECT_EQ(expected.label, actual.label); \
84 EXPECT_EQ(expected.name, actual.name); \ 95 EXPECT_EQ(expected.name, actual.name); \
85 EXPECT_EQ(expected.value, actual.value); \ 96 EXPECT_EQ(expected.value, actual.value); \
86 EXPECT_EQ(expected.form_control_type, actual.form_control_type); \ 97 EXPECT_EQ(expected.form_control_type, actual.form_control_type); \
87 EXPECT_EQ(expected.autocomplete_attribute, actual.autocomplete_attribute); \ 98 EXPECT_EQ(expected.autocomplete_attribute, actual.autocomplete_attribute); \
88 EXPECT_EQ(expected.placeholder, actual.placeholder); \ 99 EXPECT_EQ(expected.placeholder, actual.placeholder); \
89 EXPECT_EQ(expected.max_length, actual.max_length); \ 100 EXPECT_EQ(expected.max_length, actual.max_length); \
90 EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \ 101 EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \
91 EXPECT_EQ(expected.is_checked, actual.is_checked); \ 102 EXPECT_EQ(expected.check_status, actual.check_status); \
92 EXPECT_EQ(expected.is_checkable, actual.is_checkable); \
93 } while (0) 103 } while (0)
94 104
95 } // namespace autofill 105 } // namespace autofill
96 106
97 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_ 107 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_
OLDNEW
« no previous file with comments | « components/autofill/core/common/form_data_unittest.cc ('k') | components/autofill/core/common/form_field_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698