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 #include "components/autofill/core/common/form_data.h" | 5 #include "components/autofill/core/common/form_data.h" |
6 | 6 |
7 #include <tuple> | |
8 | |
9 #include "base/base64.h" | 7 #include "base/base64.h" |
10 #include "base/pickle.h" | 8 #include "base/pickle.h" |
11 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
13 #include "components/autofill/core/common/form_field_data.h" | 11 #include "components/autofill/core/common/form_field_data.h" |
14 | 12 |
15 namespace autofill { | 13 namespace autofill { |
16 | 14 |
17 namespace { | 15 namespace { |
18 | 16 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 fields.size() != form.fields.size()) | 79 fields.size() != form.fields.size()) |
82 return false; | 80 return false; |
83 for (size_t i = 0; i < fields.size(); ++i) { | 81 for (size_t i = 0; i < fields.size(); ++i) { |
84 if (!fields[i].SameFieldAs(form.fields[i])) | 82 if (!fields[i].SameFieldAs(form.fields[i])) |
85 return false; | 83 return false; |
86 } | 84 } |
87 return true; | 85 return true; |
88 } | 86 } |
89 | 87 |
90 bool FormData::operator<(const FormData& form) const { | 88 bool FormData::operator<(const FormData& form) const { |
91 return std::tie(name, origin, action, is_form_tag, fields) < | 89 if (name != form.name) |
92 std::tie(form.name, form.origin, form.action, form.is_form_tag, | 90 return name < form.name; |
93 form.fields); | 91 if (origin != form.origin) |
| 92 return origin < form.origin; |
| 93 if (action != form.action) |
| 94 return action < form.action; |
| 95 if (is_form_tag != form.is_form_tag) |
| 96 return is_form_tag < form.is_form_tag; |
| 97 return fields < form.fields; |
94 } | 98 } |
95 | 99 |
96 std::ostream& operator<<(std::ostream& os, const FormData& form) { | 100 std::ostream& operator<<(std::ostream& os, const FormData& form) { |
97 os << base::UTF16ToUTF8(form.name) << " " | 101 os << base::UTF16ToUTF8(form.name) << " " |
98 << form.origin << " " | 102 << form.origin << " " |
99 << form.action << " " | 103 << form.action << " " |
100 << form.is_form_tag << " " | 104 << form.is_form_tag << " " |
101 << "Fields:"; | 105 << "Fields:"; |
102 for (size_t i = 0; i < form.fields.size(); ++i) { | 106 for (size_t i = 0; i < form.fields.size(); ++i) { |
103 os << form.fields[i] << ","; | 107 os << form.fields[i] << ","; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 if (input.empty()) | 181 if (input.empty()) |
178 return false; | 182 return false; |
179 std::string pickle_data; | 183 std::string pickle_data; |
180 Base64Decode(input, &pickle_data); | 184 Base64Decode(input, &pickle_data); |
181 base::Pickle pickle(pickle_data.data(), static_cast<int>(pickle_data.size())); | 185 base::Pickle pickle(pickle_data.data(), static_cast<int>(pickle_data.size())); |
182 base::PickleIterator iter(pickle); | 186 base::PickleIterator iter(pickle); |
183 return DeserializeFormData(&iter, form_data); | 187 return DeserializeFormData(&iter, form_data); |
184 } | 188 } |
185 | 189 |
186 } // namespace autofill | 190 } // namespace autofill |
OLD | NEW |