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

Unified Diff: components/autofill/core/browser/autocomplete_history_manager.cc

Issue 772253003: Create an autofill Suggestion class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/autocomplete_history_manager.cc
diff --git a/components/autofill/core/browser/autocomplete_history_manager.cc b/components/autofill/core/browser/autocomplete_history_manager.cc
index 8bc497051668ae2a6f381d9329c7d7375dc5591f..1f8fa94b055c6aeadc4405b8ac6c1b10a0a2bed9 100644
--- a/components/autofill/core/browser/autocomplete_history_manager.cc
+++ b/components/autofill/core/browser/autocomplete_history_manager.cc
@@ -82,17 +82,11 @@ void AutocompleteHistoryManager::OnGetAutocompleteSuggestions(
const base::string16& name,
const base::string16& prefix,
const std::string& form_control_type,
- const std::vector<base::string16>& autofill_values,
- const std::vector<base::string16>& autofill_labels,
- const std::vector<base::string16>& autofill_icons,
- const std::vector<int>& autofill_unique_ids) {
+ const std::vector<Suggestion>& suggestions) {
CancelPendingQuery();
query_id_ = query_id;
- autofill_values_ = autofill_values;
- autofill_labels_ = autofill_labels;
- autofill_icons_ = autofill_icons;
- autofill_unique_ids_ = autofill_unique_ids;
+ autofill_suggestions_ = suggestions;
if (!autofill_client_->IsAutocompleteEnabled() ||
form_control_type == "textarea") {
SendSuggestions(NULL);
@@ -161,39 +155,28 @@ void AutocompleteHistoryManager::CancelPendingQuery() {
}
void AutocompleteHistoryManager::SendSuggestions(
- const std::vector<base::string16>* suggestions) {
- if (suggestions) {
+ const std::vector<base::string16>* autocomplete_results) {
+ if (autocomplete_results) {
// Combine Autofill and Autocomplete values into values and labels.
- for (size_t i = 0; i < suggestions->size(); ++i) {
+ for (const auto& new_result : *autocomplete_results) {
bool unique = true;
- for (size_t j = 0; j < autofill_values_.size(); ++j) {
+ for (const auto& autofill_suggestion : autofill_suggestions_) {
// Don't add duplicate values.
- if (autofill_values_[j] == (*suggestions)[i]) {
+ if (new_result == autofill_suggestion.value) {
unique = false;
break;
}
}
- if (unique) {
- autofill_values_.push_back((*suggestions)[i]);
- autofill_labels_.push_back(base::string16());
- autofill_icons_.push_back(base::string16());
- autofill_unique_ids_.push_back(0); // 0 means no profile.
- }
+ if (unique)
+ autofill_suggestions_.push_back(Suggestion(new_result));
}
}
- external_delegate_->OnSuggestionsReturned(query_id_,
- autofill_values_,
- autofill_labels_,
- autofill_icons_,
- autofill_unique_ids_);
+ external_delegate_->OnSuggestionsReturned(query_id_, autofill_suggestions_);
query_id_ = 0;
- autofill_values_.clear();
- autofill_labels_.clear();
- autofill_icons_.clear();
- autofill_unique_ids_.clear();
+ autofill_suggestions_.clear();
}
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698