| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_COMMON_FORM_FIELD_DATA_H_ | 5 #ifndef COMPONENTS_AUTOFILL_COMMON_FORM_FIELD_DATA_H_ |
| 6 #define COMPONENTS_AUTOFILL_COMMON_FORM_FIELD_DATA_H_ | 6 #define COMPONENTS_AUTOFILL_COMMON_FORM_FIELD_DATA_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| 11 | 11 |
| 12 // Stores information about a field in a form. | 12 // Stores information about a field in a form. |
| 13 struct FormFieldData { | 13 struct FormFieldData { |
| 14 FormFieldData(); | 14 FormFieldData(); |
| 15 ~FormFieldData(); | 15 ~FormFieldData(); |
| 16 | 16 |
| 17 // Equality tests for identity which does not include |value| or | 17 // Equality tests for identity which does not include |value| or |
| 18 // |is_autofilled|. | 18 // |is_autofilled|. |
| 19 // TODO(dhollowa): These operators need to be revised when we implement field | 19 // TODO(dhollowa): These operators need to be revised when we implement field |
| 20 // ids. | 20 // ids. |
| 21 bool operator==(const FormFieldData& field) const; | 21 bool operator==(const FormFieldData& field) const; |
| 22 bool operator!=(const FormFieldData& field) const; | 22 bool operator!=(const FormFieldData& field) const; |
| 23 // Comparison operator exposed for STL map. Uses label, then name to sort. | 23 // Comparison operator exposed for STL map. Uses label, then name to sort. |
| 24 bool operator<(const FormFieldData& field) const; | 24 bool operator<(const FormFieldData& field) const; |
| 25 | 25 |
| 26 string16 label; | 26 base::string16 label; |
| 27 string16 name; | 27 base::string16 name; |
| 28 string16 value; | 28 base::string16 value; |
| 29 std::string form_control_type; | 29 std::string form_control_type; |
| 30 std::string autocomplete_attribute; | 30 std::string autocomplete_attribute; |
| 31 size_t max_length; | 31 size_t max_length; |
| 32 bool is_autofilled; | 32 bool is_autofilled; |
| 33 bool is_checked; | 33 bool is_checked; |
| 34 bool is_checkable; | 34 bool is_checkable; |
| 35 bool is_focusable; | 35 bool is_focusable; |
| 36 bool should_autocomplete; | 36 bool should_autocomplete; |
| 37 | 37 |
| 38 // For the HTML snippet |<option value="US">United States</option>|, the | 38 // For the HTML snippet |<option value="US">United States</option>|, the |
| 39 // value is "US" and the contents are "United States". | 39 // value is "US" and the contents are "United States". |
| 40 std::vector<string16> option_values; | 40 std::vector<base::string16> option_values; |
| 41 std::vector<string16> option_contents; | 41 std::vector<base::string16> option_contents; |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 // So we can compare FormFieldDatas with EXPECT_EQ(). | 44 // So we can compare FormFieldDatas with EXPECT_EQ(). |
| 45 std::ostream& operator<<(std::ostream& os, const FormFieldData& field); | 45 std::ostream& operator<<(std::ostream& os, const FormFieldData& field); |
| 46 | 46 |
| 47 // Prefer to use this macro in place of |EXPECT_EQ()| for comparing | 47 // Prefer to use this macro in place of |EXPECT_EQ()| for comparing |
| 48 // |FormFieldData|s in test code. | 48 // |FormFieldData|s in test code. |
| 49 #define EXPECT_FORM_FIELD_DATA_EQUALS(expected, actual) \ | 49 #define EXPECT_FORM_FIELD_DATA_EQUALS(expected, actual) \ |
| 50 do { \ | 50 do { \ |
| 51 EXPECT_EQ(expected.label, actual.label); \ | 51 EXPECT_EQ(expected.label, actual.label); \ |
| 52 EXPECT_EQ(expected.name, actual.name); \ | 52 EXPECT_EQ(expected.name, actual.name); \ |
| 53 EXPECT_EQ(expected.value, actual.value); \ | 53 EXPECT_EQ(expected.value, actual.value); \ |
| 54 EXPECT_EQ(expected.form_control_type, actual.form_control_type); \ | 54 EXPECT_EQ(expected.form_control_type, actual.form_control_type); \ |
| 55 EXPECT_EQ(expected.autocomplete_attribute, actual.autocomplete_attribute); \ | 55 EXPECT_EQ(expected.autocomplete_attribute, actual.autocomplete_attribute); \ |
| 56 EXPECT_EQ(expected.max_length, actual.max_length); \ | 56 EXPECT_EQ(expected.max_length, actual.max_length); \ |
| 57 EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \ | 57 EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \ |
| 58 EXPECT_EQ(expected.is_checked, actual.is_checked); \ | 58 EXPECT_EQ(expected.is_checked, actual.is_checked); \ |
| 59 EXPECT_EQ(expected.is_checkable, actual.is_checkable); \ | 59 EXPECT_EQ(expected.is_checkable, actual.is_checkable); \ |
| 60 } while (0) | 60 } while (0) |
| 61 | 61 |
| 62 #endif // COMPONENTS_AUTOFILL_COMMON_FORM_FIELD_DATA_H_ | 62 #endif // COMPONENTS_AUTOFILL_COMMON_FORM_FIELD_DATA_H_ |
| OLD | NEW |