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/form_cache.h" | 5 #include "components/autofill/content/renderer/form_cache.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 | 59 |
60 // Determines whether the form is interesting enough to send to the browser | 60 // Determines whether the form is interesting enough to send to the browser |
61 // for further operations. | 61 // for further operations. |
62 bool IsFormInteresting(const FormData& form, size_t num_editable_elements) { | 62 bool IsFormInteresting(const FormData& form, size_t num_editable_elements) { |
63 if (form.fields.empty()) | 63 if (form.fields.empty()) |
64 return false; | 64 return false; |
65 | 65 |
66 // If the form has at least one field with an autocomplete attribute, it is a | 66 // If the form has at least one field with an autocomplete attribute, it is a |
67 // candidate for autofill. | 67 // candidate for autofill. |
| 68 bool all_fields_are_passwords = true; |
68 for (const FormFieldData& field : form.fields) { | 69 for (const FormFieldData& field : form.fields) { |
69 if (!field.autocomplete_attribute.empty()) | 70 if (!field.autocomplete_attribute.empty()) |
70 return true; | 71 return true; |
| 72 if (field.form_control_type != "password") |
| 73 all_fields_are_passwords = false; |
71 } | 74 } |
72 | 75 |
73 // If there are no autocomplete attributes, the form needs to have at least | 76 // If there are no autocomplete attributes, the form needs to have at least |
74 // the required number of editable fields for the prediction routines to be a | 77 // the required number of editable fields for the prediction routines to be a |
75 // candidate for autofill. | 78 // candidate for autofill. |
76 return num_editable_elements >= kRequiredFieldsForPredictionRoutines; | 79 return num_editable_elements >= kRequiredFieldsForPredictionRoutines || |
| 80 (all_fields_are_passwords && |
| 81 num_editable_elements >= |
| 82 kRequiredFieldsForFormsWithOnlyPasswordFields); |
77 } | 83 } |
78 | 84 |
79 } // namespace | 85 } // namespace |
80 | 86 |
81 FormCache::FormCache(const WebFrame& frame) : frame_(frame) { | 87 FormCache::FormCache(const WebFrame& frame) : frame_(frame) { |
82 } | 88 } |
83 | 89 |
84 FormCache::~FormCache() { | 90 FormCache::~FormCache() { |
85 } | 91 } |
86 | 92 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 const WebInputElement* input_element = toWebInputElement(&element); | 355 const WebInputElement* input_element = toWebInputElement(&element); |
350 if (form_util::IsCheckableElement(input_element)) { | 356 if (form_util::IsCheckableElement(input_element)) { |
351 initial_checked_state_.insert( | 357 initial_checked_state_.insert( |
352 std::make_pair(*input_element, input_element->isChecked())); | 358 std::make_pair(*input_element, input_element->isChecked())); |
353 } | 359 } |
354 } | 360 } |
355 } | 361 } |
356 } | 362 } |
357 | 363 |
358 } // namespace autofill | 364 } // namespace autofill |
OLD | NEW |