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

Unified Diff: chrome/browser/autocomplete/search_provider.h

Issue 471673002: Omnibox: Prevent Asynchronous Suggestions from Changing Default Match (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mike's comments Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/autocomplete/base_search_provider.cc ('k') | chrome/browser/autocomplete/search_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/search_provider.h
diff --git a/chrome/browser/autocomplete/search_provider.h b/chrome/browser/autocomplete/search_provider.h
index 7140c5c6ad52f8aef1ad25ea79a1ecc3c8aabb76..6d53eff3622fb69559b128377b9c021d089a77be 100644
--- a/chrome/browser/autocomplete/search_provider.h
+++ b/chrome/browser/autocomplete/search_provider.h
@@ -74,10 +74,11 @@ class SearchProvider : public BaseSearchProvider,
private:
friend class SearchProviderTest;
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, CanSendURL);
+ FRIEND_TEST_ALL_PREFIXES(SearchProviderTest,
+ DontInlineAutocompleteAsynchronously);
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline);
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify);
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring);
- FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveStaleResultsTest);
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment);
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, TestDeleteMatch);
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestQueryUsesToken);
@@ -143,20 +144,19 @@ class SearchProvider : public BaseSearchProvider,
typedef std::vector<history::KeywordSearchTermVisit> HistoryResults;
- // Removes non-inlineable results until either the top result can inline
- // autocomplete the current input or verbatim outscores the top result.
- static void RemoveStaleResults(
- const base::string16& input,
- int verbatim_relevance,
- SearchSuggestionParser::SuggestResults* suggest_results,
- SearchSuggestionParser::NavigationResults* navigation_results);
-
// Calculates the relevance score for the keyword verbatim result (if the
// input matches one of the profile's keyword).
static int CalculateRelevanceForKeywordVerbatim(
metrics::OmniboxInputType::Type type,
bool prefer_keyword);
+ // A helper function for UpdateAllOldResults().
+ static void UpdateOldResults(bool minimal_changes,
+ SearchSuggestionParser::Results* results);
+
+ // Returns the first match in |matches| which might be chosen as default.
+ static ACMatches::iterator FindTopMatch(ACMatches* matches);
+
// AutocompleteProvider:
virtual void Start(const AutocompleteInput& input,
bool minimal_changes) OVERRIDE;
@@ -205,12 +205,16 @@ class SearchProvider : public BaseSearchProvider,
// potentially private data, etc.
bool IsQuerySuitableForSuggest() const;
- // Removes stale results for both default and keyword providers. See comments
- // on RemoveStaleResults().
- void RemoveAllStaleResults();
+ // Remove existing keyword results if the user is no longer in keyword mode,
+ // and, if |minimal_changes| is false, revise the existing results to
+ // indicate they were received before the last keystroke.
+ void UpdateAllOldResults(bool minimal_changes);
+
+ // Given new asynchronous results, ensure that we don't clobber the current
+ // top results, which were determined synchronously on the last keystroke.
+ void PersistTopSuggestions(SearchSuggestionParser::Results* results);
// Apply calculated relevance scores to the current results.
- void ApplyCalculatedRelevance();
void ApplyCalculatedSuggestRelevance(
SearchSuggestionParser::SuggestResults* list);
void ApplyCalculatedNavigationRelevance(
@@ -349,6 +353,11 @@ class SearchProvider : public BaseSearchProvider,
SearchSuggestionParser::Results default_results_;
SearchSuggestionParser::Results keyword_results_;
+ // The top query suggestion, left blank if none.
+ base::string16 top_query_suggestion_match_contents_;
+ // The top navigation suggestion, left blank/invalid if none.
+ GURL top_navigation_suggestion_;
+
GURL current_page_url_;
// Session token management.
« no previous file with comments | « chrome/browser/autocomplete/base_search_provider.cc ('k') | chrome/browser/autocomplete/search_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698