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

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

Issue 16154031: Un-refcount AutofillWebData and TokenWebData (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on ToT Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/autocomplete_history_manager.h" 5 #include "components/autofill/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/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 query_id_ = query_id; 110 query_id_ = query_id;
111 autofill_values_ = autofill_values; 111 autofill_values_ = autofill_values;
112 autofill_labels_ = autofill_labels; 112 autofill_labels_ = autofill_labels;
113 autofill_icons_ = autofill_icons; 113 autofill_icons_ = autofill_icons;
114 autofill_unique_ids_ = autofill_unique_ids; 114 autofill_unique_ids_ = autofill_unique_ids;
115 if (!*autofill_enabled_) { 115 if (!*autofill_enabled_) {
116 SendSuggestions(NULL); 116 SendSuggestions(NULL);
117 return; 117 return;
118 } 118 }
119 119
120 if (autofill_data_.get()) { 120 if (autofill_data_) {
121 pending_query_handle_ = autofill_data_->GetFormValuesForElementName( 121 pending_query_handle_ = autofill_data_->GetFormValuesForElementName(
122 name, prefix, kMaxAutocompleteMenuItems, this); 122 name, prefix, kMaxAutocompleteMenuItems, this);
123 } 123 }
124 } 124 }
125 125
126 void AutocompleteHistoryManager::OnFormSubmitted(const FormData& form) { 126 void AutocompleteHistoryManager::OnFormSubmitted(const FormData& form) {
127 if (!*autofill_enabled_) 127 if (!*autofill_enabled_)
128 return; 128 return;
129 129
130 if (browser_context_->IsOffTheRecord()) 130 if (browser_context_->IsOffTheRecord())
(...skipping 15 matching lines...) Expand all
146 iter != form.fields.end(); ++iter) { 146 iter != form.fields.end(); ++iter) {
147 if (!iter->value.empty() && 147 if (!iter->value.empty() &&
148 !iter->name.empty() && 148 !iter->name.empty() &&
149 IsTextField(*iter) && 149 IsTextField(*iter) &&
150 !autofill::IsValidCreditCardNumber(iter->value) && 150 !autofill::IsValidCreditCardNumber(iter->value) &&
151 !autofill::IsSSN(iter->value)) { 151 !autofill::IsSSN(iter->value)) {
152 values.push_back(*iter); 152 values.push_back(*iter);
153 } 153 }
154 } 154 }
155 155
156 if (!values.empty() && autofill_data_.get()) 156 if (!values.empty() && autofill_data_)
157 autofill_data_->AddFormFields(values); 157 autofill_data_->AddFormFields(values);
158 } 158 }
159 159
160 void AutocompleteHistoryManager::OnRemoveAutocompleteEntry( 160 void AutocompleteHistoryManager::OnRemoveAutocompleteEntry(
161 const base::string16& name, const base::string16& value) { 161 const base::string16& name, const base::string16& value) {
162 if (autofill_data_.get()) 162 if (autofill_data_)
163 autofill_data_->RemoveFormValueForElementName(name, value); 163 autofill_data_->RemoveFormValueForElementName(name, value);
164 } 164 }
165 165
166 void AutocompleteHistoryManager::SetExternalDelegate( 166 void AutocompleteHistoryManager::SetExternalDelegate(
167 AutofillExternalDelegate* delegate) { 167 AutofillExternalDelegate* delegate) {
168 external_delegate_ = delegate; 168 external_delegate_ = delegate;
169 } 169 }
170 170
171 void AutocompleteHistoryManager::CancelPendingQuery() { 171 void AutocompleteHistoryManager::CancelPendingQuery() {
172 if (pending_query_handle_) { 172 if (pending_query_handle_) {
173 if (autofill_data_.get()) 173 if (autofill_data_)
174 autofill_data_->CancelRequest(pending_query_handle_); 174 autofill_data_->CancelRequest(pending_query_handle_);
175 pending_query_handle_ = 0; 175 pending_query_handle_ = 0;
176 } 176 }
177 } 177 }
178 178
179 void AutocompleteHistoryManager::SendSuggestions( 179 void AutocompleteHistoryManager::SendSuggestions(
180 const std::vector<base::string16>* suggestions) { 180 const std::vector<base::string16>* suggestions) {
181 if (suggestions) { 181 if (suggestions) {
182 // Combine Autofill and Autocomplete values into values and labels. 182 // Combine Autofill and Autocomplete values into values and labels.
183 for (size_t i = 0; i < suggestions->size(); ++i) { 183 for (size_t i = 0; i < suggestions->size(); ++i) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 216 }
217 217
218 query_id_ = 0; 218 query_id_ = 0;
219 autofill_values_.clear(); 219 autofill_values_.clear();
220 autofill_labels_.clear(); 220 autofill_labels_.clear();
221 autofill_icons_.clear(); 221 autofill_icons_.clear();
222 autofill_unique_ids_.clear(); 222 autofill_unique_ids_.clear();
223 } 223 }
224 224
225 } // namespace autofill 225 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698