| 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/core/browser/autofill_manager.h" | 5 #include "components/autofill/core/browser/autofill_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 !value.empty() && | 573 !value.empty() && |
| 574 (result.fields[i] == field || | 574 (result.fields[i] == field || |
| 575 result.fields[i].form_control_type == "select-one" || | 575 result.fields[i].form_control_type == "select-one" || |
| 576 result.fields[i].value.empty()); | 576 result.fields[i].value.empty()); |
| 577 if (AutofillField::FillFormField( | 577 if (AutofillField::FillFormField( |
| 578 *cached_field, value, app_locale_, &result.fields[i])) { | 578 *cached_field, value, app_locale_, &result.fields[i])) { |
| 579 // Mark the cached field as autofilled, so that we can detect when a | 579 // Mark the cached field as autofilled, so that we can detect when a |
| 580 // user edits an autofilled field (for metrics). | 580 // user edits an autofilled field (for metrics). |
| 581 form_structure->field(i)->is_autofilled = true; | 581 form_structure->field(i)->is_autofilled = true; |
| 582 | 582 |
| 583 // Mark the field as autofilled when a non-empty value is assigned to |
| 584 // it. This allows the renderer to distinguish autofilled fields from |
| 585 // fields with non-empty values, such as select-one fields. |
| 586 result.fields[i].is_autofilled = true; |
| 587 |
| 583 if (should_notify) | 588 if (should_notify) |
| 584 manager_delegate_->DidFillOrPreviewField(value, profile_full_name); | 589 manager_delegate_->DidFillOrPreviewField(value, profile_full_name); |
| 585 } | 590 } |
| 586 } | 591 } |
| 587 } | 592 } |
| 588 | 593 |
| 589 autofilled_form_signatures_.push_front(form_structure->FormSignature()); | 594 autofilled_form_signatures_.push_front(form_structure->FormSignature()); |
| 590 // Only remember the last few forms that we've seen, both to avoid false | 595 // Only remember the last few forms that we've seen, both to avoid false |
| 591 // positives and to avoid wasting memory. | 596 // positives and to avoid wasting memory. |
| 592 if (autofilled_form_signatures_.size() > kMaxRecentFormSignaturesToRemember) | 597 if (autofilled_form_signatures_.size() > kMaxRecentFormSignaturesToRemember) |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 return false; | 1165 return false; |
| 1161 | 1166 |
| 1162 // Disregard forms that we wouldn't ever autofill in the first place. | 1167 // Disregard forms that we wouldn't ever autofill in the first place. |
| 1163 if (!form.ShouldBeParsed(true)) | 1168 if (!form.ShouldBeParsed(true)) |
| 1164 return false; | 1169 return false; |
| 1165 | 1170 |
| 1166 return true; | 1171 return true; |
| 1167 } | 1172 } |
| 1168 | 1173 |
| 1169 } // namespace autofill | 1174 } // namespace autofill |
| OLD | NEW |