| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 query_id_ = query_id; | 96 query_id_ = query_id; |
| 97 autofill_suggestions_ = suggestions; | 97 autofill_suggestions_ = suggestions; |
| 98 if (!autofill_client_->IsAutocompleteEnabled() || | 98 if (!autofill_client_->IsAutocompleteEnabled() || |
| 99 form_control_type == "textarea" || | 99 form_control_type == "textarea" || |
| 100 IsInAutofillSuggestionsDisabledExperiment()) { | 100 IsInAutofillSuggestionsDisabledExperiment()) { |
| 101 SendSuggestions(NULL); | 101 SendSuggestions(NULL); |
| 102 return; | 102 return; |
| 103 } | 103 } |
| 104 | 104 |
| 105 if (database_.get()) { | 105 if (database_.get()) { |
| 106 pending_query_prefix_ = prefix; |
| 106 pending_query_handle_ = database_->GetFormValuesForElementName( | 107 pending_query_handle_ = database_->GetFormValuesForElementName( |
| 107 name, prefix, kMaxAutocompleteMenuItems, this); | 108 name, prefix, kMaxAutocompleteMenuItems, this); |
| 108 } | 109 } |
| 109 } | 110 } |
| 110 | 111 |
| 111 void AutocompleteHistoryManager::OnFormSubmitted(const FormData& form) { | 112 void AutocompleteHistoryManager::OnFormSubmitted(const FormData& form) { |
| 112 if (!autofill_client_->IsAutocompleteEnabled()) | 113 if (!autofill_client_->IsAutocompleteEnabled()) |
| 113 return; | 114 return; |
| 114 | 115 |
| 115 if (driver_->IsOffTheRecord()) | 116 if (driver_->IsOffTheRecord()) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 for (const auto& new_result : *autocomplete_results) { | 169 for (const auto& new_result : *autocomplete_results) { |
| 169 bool unique = true; | 170 bool unique = true; |
| 170 for (const auto& autofill_suggestion : autofill_suggestions_) { | 171 for (const auto& autofill_suggestion : autofill_suggestions_) { |
| 171 // Don't add duplicate values. | 172 // Don't add duplicate values. |
| 172 if (new_result == autofill_suggestion.value) { | 173 if (new_result == autofill_suggestion.value) { |
| 173 unique = false; | 174 unique = false; |
| 174 break; | 175 break; |
| 175 } | 176 } |
| 176 } | 177 } |
| 177 | 178 |
| 178 if (unique) | 179 if (unique) { |
| 179 autofill_suggestions_.push_back(Suggestion(new_result)); | 180 Suggestion s(new_result); |
| 181 s.match_start = pending_query_prefix_.size(); |
| 182 autofill_suggestions_.push_back(s); |
| 183 } |
| 180 } | 184 } |
| 181 } | 185 } |
| 182 | 186 |
| 183 external_delegate_->OnSuggestionsReturned(query_id_, autofill_suggestions_); | 187 external_delegate_->OnSuggestionsReturned(query_id_, autofill_suggestions_); |
| 184 | 188 |
| 185 query_id_ = 0; | 189 query_id_ = 0; |
| 186 autofill_suggestions_.clear(); | 190 autofill_suggestions_.clear(); |
| 187 } | 191 } |
| 188 | 192 |
| 189 } // namespace autofill | 193 } // namespace autofill |
| OLD | NEW |