| 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/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/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 webkit::forms::PasswordForm; | 9 using webkit::forms::PasswordForm; |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 << "date_created: " << form.date_created.ToDoubleT(); | 69 << "date_created: " << form.date_created.ToDoubleT(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 typedef std::set<const webkit::forms::PasswordForm*> SetOfForms; | 72 typedef std::set<const webkit::forms::PasswordForm*> SetOfForms; |
| 73 | 73 |
| 74 bool ContainsSamePasswordFormsPtr( | 74 bool ContainsSamePasswordFormsPtr( |
| 75 const std::vector<PasswordForm*>& first, | 75 const std::vector<PasswordForm*>& first, |
| 76 const std::vector<PasswordForm*>& second) { | 76 const std::vector<PasswordForm*>& second) { |
| 77 if (first.size() != second.size()) | 77 if (first.size() != second.size()) |
| 78 return false; | 78 return false; |
| 79 SetOfForms expectations(first.begin(), first.end()); | 79 |
| 80 // 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 |
| 82 // into a set rather than std::copy that is used below. |
| 83 // Need to revert this once STLport is fixed. |
| 84 SetOfForms expectations; |
| 85 std::copy(first.begin(), first.end(), std::inserter(expectations, |
| 86 expectations.begin())); |
| 80 for (unsigned int i = 0; i < second.size(); ++i) { | 87 for (unsigned int i = 0; i < second.size(); ++i) { |
| 81 const PasswordForm* actual = second[i]; | 88 const PasswordForm* actual = second[i]; |
| 82 bool found_match = false; | 89 bool found_match = false; |
| 83 for (SetOfForms::iterator it = expectations.begin(); | 90 for (SetOfForms::iterator it = expectations.begin(); |
| 84 it != expectations.end(); ++it) { | 91 it != expectations.end(); ++it) { |
| 85 const PasswordForm* expected = *it; | 92 const PasswordForm* expected = *it; |
| 86 if (*expected == *actual) { | 93 if (*expected == *actual) { |
| 87 found_match = true; | 94 found_match = true; |
| 88 expectations.erase(it); | 95 expectations.erase(it); |
| 89 break; | 96 break; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 103 std::vector<PasswordForm*> first_ptr; | 110 std::vector<PasswordForm*> first_ptr; |
| 104 for (unsigned int i = 0; i < first.size(); ++i) { | 111 for (unsigned int i = 0; i < first.size(); ++i) { |
| 105 first_ptr.push_back(&first[i]); | 112 first_ptr.push_back(&first[i]); |
| 106 } | 113 } |
| 107 std::vector<PasswordForm*> second_ptr; | 114 std::vector<PasswordForm*> second_ptr; |
| 108 for (unsigned int i = 0; i < second.size(); ++i) { | 115 for (unsigned int i = 0; i < second.size(); ++i) { |
| 109 second_ptr.push_back(&second[i]); | 116 second_ptr.push_back(&second[i]); |
| 110 } | 117 } |
| 111 return ContainsSamePasswordFormsPtr(first_ptr, second_ptr); | 118 return ContainsSamePasswordFormsPtr(first_ptr, second_ptr); |
| 112 } | 119 } |
| OLD | NEW |