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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 170 } |
171 #endif | 171 #endif |
172 std::copy(matches.begin(), matches.end(), std::back_inserter(matches_)); | 172 std::copy(matches.begin(), matches.end(), std::back_inserter(matches_)); |
173 default_match_ = end(); | 173 default_match_ = end(); |
174 alternate_nav_url_ = GURL(); | 174 alternate_nav_url_ = GURL(); |
175 } | 175 } |
176 | 176 |
177 void AutocompleteResult::SortAndCull( | 177 void AutocompleteResult::SortAndCull( |
178 const AutocompleteInput& input, | 178 const AutocompleteInput& input, |
179 TemplateURLService* template_url_service) { | 179 TemplateURLService* template_url_service) { |
180 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) | 180 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { |
181 i->ComputeStrippedDestinationURL(template_url_service); | 181 i->ComputeStrippedDestinationURL( |
| 182 input.parts().scheme.is_nonempty(), template_url_service); |
| 183 } |
182 | 184 |
183 DedupMatchesByDestination(input.current_page_classification(), true, | 185 DedupMatchesByDestination(input.current_page_classification(), true, |
184 &matches_); | 186 &matches_); |
185 | 187 |
186 // Sort and trim to the most relevant kMaxMatches matches. | 188 // Sort and trim to the most relevant kMaxMatches matches. |
187 size_t max_num_matches = std::min(kMaxMatches, matches_.size()); | 189 size_t max_num_matches = std::min(kMaxMatches, matches_.size()); |
188 CompareWithDemoteByType comparing_object(input.current_page_classification()); | 190 CompareWithDemoteByType comparing_object(input.current_page_classification()); |
189 std::sort(matches_.begin(), matches_.end(), comparing_object); | 191 std::sort(matches_.begin(), matches_.end(), comparing_object); |
190 if (!matches_.empty() && !matches_.begin()->allowed_to_be_default_match) { | 192 if (!matches_.empty() && !matches_.begin()->allowed_to_be_default_match) { |
191 // 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 248 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 |