Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/omnibox/autocomplete_result.h" | 5 #include "components/omnibox/autocomplete_result.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 old_matches.BuildProviderToMatches(&old_matches_per_provider); | 154 old_matches.BuildProviderToMatches(&old_matches_per_provider); |
| 155 for (ProviderToMatches::const_iterator i(old_matches_per_provider.begin()); | 155 for (ProviderToMatches::const_iterator i(old_matches_per_provider.begin()); |
| 156 i != old_matches_per_provider.end(); ++i) { | 156 i != old_matches_per_provider.end(); ++i) { |
| 157 MergeMatchesByProvider(input.current_page_classification(), | 157 MergeMatchesByProvider(input.current_page_classification(), |
| 158 i->second, matches_per_provider[i->first]); | 158 i->second, matches_per_provider[i->first]); |
| 159 } | 159 } |
| 160 | 160 |
| 161 SortAndCull(input, template_url_service); | 161 SortAndCull(input, template_url_service); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void AutocompleteResult::AppendMatches(const ACMatches& matches) { | 164 void AutocompleteResult::AppendMatches(const AutocompleteInput& input, |
| 165 const ACMatches& matches) { | |
| 166 for (ACMatches::const_iterator i(matches.begin()); i != matches.end(); ++i) { | |
|
Peter Kasting
2015/05/22 23:39:36
Nit: Range-based for?
Mark P
2015/05/23 20:32:13
Okay. Done.
| |
| 165 #ifndef NDEBUG | 167 #ifndef NDEBUG |
| 166 for (ACMatches::const_iterator i(matches.begin()); i != matches.end(); ++i) { | |
| 167 DCHECK_EQ(AutocompleteMatch::SanitizeString(i->contents), i->contents); | 168 DCHECK_EQ(AutocompleteMatch::SanitizeString(i->contents), i->contents); |
| 168 DCHECK_EQ(AutocompleteMatch::SanitizeString(i->description), | 169 DCHECK_EQ(AutocompleteMatch::SanitizeString(i->description), |
| 169 i->description); | 170 i->description); |
| 171 #endif | |
| 172 matches_.push_back(*i); | |
| 173 matches_.back().PossiblySwapContentsAndDescriptionForURLSuggestion(input); | |
| 170 } | 174 } |
| 171 #endif | |
| 172 std::copy(matches.begin(), matches.end(), std::back_inserter(matches_)); | |
| 173 default_match_ = end(); | 175 default_match_ = end(); |
| 174 alternate_nav_url_ = GURL(); | 176 alternate_nav_url_ = GURL(); |
| 175 } | 177 } |
| 176 | 178 |
| 177 void AutocompleteResult::SortAndCull( | 179 void AutocompleteResult::SortAndCull( |
| 178 const AutocompleteInput& input, | 180 const AutocompleteInput& input, |
| 179 TemplateURLService* template_url_service) { | 181 TemplateURLService* template_url_service) { |
| 180 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) | 182 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) |
| 181 i->ComputeStrippedDestinationURL(template_url_service); | 183 i->ComputeStrippedDestinationURL(template_url_service); |
| 182 | 184 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 i != old_matches.rend() && delta > 0; ++i) { | 442 i != old_matches.rend() && delta > 0; ++i) { |
| 441 if (!HasMatchByDestination(*i, new_matches)) { | 443 if (!HasMatchByDestination(*i, new_matches)) { |
| 442 AutocompleteMatch match = *i; | 444 AutocompleteMatch match = *i; |
| 443 match.relevance = std::min(max_relevance, match.relevance); | 445 match.relevance = std::min(max_relevance, match.relevance); |
| 444 match.from_previous = true; | 446 match.from_previous = true; |
| 445 matches_.push_back(match); | 447 matches_.push_back(match); |
| 446 delta--; | 448 delta--; |
| 447 } | 449 } |
| 448 } | 450 } |
| 449 } | 451 } |
| OLD | NEW |