| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/strings/string_util.h" | 5 #include "base/strings/string_util.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "chrome/browser/password_manager/password_form_data.h" | 7 #include "chrome/browser/password_manager/password_form_data.h" |
| 8 | 8 |
| 9 using autofill::PasswordForm; | 9 using autofill::PasswordForm; |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 if (form_data.username_value) { | 30 if (form_data.username_value) { |
| 31 form->username_value = WideToUTF16(form_data.username_value); | 31 form->username_value = WideToUTF16(form_data.username_value); |
| 32 if (form_data.password_value) | 32 if (form_data.password_value) |
| 33 form->password_value = WideToUTF16(form_data.password_value); | 33 form->password_value = WideToUTF16(form_data.password_value); |
| 34 } else { | 34 } else { |
| 35 form->blacklisted_by_user = true; | 35 form->blacklisted_by_user = true; |
| 36 } | 36 } |
| 37 return form; | 37 return form; |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool operator==(const PasswordForm& lhs, const PasswordForm& rhs) { | |
| 41 return (lhs.scheme == rhs.scheme && | |
| 42 lhs.signon_realm == rhs.signon_realm && | |
| 43 lhs.origin == rhs.origin && | |
| 44 lhs.action == rhs.action && | |
| 45 lhs.submit_element == rhs.submit_element && | |
| 46 lhs.username_element == rhs.username_element && | |
| 47 lhs.password_element == rhs.password_element && | |
| 48 lhs.username_value == rhs.username_value && | |
| 49 lhs.password_value == rhs.password_value && | |
| 50 lhs.blacklisted_by_user == rhs.blacklisted_by_user && | |
| 51 lhs.preferred == rhs.preferred && | |
| 52 lhs.ssl_valid == rhs.ssl_valid && | |
| 53 lhs.date_created == rhs.date_created); | |
| 54 } | |
| 55 | |
| 56 std::ostream& operator<<(std::ostream& os, const PasswordForm& form) { | |
| 57 return os << "scheme: " << form.scheme << std::endl | |
| 58 << "signon_realm: " << form.signon_realm << std::endl | |
| 59 << "origin: " << form.origin << std::endl | |
| 60 << "action: " << form.action << std::endl | |
| 61 << "submit_element: " << form.submit_element << std::endl | |
| 62 << "username_elem: " << form.username_element << std::endl | |
| 63 << "password_elem: " << form.password_element << std::endl | |
| 64 << "username_value: " << form.username_value << std::endl | |
| 65 << "password_value: " << form.password_value << std::endl | |
| 66 << "blacklisted: " << form.blacklisted_by_user << std::endl | |
| 67 << "preferred: " << form.preferred << std::endl | |
| 68 << "ssl_valid: " << form.ssl_valid << std::endl | |
| 69 << "date_created: " << form.date_created.ToDoubleT(); | |
| 70 } | |
| 71 | |
| 72 typedef std::set<const autofill::PasswordForm*> SetOfForms; | 40 typedef std::set<const autofill::PasswordForm*> SetOfForms; |
| 73 | 41 |
| 74 bool ContainsSamePasswordFormsPtr( | 42 bool ContainsSamePasswordFormsPtr( |
| 75 const std::vector<PasswordForm*>& first, | 43 const std::vector<PasswordForm*>& first, |
| 76 const std::vector<PasswordForm*>& second) { | 44 const std::vector<PasswordForm*>& second) { |
| 77 if (first.size() != second.size()) | 45 if (first.size() != second.size()) |
| 78 return false; | 46 return false; |
| 79 | 47 |
| 80 // TODO(cramya): As per b/7079906, the STLport of Android causes a crash | 48 // TODO(cramya): As per b/7079906, the STLport of Android causes a crash |
| 81 // if we use expectations(first.begin(), first.end()) to copy a vector | 49 // if we use expectations(first.begin(), first.end()) to copy a vector |
| (...skipping 28 matching lines...) Expand all Loading... |
| 110 std::vector<PasswordForm*> first_ptr; | 78 std::vector<PasswordForm*> first_ptr; |
| 111 for (unsigned int i = 0; i < first.size(); ++i) { | 79 for (unsigned int i = 0; i < first.size(); ++i) { |
| 112 first_ptr.push_back(&first[i]); | 80 first_ptr.push_back(&first[i]); |
| 113 } | 81 } |
| 114 std::vector<PasswordForm*> second_ptr; | 82 std::vector<PasswordForm*> second_ptr; |
| 115 for (unsigned int i = 0; i < second.size(); ++i) { | 83 for (unsigned int i = 0; i < second.size(); ++i) { |
| 116 second_ptr.push_back(&second[i]); | 84 second_ptr.push_back(&second[i]); |
| 117 } | 85 } |
| 118 return ContainsSamePasswordFormsPtr(first_ptr, second_ptr); | 86 return ContainsSamePasswordFormsPtr(first_ptr, second_ptr); |
| 119 } | 87 } |
| OLD | NEW |