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/content/renderer/password_form_conversion_utils.h" | 5 #include "components/autofill/content/renderer/password_form_conversion_utils.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 | 136 |
137 if (passwords.empty()) | 137 if (passwords.empty()) |
138 return false; | 138 return false; |
139 | 139 |
140 switch (passwords.size()) { | 140 switch (passwords.size()) { |
141 case 1: | 141 case 1: |
142 // Single password, easy. | 142 // Single password, easy. |
143 *current_password = passwords[0]; | 143 *current_password = passwords[0]; |
144 break; | 144 break; |
145 case 2: | 145 case 2: |
146 if (passwords[0].value() == passwords[1].value()) { | 146 if (!passwords[0].value().isEmpty() && |
Garrett Casto
2015/06/12 00:09:09
Can you add a test for this?
dvadym
2015/06/12 17:22:37
Done. I've fixed corresponding test in password_fo
| |
147 // Two identical passwords: assume we are seeing a new password with a | 147 passwords[0].value() == passwords[1].value()) { |
148 // confirmation. This can be either a sign-up form or a password change | 148 // Two identical non-empty passwords: assume we are seeing a new |
149 // form that does not ask for the old password. | 149 // password with a confirmation. This can be either a sign-up form or a |
150 // password change form that does not ask for the old password. | |
150 *new_password = passwords[0]; | 151 *new_password = passwords[0]; |
151 } else { | 152 } else { |
152 // Assume first is old password, second is new (no choice but to guess). | 153 // Assume first is old password, second is new (no choice but to guess). |
154 // This case also includes empty passwords in order to allow filling of | |
155 // password change forms (that also could autofill for sign up form, but | |
156 // we can't do anything with this using only client side information). | |
153 *current_password = passwords[0]; | 157 *current_password = passwords[0]; |
154 *new_password = passwords[1]; | 158 *new_password = passwords[1]; |
155 } | 159 } |
156 break; | 160 break; |
157 default: | 161 default: |
158 if (!passwords[0].value().isEmpty() && | 162 if (!passwords[0].value().isEmpty() && |
159 passwords[0].value() == passwords[1].value() && | 163 passwords[0].value() == passwords[1].value() && |
160 passwords[0].value() == passwords[2].value()) { | 164 passwords[0].value() == passwords[2].value()) { |
161 // All three passwords are the same and non-empty? This does not make | 165 // All three passwords are the same and non-empty? This does not make |
162 // any sense, give up. | 166 // any sense, give up. |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
482 WebFormElementToFormData(web_form, | 486 WebFormElementToFormData(web_form, |
483 blink::WebFormControlElement(), | 487 blink::WebFormControlElement(), |
484 EXTRACT_NONE, | 488 EXTRACT_NONE, |
485 &password_form->form_data, | 489 &password_form->form_data, |
486 NULL /* FormFieldData */); | 490 NULL /* FormFieldData */); |
487 | 491 |
488 return password_form.Pass(); | 492 return password_form.Pass(); |
489 } | 493 } |
490 | 494 |
491 } // namespace autofill | 495 } // namespace autofill |
OLD | NEW |