OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_glue::PasswordForm; | 9 using webkit::forms::PasswordForm; |
10 | 10 |
11 PasswordForm* CreatePasswordFormFromData( | 11 PasswordForm* CreatePasswordFormFromData( |
12 const PasswordFormData& form_data) { | 12 const PasswordFormData& form_data) { |
13 PasswordForm* form = new PasswordForm(); | 13 PasswordForm* form = new PasswordForm(); |
14 form->scheme = form_data.scheme; | 14 form->scheme = form_data.scheme; |
15 form->preferred = form_data.preferred; | 15 form->preferred = form_data.preferred; |
16 form->ssl_valid = form_data.ssl_valid; | 16 form->ssl_valid = form_data.ssl_valid; |
17 form->date_created = base::Time::FromDoubleT(form_data.creation_time); | 17 form->date_created = base::Time::FromDoubleT(form_data.creation_time); |
18 if (form_data.signon_realm) | 18 if (form_data.signon_realm) |
19 form->signon_realm = std::string(form_data.signon_realm); | 19 form->signon_realm = std::string(form_data.signon_realm); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 << "username_elem: " << form.username_element << std::endl | 62 << "username_elem: " << form.username_element << std::endl |
63 << "password_elem: " << form.password_element << std::endl | 63 << "password_elem: " << form.password_element << std::endl |
64 << "username_value: " << form.username_value << std::endl | 64 << "username_value: " << form.username_value << std::endl |
65 << "password_value: " << form.password_value << std::endl | 65 << "password_value: " << form.password_value << std::endl |
66 << "blacklisted: " << form.blacklisted_by_user << std::endl | 66 << "blacklisted: " << form.blacklisted_by_user << std::endl |
67 << "preferred: " << form.preferred << std::endl | 67 << "preferred: " << form.preferred << std::endl |
68 << "ssl_valid: " << form.ssl_valid << std::endl | 68 << "ssl_valid: " << form.ssl_valid << std::endl |
69 << "date_created: " << form.date_created.ToDoubleT(); | 69 << "date_created: " << form.date_created.ToDoubleT(); |
70 } | 70 } |
71 | 71 |
72 typedef std::set<const webkit_glue::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 SetOfForms expectations(first.begin(), first.end()); |
80 for (unsigned int i = 0; i < second.size(); ++i) { | 80 for (unsigned int i = 0; i < second.size(); ++i) { |
81 const PasswordForm* actual = second[i]; | 81 const PasswordForm* actual = second[i]; |
82 bool found_match = false; | 82 bool found_match = false; |
83 for (SetOfForms::iterator it = expectations.begin(); | 83 for (SetOfForms::iterator it = expectations.begin(); |
84 it != expectations.end(); ++it) { | 84 it != expectations.end(); ++it) { |
85 const PasswordForm* expected = *it; | 85 const PasswordForm* expected = *it; |
86 if (*expected == *actual) { | 86 if (*expected == *actual) { |
87 found_match = true; | 87 found_match = true; |
88 expectations.erase(it); | 88 expectations.erase(it); |
89 break; | 89 break; |
90 } | 90 } |
91 } | 91 } |
92 if (!found_match) { | 92 if (!found_match) { |
93 LOG(ERROR) << "No match for:" << std::endl << *actual; | 93 LOG(ERROR) << "No match for:" << std::endl << *actual; |
94 return false; | 94 return false; |
95 } | 95 } |
96 } | 96 } |
97 return true; | 97 return true; |
98 } | 98 } |
99 | 99 |
100 bool ContainsSamePasswordForms( | 100 bool ContainsSamePasswordForms( |
101 std::vector<webkit_glue::PasswordForm>& first, | 101 std::vector<webkit::forms::PasswordForm>& first, |
102 std::vector<webkit_glue::PasswordForm>& second) { | 102 std::vector<webkit::forms::PasswordForm>& second) { |
103 std::vector<PasswordForm*> first_ptr; | 103 std::vector<PasswordForm*> first_ptr; |
104 for (unsigned int i = 0; i < first.size(); ++i) { | 104 for (unsigned int i = 0; i < first.size(); ++i) { |
105 first_ptr.push_back(&first[i]); | 105 first_ptr.push_back(&first[i]); |
106 } | 106 } |
107 std::vector<PasswordForm*> second_ptr; | 107 std::vector<PasswordForm*> second_ptr; |
108 for (unsigned int i = 0; i < second.size(); ++i) { | 108 for (unsigned int i = 0; i < second.size(); ++i) { |
109 second_ptr.push_back(&second[i]); | 109 second_ptr.push_back(&second[i]); |
110 } | 110 } |
111 return ContainsSamePasswordFormsPtr(first_ptr, second_ptr); | 111 return ContainsSamePasswordFormsPtr(first_ptr, second_ptr); |
112 } | 112 } |
OLD | NEW |