| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 matches_.back().PossiblySwapContentsAndDescriptionForURLSuggestion(input); | 173 matches_.back().PossiblySwapContentsAndDescriptionForURLSuggestion(input); |
| 174 } | 174 } |
| 175 default_match_ = end(); | 175 default_match_ = end(); |
| 176 alternate_nav_url_ = GURL(); | 176 alternate_nav_url_ = GURL(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void AutocompleteResult::SortAndCull( | 179 void AutocompleteResult::SortAndCull( |
| 180 const AutocompleteInput& input, | 180 const AutocompleteInput& input, |
| 181 TemplateURLService* template_url_service) { | 181 TemplateURLService* template_url_service) { |
| 182 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) | 182 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) |
| 183 i->ComputeStrippedDestinationURL(template_url_service); | 183 i->ComputeStrippedDestinationURL(input, template_url_service); |
| 184 | 184 |
| 185 DedupMatchesByDestination(input.current_page_classification(), true, | 185 DedupMatchesByDestination(input.current_page_classification(), true, |
| 186 &matches_); | 186 &matches_); |
| 187 | 187 |
| 188 // Sort and trim to the most relevant kMaxMatches matches. | 188 // Sort and trim to the most relevant kMaxMatches matches. |
| 189 size_t max_num_matches = std::min(kMaxMatches, matches_.size()); | 189 size_t max_num_matches = std::min(kMaxMatches, matches_.size()); |
| 190 CompareWithDemoteByType comparing_object(input.current_page_classification()); | 190 CompareWithDemoteByType comparing_object(input.current_page_classification()); |
| 191 std::sort(matches_.begin(), matches_.end(), comparing_object); | 191 std::sort(matches_.begin(), matches_.end(), comparing_object); |
| 192 if (!matches_.empty() && !matches_.begin()->allowed_to_be_default_match) { | 192 if (!matches_.empty() && !matches_.begin()->allowed_to_be_default_match) { |
| 193 // Top match is not allowed to be the default match. Find the most | 193 // Top match is not allowed to be the default match. Find the most |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 i != old_matches.rend() && delta > 0; ++i) { | 437 i != old_matches.rend() && delta > 0; ++i) { |
| 438 if (!HasMatchByDestination(*i, new_matches)) { | 438 if (!HasMatchByDestination(*i, new_matches)) { |
| 439 AutocompleteMatch match = *i; | 439 AutocompleteMatch match = *i; |
| 440 match.relevance = std::min(max_relevance, match.relevance); | 440 match.relevance = std::min(max_relevance, match.relevance); |
| 441 match.from_previous = true; | 441 match.from_previous = true; |
| 442 matches_.push_back(match); | 442 matches_.push_back(match); |
| 443 delta--; | 443 delta--; |
| 444 } | 444 } |
| 445 } | 445 } |
| 446 } | 446 } |
| OLD | NEW |