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

Side by Side Diff: components/omnibox/browser/zero_suggest_provider.h

Issue 2965173002: Add ContextualSuggestionsService to Omnibox (Closed)
Patch Set: Move contextual suggestions service to c/o/b Created 3 years, 5 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
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 // This file contains the zero-suggest autocomplete provider. This experimental 5 // This file contains the zero-suggest autocomplete provider. This experimental
6 // provider is invoked when the user focuses in the omnibox prior to editing, 6 // provider is invoked when the user focuses in the omnibox prior to editing,
7 // and generates search query suggestions based on the current URL. 7 // and generates search query suggestions based on the current URL.
8 8
9 #ifndef COMPONENTS_OMNIBOX_BROWSER_ZERO_SUGGEST_PROVIDER_H_ 9 #ifndef COMPONENTS_OMNIBOX_BROWSER_ZERO_SUGGEST_PROVIDER_H_
10 #define COMPONENTS_OMNIBOX_BROWSER_ZERO_SUGGEST_PROVIDER_H_ 10 #define COMPONENTS_OMNIBOX_BROWSER_ZERO_SUGGEST_PROVIDER_H_
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // Adds AutocompleteMatches for each of the suggestions in |results| to 91 // Adds AutocompleteMatches for each of the suggestions in |results| to
92 // |map|. 92 // |map|.
93 void AddSuggestResultsToMap( 93 void AddSuggestResultsToMap(
94 const SearchSuggestionParser::SuggestResults& results, 94 const SearchSuggestionParser::SuggestResults& results,
95 MatchMap* map); 95 MatchMap* map);
96 96
97 // Returns an AutocompleteMatch for a navigational suggestion |navigation|. 97 // Returns an AutocompleteMatch for a navigational suggestion |navigation|.
98 AutocompleteMatch NavigationToMatch( 98 AutocompleteMatch NavigationToMatch(
99 const SearchSuggestionParser::NavigationResult& navigation); 99 const SearchSuggestionParser::NavigationResult& navigation);
100 100
101 // Fetches zero-suggest suggestions by sending a request using |suggest_url|.
102 void Run(const GURL& suggest_url);
103
104 // Converts the parsed results to a set of AutocompleteMatches and adds them 101 // Converts the parsed results to a set of AutocompleteMatches and adds them
105 // to |matches_|. Also update the histograms for how many results were 102 // to |matches_|. Also update the histograms for how many results were
106 // received. 103 // received.
107 void ConvertResultsToAutocompleteMatches(); 104 void ConvertResultsToAutocompleteMatches();
108 105
109 // Returns an AutocompleteMatch for the current URL. The match should be in 106 // Returns an AutocompleteMatch for the current URL. The match should be in
110 // the top position so that pressing enter has the effect of reloading the 107 // the top position so that pressing enter has the effect of reloading the
111 // page. 108 // page.
112 AutocompleteMatch MatchForCurrentURL(); 109 AutocompleteMatch MatchForCurrentURL();
113 110
114 // When the user is in the Most Visited field trial, we ask the TopSites 111 // When the user is in the Most Visited field trial, we ask the TopSites
115 // service for the most visited URLs during Run(). It calls back to this 112 // service for the most visited URLs during Run(). It calls back to this
Mark P 2017/07/18 19:11:30 Please revise, as Run() doesn't exist anymore.
116 // function to return those |urls|. 113 // function to return those |urls|.
117 void OnMostVisitedUrlsAvailable(const history::MostVisitedURLList& urls); 114 void OnMostVisitedUrlsAvailable(const history::MostVisitedURLList& urls);
118 115
116 void OnContextualSuggestionsFetcherAvailable(
Mark P 2017/07/18 19:11:30 Please comment.
117 std::unique_ptr<net::URLFetcher> fetcher);
118
119 // Whether we can show zero suggest suggestions that are not based on 119 // Whether we can show zero suggest suggestions that are not based on
120 // |current_page_url|. Also checks that other conditions for non-contextual 120 // |current_page_url|. Also checks that other conditions for non-contextual
121 // zero suggest are satisfied. 121 // zero suggest are satisfied.
122 bool ShouldShowNonContextualZeroSuggest(const GURL& current_page_url) const; 122 bool ShouldShowNonContextualZeroSuggest(const GURL& current_page_url) const;
123 123
124 // Returns a URL string that should be used to to request contextual 124 // Returns a URL string that should be used to to request contextual
125 // suggestions from the default provider. Does not take into account whether 125 // suggestions from the default provider. Does not take into account whether
126 // sending this request is prohibited (e.g., in an incognito window). Returns 126 // sending this request is prohibited (e.g., in an incognito window). Returns
127 // an empty string in case of an error. 127 // an empty string in case of an error.
128 std::string GetContextualSuggestionsUrl() const; 128 std::string GetContextualSuggestionsUrl() const;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // Whether we are waiting for a most visited visited urls callback to run. 167 // Whether we are waiting for a most visited visited urls callback to run.
168 bool waiting_for_most_visited_urls_request_; 168 bool waiting_for_most_visited_urls_request_;
169 169
170 // For callbacks that may be run after destruction. 170 // For callbacks that may be run after destruction.
171 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; 171 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_;
172 172
173 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); 173 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider);
174 }; 174 };
175 175
176 #endif // COMPONENTS_OMNIBOX_BROWSER_ZERO_SUGGEST_PROVIDER_H_ 176 #endif // COMPONENTS_OMNIBOX_BROWSER_ZERO_SUGGEST_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698