Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: chrome/browser/autocomplete/search_provider.cc

Issue 10381121: Add SearchProvider's most relevant NavigationResult to |matches_|. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use max_element instead of sorting results. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/autocomplete/search_provider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 const NavigationResults& navigation_results,
661 bool is_keyword) { 661 bool is_keyword) {
662 if (!navigation_results.empty()) { 662 if (!navigation_results.empty()) {
663 // TODO(kochi): http://b/1170574 We add only one results for navigational 663 // TODO(kochi|msw): Add more navigational results if they get more
664 // suggestions. If we can get more useful information about the score, 664 // meaningful relevance values; see http://b/1170574.
665 // consider adding more results. 665 NavigationResults::const_iterator result(
666 matches_.push_back( 666 std::max_element(navigation_results.begin(),
667 NavigationToMatch(navigation_results.front(), is_keyword)); 667 navigation_results.end(),
668 CompareScoredResults()));
669 matches_.push_back(NavigationToMatch(*result, is_keyword));
668 } 670 }
669 } 671 }
670 672
671 void SearchProvider::AddHistoryResultsToMap(const HistoryResults& results, 673 void SearchProvider::AddHistoryResultsToMap(const HistoryResults& results,
672 bool is_keyword, 674 bool is_keyword,
673 int did_not_accept_suggestion, 675 int did_not_accept_suggestion,
674 MatchMap* map) { 676 MatchMap* map) {
675 if (results.empty()) 677 if (results.empty())
676 return; 678 return;
677 679
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 977
976 return match; 978 return match;
977 } 979 }
978 980
979 void SearchProvider::UpdateDone() { 981 void SearchProvider::UpdateDone() {
980 // We're done when there are no more suggest queries pending (this is set to 1 982 // 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. 983 // when the timer is started) and we're not waiting on instant.
982 done_ = ((suggest_results_pending_ == 0) && 984 done_ = ((suggest_results_pending_ == 0) &&
983 (instant_finalized_ || !InstantController::IsEnabled(profile_))); 985 (instant_finalized_ || !InstantController::IsEnabled(profile_)));
984 } 986 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/search_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698