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_autofill_agent.h" | 5 #include "components/autofill/content/renderer/password_autofill_agent.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 if (!control_element.hasHTMLTagName("input")) | 178 if (!control_element.hasHTMLTagName("input")) |
179 continue; | 179 continue; |
180 | 180 |
181 // Only fill saved passwords into password fields and usernames into text | 181 // Only fill saved passwords into password fields and usernames into text |
182 // fields. | 182 // fields. |
183 const blink::WebInputElement input_element = | 183 const blink::WebInputElement input_element = |
184 control_element.toConst<blink::WebInputElement>(); | 184 control_element.toConst<blink::WebInputElement>(); |
185 if (input_element.isPasswordField() != is_password_field) | 185 if (input_element.isPasswordField() != is_password_field) |
186 continue; | 186 continue; |
187 | 187 |
188 // Avoid autofilling invisible password fields. | |
189 if (input_element.isPasswordField() && | |
190 !form_util::IsWebNodeVisible(input_element)) { | |
191 continue; | |
192 } | |
193 | |
194 // For change password form with ambiguous or empty names keep only the | 188 // For change password form with ambiguous or empty names keep only the |
195 // first password field having |autocomplete='current-password'| attribute | 189 // first password field having |autocomplete='current-password'| attribute |
196 // set. Also make sure we avoid keeping password fields having | 190 // set. Also make sure we avoid keeping password fields having |
197 // |autocomplete='new-password'| attribute set. | 191 // |autocomplete='new-password'| attribute set. |
198 if (ambiguous_and_multiple_password_fields_with_autocomplete && | 192 if (ambiguous_and_multiple_password_fields_with_autocomplete && |
199 !HasAutocompleteAttributeValue(input_element, "current-password")) { | 193 !HasAutocompleteAttributeValue(input_element, "current-password")) { |
200 continue; | 194 continue; |
201 } | 195 } |
202 | 196 |
203 // Check for a non-unique match. | 197 // Check for a non-unique match. |
204 if (found_input) { | 198 if (found_input) { |
205 // For change password form keep only the first password field entry. | 199 // For change password form keep only the first password field entry. |
206 if (does_password_field_has_ambigous_or_empty_name) | 200 if (does_password_field_has_ambigous_or_empty_name) { |
201 if (!form_util::IsWebNodeVisible((*result)[field_name])) { | |
vabr (Chromium)
2015/11/05 15:20:25
Is this code path tested? The added test does not
dvadym
2015/11/05 16:18:26
It's tested in previously added test AutofillSugge
vabr (Chromium)
2015/11/05 16:29:46
Acknowledged.
| |
202 // If a previously chosen field was invisible then take the current | |
203 // one. | |
204 (*result)[field_name] = input_element; | |
205 } | |
207 continue; | 206 continue; |
207 } | |
208 | 208 |
209 found_input = false; | 209 found_input = false; |
210 break; | 210 break; |
211 } | 211 } |
212 | 212 |
213 (*result)[field_name] = input_element; | 213 (*result)[field_name] = input_element; |
214 found_input = true; | 214 found_input = true; |
215 } | 215 } |
216 | 216 |
217 // A required element was not found. This is not the right form. | 217 // A required element was not found. This is not the right form. |
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1521 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::OnDestruct() { | 1521 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::OnDestruct() { |
1522 // No op. Do not delete |this|. | 1522 // No op. Do not delete |this|. |
1523 } | 1523 } |
1524 | 1524 |
1525 void PasswordAutofillAgent::LegacyPasswordAutofillAgent:: | 1525 void PasswordAutofillAgent::LegacyPasswordAutofillAgent:: |
1526 DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) { | 1526 DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) { |
1527 agent_->LegacyDidStartProvisionalLoad(navigated_frame); | 1527 agent_->LegacyDidStartProvisionalLoad(navigated_frame); |
1528 } | 1528 } |
1529 | 1529 |
1530 } // namespace autofill | 1530 } // namespace autofill |
OLD | NEW |