| OLD | NEW |
| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 | 12 |
| 13 namespace base { |
| 13 class Pickle; | 14 class Pickle; |
| 14 class PickleIterator; | 15 class PickleIterator; |
| 16 } |
| 15 | 17 |
| 16 namespace autofill { | 18 namespace autofill { |
| 17 | 19 |
| 18 // Stores information about a field in a form. | 20 // Stores information about a field in a form. |
| 19 struct FormFieldData { | 21 struct FormFieldData { |
| 20 enum RoleAttribute { | 22 enum RoleAttribute { |
| 21 // "presentation" | 23 // "presentation" |
| 22 ROLE_ATTRIBUTE_PRESENTATION, | 24 ROLE_ATTRIBUTE_PRESENTATION, |
| 23 // Anything else. | 25 // Anything else. |
| 24 ROLE_ATTRIBUTE_OTHER, | 26 ROLE_ATTRIBUTE_OTHER, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 51 | 53 |
| 52 // For the HTML snippet |<option value="US">United States</option>|, the | 54 // For the HTML snippet |<option value="US">United States</option>|, the |
| 53 // value is "US" and the contents are "United States". | 55 // value is "US" and the contents are "United States". |
| 54 std::vector<base::string16> option_values; | 56 std::vector<base::string16> option_values; |
| 55 std::vector<base::string16> option_contents; | 57 std::vector<base::string16> option_contents; |
| 56 }; | 58 }; |
| 57 | 59 |
| 58 // Serialize and deserialize FormFieldData. These are used when FormData objects | 60 // Serialize and deserialize FormFieldData. These are used when FormData objects |
| 59 // are serialized and deserialized. | 61 // are serialized and deserialized. |
| 60 void SerializeFormFieldData(const FormFieldData& form_field_data, | 62 void SerializeFormFieldData(const FormFieldData& form_field_data, |
| 61 Pickle* serialized); | 63 base::Pickle* serialized); |
| 62 bool DeserializeFormFieldData(PickleIterator* pickle_iterator, | 64 bool DeserializeFormFieldData(base::PickleIterator* pickle_iterator, |
| 63 FormFieldData* form_field_data); | 65 FormFieldData* form_field_data); |
| 64 | 66 |
| 65 // So we can compare FormFieldDatas with EXPECT_EQ(). | 67 // So we can compare FormFieldDatas with EXPECT_EQ(). |
| 66 std::ostream& operator<<(std::ostream& os, const FormFieldData& field); | 68 std::ostream& operator<<(std::ostream& os, const FormFieldData& field); |
| 67 | 69 |
| 68 // Prefer to use this macro in place of |EXPECT_EQ()| for comparing | 70 // Prefer to use this macro in place of |EXPECT_EQ()| for comparing |
| 69 // |FormFieldData|s in test code. | 71 // |FormFieldData|s in test code. |
| 70 #define EXPECT_FORM_FIELD_DATA_EQUALS(expected, actual) \ | 72 #define EXPECT_FORM_FIELD_DATA_EQUALS(expected, actual) \ |
| 71 do { \ | 73 do { \ |
| 72 EXPECT_EQ(expected.label, actual.label); \ | 74 EXPECT_EQ(expected.label, actual.label); \ |
| 73 EXPECT_EQ(expected.name, actual.name); \ | 75 EXPECT_EQ(expected.name, actual.name); \ |
| 74 EXPECT_EQ(expected.value, actual.value); \ | 76 EXPECT_EQ(expected.value, actual.value); \ |
| 75 EXPECT_EQ(expected.form_control_type, actual.form_control_type); \ | 77 EXPECT_EQ(expected.form_control_type, actual.form_control_type); \ |
| 76 EXPECT_EQ(expected.autocomplete_attribute, actual.autocomplete_attribute); \ | 78 EXPECT_EQ(expected.autocomplete_attribute, actual.autocomplete_attribute); \ |
| 77 EXPECT_EQ(expected.max_length, actual.max_length); \ | 79 EXPECT_EQ(expected.max_length, actual.max_length); \ |
| 78 EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \ | 80 EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \ |
| 79 EXPECT_EQ(expected.is_checked, actual.is_checked); \ | 81 EXPECT_EQ(expected.is_checked, actual.is_checked); \ |
| 80 EXPECT_EQ(expected.is_checkable, actual.is_checkable); \ | 82 EXPECT_EQ(expected.is_checkable, actual.is_checkable); \ |
| 81 } while (0) | 83 } while (0) |
| 82 | 84 |
| 83 } // namespace autofill | 85 } // namespace autofill |
| 84 | 86 |
| 85 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_ | 87 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_ |
| OLD | NEW |