Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: components/autofill/core/browser/autocomplete_history_manager.cc

Issue 1104543006: Style cleanups in Autofill for greater code clarity. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 if (!form.user_submitted) 117 if (!form.user_submitted)
118 return; 118 return;
119 119
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
128 // AutofillManager)
127 std::vector<FormFieldData> values; 129 std::vector<FormFieldData> values;
128 for (std::vector<FormFieldData>::const_iterator iter = 130 for (const FormFieldData& field : form.fields) {
129 form.fields.begin(); 131 if (!field.value.empty() && !field.name.empty() && IsTextField(field) &&
130 iter != form.fields.end(); ++iter) { 132 field.should_autocomplete &&
131 if (!iter->value.empty() && 133 !autofill::IsValidCreditCardNumber(field.value) &&
132 !iter->name.empty() && 134 !autofill::IsSSN(field.value)) {
133 IsTextField(*iter) && 135 values.push_back(field);
134 iter->should_autocomplete &&
135 !autofill::IsValidCreditCardNumber(iter->value) &&
136 !autofill::IsSSN(iter->value)) {
137 values.push_back(*iter);
138 } 136 }
139 } 137 }
140 138
141 if (!values.empty() && database_.get()) 139 if (!values.empty() && database_.get())
142 database_->AddFormFields(values); 140 database_->AddFormFields(values);
143 } 141 }
144 142
145 void AutocompleteHistoryManager::OnRemoveAutocompleteEntry( 143 void AutocompleteHistoryManager::OnRemoveAutocompleteEntry(
146 const base::string16& name, const base::string16& value) { 144 const base::string16& name, const base::string16& value) {
147 if (database_.get()) 145 if (database_.get())
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 178 }
181 } 179 }
182 180
183 external_delegate_->OnSuggestionsReturned(query_id_, autofill_suggestions_); 181 external_delegate_->OnSuggestionsReturned(query_id_, autofill_suggestions_);
184 182
185 query_id_ = 0; 183 query_id_ = 0;
186 autofill_suggestions_.clear(); 184 autofill_suggestions_.clear();
187 } 185 }
188 186
189 } // namespace autofill 187 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/core/browser/credit_card.cc » ('j') | components/autofill/core/browser/form_structure.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698