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 #include "chrome/common/form_field_data.h" | 5 #include "chrome/common/form_field_data.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 | 9 |
10 FormFieldData::FormFieldData() | 10 FormFieldData::FormFieldData() |
11 : max_length(0), | 11 : max_length(0), |
12 is_autofilled(false), | 12 is_autofilled(false), |
13 is_focusable(false), | 13 is_focusable(false), |
14 should_autocomplete(false) { | 14 should_autocomplete(false) { |
15 } | 15 } |
16 | 16 |
17 FormFieldData::~FormFieldData() { | 17 FormFieldData::~FormFieldData() { |
18 } | 18 } |
19 | 19 |
20 bool FormFieldData::operator==(const FormFieldData& field) const { | 20 bool FormFieldData::operator==(const FormFieldData& field) const { |
21 // A FormFieldData stores a value, but the value is not part of the identity | 21 // A FormFieldData stores a value, but the value is not part of the identity |
22 // of the field, so we don't want to compare the values. | 22 // of the field, so we don't want to compare the values. |
23 return (label == field.label && | 23 return (label == field.label && |
24 name == field.name && | 24 name == field.name && |
25 form_control_type == field.form_control_type && | 25 form_control_type == field.form_control_type && |
26 autocomplete_type == field.autocomplete_type && | 26 autocomplete_attribute == field.autocomplete_attribute && |
27 max_length == field.max_length); | 27 max_length == field.max_length); |
28 } | 28 } |
29 | 29 |
30 bool FormFieldData::operator!=(const FormFieldData& field) const { | 30 bool FormFieldData::operator!=(const FormFieldData& field) const { |
31 return !operator==(field); | 31 return !operator==(field); |
32 } | 32 } |
33 | 33 |
34 bool FormFieldData::operator<(const FormFieldData& field) const { | 34 bool FormFieldData::operator<(const FormFieldData& field) const { |
35 if (label == field.label) | 35 if (label == field.label) |
36 return name < field.name; | 36 return name < field.name; |
37 | 37 |
38 return label < field.label; | 38 return label < field.label; |
39 } | 39 } |
40 | 40 |
41 std::ostream& operator<<(std::ostream& os, const FormFieldData& field) { | 41 std::ostream& operator<<(std::ostream& os, const FormFieldData& field) { |
42 return os | 42 return os |
43 << UTF16ToUTF8(field.label) | 43 << UTF16ToUTF8(field.label) |
44 << " " | 44 << " " |
45 << UTF16ToUTF8(field.name) | 45 << UTF16ToUTF8(field.name) |
46 << " " | 46 << " " |
47 << UTF16ToUTF8(field.value) | 47 << UTF16ToUTF8(field.value) |
48 << " " | 48 << " " |
49 << UTF16ToUTF8(field.form_control_type) | 49 << field.form_control_type |
50 << " " | 50 << " " |
51 << UTF16ToUTF8(field.autocomplete_type) | 51 << field.autocomplete_attribute |
52 << " " | 52 << " " |
53 << field.max_length | 53 << field.max_length |
54 << " " | 54 << " " |
55 << (field.is_autofilled ? "true" : "false") | 55 << (field.is_autofilled ? "true" : "false") |
56 << " " | 56 << " " |
57 << (field.is_focusable ? "true" : "false") | 57 << (field.is_focusable ? "true" : "false") |
58 << " " | 58 << " " |
59 << (field.should_autocomplete ? "true" : "false"); | 59 << (field.should_autocomplete ? "true" : "false"); |
60 } | 60 } |
OLD | NEW |