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