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 content::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::forms::PasswordForm*> SetOfForms; | 72 typedef std::set<const content::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 | 79 |
80 // TODO(cramya): As per b/7079906, the STLport of Android causes a crash | 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 | 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. | 82 // into a set rather than std::copy that is used below. |
(...skipping 15 matching lines...) Expand all Loading... |
98 } | 98 } |
99 if (!found_match) { | 99 if (!found_match) { |
100 LOG(ERROR) << "No match for:" << std::endl << *actual; | 100 LOG(ERROR) << "No match for:" << std::endl << *actual; |
101 return false; | 101 return false; |
102 } | 102 } |
103 } | 103 } |
104 return true; | 104 return true; |
105 } | 105 } |
106 | 106 |
107 bool ContainsSamePasswordForms( | 107 bool ContainsSamePasswordForms( |
108 std::vector<webkit::forms::PasswordForm>& first, | 108 std::vector<content::PasswordForm>& first, |
109 std::vector<webkit::forms::PasswordForm>& second) { | 109 std::vector<content::PasswordForm>& second) { |
110 std::vector<PasswordForm*> first_ptr; | 110 std::vector<PasswordForm*> first_ptr; |
111 for (unsigned int i = 0; i < first.size(); ++i) { | 111 for (unsigned int i = 0; i < first.size(); ++i) { |
112 first_ptr.push_back(&first[i]); | 112 first_ptr.push_back(&first[i]); |
113 } | 113 } |
114 std::vector<PasswordForm*> second_ptr; | 114 std::vector<PasswordForm*> second_ptr; |
115 for (unsigned int i = 0; i < second.size(); ++i) { | 115 for (unsigned int i = 0; i < second.size(); ++i) { |
116 second_ptr.push_back(&second[i]); | 116 second_ptr.push_back(&second[i]); |
117 } | 117 } |
118 return ContainsSamePasswordFormsPtr(first_ptr, second_ptr); | 118 return ContainsSamePasswordFormsPtr(first_ptr, second_ptr); |
119 } | 119 } |
OLD | NEW |