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 // 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // Returns an AutocompleteMatch for the current URL. The match should be in | 109 // 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 | 110 // the top position so that pressing enter has the effect of reloading the |
111 // page. | 111 // page. |
112 AutocompleteMatch MatchForCurrentURL(); | 112 AutocompleteMatch MatchForCurrentURL(); |
113 | 113 |
114 // When the user is in the Most Visited field trial, we ask the TopSites | 114 // 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 | 115 // service for the most visited URLs during Run(). It calls back to this |
116 // function to return those |urls|. | 116 // function to return those |urls|. |
117 void OnMostVisitedUrlsAvailable(const history::MostVisitedURLList& urls); | 117 void OnMostVisitedUrlsAvailable(const history::MostVisitedURLList& urls); |
118 | 118 |
| 119 void OnContextualSuggestionsFetcherAvailable( |
| 120 std::unique_ptr<net::URLFetcher> fetcher); |
| 121 |
119 // Whether we can show zero suggest suggestions that are not based on | 122 // Whether we can show zero suggest suggestions that are not based on |
120 // |current_page_url|. Also checks that other conditions for non-contextual | 123 // |current_page_url|. Also checks that other conditions for non-contextual |
121 // zero suggest are satisfied. | 124 // zero suggest are satisfied. |
122 bool ShouldShowNonContextualZeroSuggest(const GURL& current_page_url) const; | 125 bool ShouldShowNonContextualZeroSuggest(const GURL& current_page_url) const; |
123 | 126 |
124 // Returns a URL string that should be used to to request contextual | 127 // Returns a URL string that should be used to to request contextual |
125 // suggestions from the default provider. Does not take into account whether | 128 // suggestions from the default provider. Does not take into account whether |
126 // sending this request is prohibited (e.g., in an incognito window). Returns | 129 // sending this request is prohibited (e.g., in an incognito window). Returns |
127 // an empty string in case of an error. | 130 // an empty string in case of an error. |
128 std::string GetContextualSuggestionsUrl() const; | 131 std::string GetContextualSuggestionsUrl() const; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // Whether we are waiting for a most visited visited urls callback to run. | 170 // Whether we are waiting for a most visited visited urls callback to run. |
168 bool waiting_for_most_visited_urls_request_; | 171 bool waiting_for_most_visited_urls_request_; |
169 | 172 |
170 // For callbacks that may be run after destruction. | 173 // For callbacks that may be run after destruction. |
171 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; | 174 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; |
172 | 175 |
173 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); | 176 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); |
174 }; | 177 }; |
175 | 178 |
176 #endif // COMPONENTS_OMNIBOX_BROWSER_ZERO_SUGGEST_PROVIDER_H_ | 179 #endif // COMPONENTS_OMNIBOX_BROWSER_ZERO_SUGGEST_PROVIDER_H_ |
OLD | NEW |