| 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/autocomplete_history_manager.h" | 5 #include "components/autofill/core/browser/autocomplete_history_manager.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/profiler/scoped_tracker.h" | 10 #include "base/profiler/scoped_tracker.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // We put the following restriction on stored FormFields: | 120 // We put the following restriction on stored FormFields: |
| 121 // - non-empty name | 121 // - non-empty name |
| 122 // - non-empty value | 122 // - non-empty value |
| 123 // - text field | 123 // - text field |
| 124 // - autocomplete is not disabled | 124 // - autocomplete is not disabled |
| 125 // - value is not a credit card number | 125 // - value is not a credit card number |
| 126 // - value is not a SSN | 126 // - value is not a SSN |
| 127 // - field was not identified as a CVC field (this is handled in | 127 // - field was not identified as a CVC field (this is handled in |
| 128 // AutofillManager) | 128 // AutofillManager) |
| 129 std::vector<FormFieldData> values; | 129 std::vector<FormFieldData> values; |
| 130 for (std::vector<FormFieldData>::const_iterator iter = | 130 for (const FormFieldData& field : form.fields) { |
| 131 form.fields.begin(); | 131 if (!field.value.empty() && !field.name.empty() && IsTextField(field) && |
| 132 iter != form.fields.end(); ++iter) { | 132 field.should_autocomplete && |
| 133 if (!iter->value.empty() && | 133 !autofill::IsValidCreditCardNumber(field.value) && |
| 134 !iter->name.empty() && | 134 !autofill::IsSSN(field.value)) { |
| 135 IsTextField(*iter) && | 135 values.push_back(field); |
| 136 iter->should_autocomplete && | |
| 137 !autofill::IsValidCreditCardNumber(iter->value) && | |
| 138 !autofill::IsSSN(iter->value)) { | |
| 139 values.push_back(*iter); | |
| 140 } | 136 } |
| 141 } | 137 } |
| 142 | 138 |
| 143 if (!values.empty() && database_.get()) | 139 if (!values.empty() && database_.get()) |
| 144 database_->AddFormFields(values); | 140 database_->AddFormFields(values); |
| 145 } | 141 } |
| 146 | 142 |
| 147 void AutocompleteHistoryManager::OnRemoveAutocompleteEntry( | 143 void AutocompleteHistoryManager::OnRemoveAutocompleteEntry( |
| 148 const base::string16& name, const base::string16& value) { | 144 const base::string16& name, const base::string16& value) { |
| 149 if (database_.get()) | 145 if (database_.get()) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 178 } |
| 183 } | 179 } |
| 184 | 180 |
| 185 external_delegate_->OnSuggestionsReturned(query_id_, autofill_suggestions_); | 181 external_delegate_->OnSuggestionsReturned(query_id_, autofill_suggestions_); |
| 186 | 182 |
| 187 query_id_ = 0; | 183 query_id_ = 0; |
| 188 autofill_suggestions_.clear(); | 184 autofill_suggestions_.clear(); |
| 189 } | 185 } |
| 190 | 186 |
| 191 } // namespace autofill | 187 } // namespace autofill |
| OLD | NEW |