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() && |
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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 WebFormElementToFormData(web_form, | 490 WebFormElementToFormData(web_form, |
487 blink::WebFormControlElement(), | 491 blink::WebFormControlElement(), |
488 EXTRACT_NONE, | 492 EXTRACT_NONE, |
489 &password_form->form_data, | 493 &password_form->form_data, |
490 NULL /* FormFieldData */); | 494 NULL /* FormFieldData */); |
491 | 495 |
492 return password_form.Pass(); | 496 return password_form.Pass(); |
493 } | 497 } |
494 | 498 |
495 } // namespace autofill | 499 } // namespace autofill |
OLD | NEW |