OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/autocomplete/search_provider.h" | 5 #include "chrome/browser/autocomplete/search_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
650 matches_.begin() + std::min(max_total_matches, matches_.size()), | 650 matches_.begin() + std::min(max_total_matches, matches_.size()), |
651 matches_.end(), &AutocompleteMatch::MoreRelevant); | 651 matches_.end(), &AutocompleteMatch::MoreRelevant); |
652 if (matches_.size() > max_total_matches) | 652 if (matches_.size() > max_total_matches) |
653 matches_.erase(matches_.begin() + max_total_matches, matches_.end()); | 653 matches_.erase(matches_.begin() + max_total_matches, matches_.end()); |
654 | 654 |
655 UpdateStarredStateOfMatches(); | 655 UpdateStarredStateOfMatches(); |
656 UpdateDone(); | 656 UpdateDone(); |
657 } | 657 } |
658 | 658 |
659 void SearchProvider::AddNavigationResultsToMatches( | 659 void SearchProvider::AddNavigationResultsToMatches( |
660 const NavigationResults& navigation_results, | 660 NavigationResults navigation_results, |
661 bool is_keyword) { | 661 bool is_keyword) { |
662 std::stable_sort(navigation_results.begin(), navigation_results.end(), | |
Peter Kasting
2012/05/14 20:29:19
Use std::max_element() instead of sorting and then
msw
2012/05/15 01:00:29
Done.
| |
663 CompareScoredResults()); | |
662 if (!navigation_results.empty()) { | 664 if (!navigation_results.empty()) { |
663 // TODO(kochi): http://b/1170574 We add only one results for navigational | 665 // TODO(kochi|msw): Add more navigational results if they get more |
664 // suggestions. If we can get more useful information about the score, | 666 // meaningful relevance values; see http://b/1170574. |
665 // consider adding more results. | |
666 matches_.push_back( | 667 matches_.push_back( |
667 NavigationToMatch(navigation_results.front(), is_keyword)); | 668 NavigationToMatch(navigation_results.front(), is_keyword)); |
668 } | 669 } |
669 } | 670 } |
670 | 671 |
671 void SearchProvider::AddHistoryResultsToMap(const HistoryResults& results, | 672 void SearchProvider::AddHistoryResultsToMap(const HistoryResults& results, |
672 bool is_keyword, | 673 bool is_keyword, |
673 int did_not_accept_suggestion, | 674 int did_not_accept_suggestion, |
674 MatchMap* map) { | 675 MatchMap* map) { |
675 if (results.empty()) | 676 if (results.empty()) |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
975 | 976 |
976 return match; | 977 return match; |
977 } | 978 } |
978 | 979 |
979 void SearchProvider::UpdateDone() { | 980 void SearchProvider::UpdateDone() { |
980 // We're done when there are no more suggest queries pending (this is set to 1 | 981 // We're done when there are no more suggest queries pending (this is set to 1 |
981 // when the timer is started) and we're not waiting on instant. | 982 // when the timer is started) and we're not waiting on instant. |
982 done_ = ((suggest_results_pending_ == 0) && | 983 done_ = ((suggest_results_pending_ == 0) && |
983 (instant_finalized_ || !InstantController::IsEnabled(profile_))); | 984 (instant_finalized_ || !InstantController::IsEnabled(profile_))); |
984 } | 985 } |
OLD | NEW |