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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Whether we can show zero suggest without sending |current_page_url| to | 119 // Whether we can show zero suggest without sending |current_page_url| to |
120 // |suggest_url| search provider. Also checks that other conditions for | 120 // |suggest_url| search provider. Also checks that other conditions for |
121 // non-contextual zero suggest are satisfied. | 121 // non-contextual zero suggest are satisfied. |
122 bool ShouldShowNonContextualZeroSuggest(const GURL& suggest_url, | 122 bool ShouldShowNonContextualZeroSuggest(const GURL& suggest_url, |
123 const GURL& current_page_url) const; | 123 const GURL& current_page_url) const; |
124 | 124 |
| 125 // Returns a URL string that should be used to to request contextual |
| 126 // suggestions from the default provider. Does not take into account whether |
| 127 // sending this request is prohibited (e.g., in an incognito window). Returns |
| 128 // an empty string in case of an error. |
| 129 std::string GetContextualSuggestionsUrl() const; |
| 130 |
125 // Checks whether we have a set of zero suggest results cached, and if so | 131 // Checks whether we have a set of zero suggest results cached, and if so |
126 // populates |matches_| with cached results. | 132 // populates |matches_| with cached results. |
127 void MaybeUseCachedSuggestions(); | 133 void MaybeUseCachedSuggestions(); |
128 | 134 |
129 // Used for efficiency when creating the verbatim match. Can be null. | 135 // Used for efficiency when creating the verbatim match. Can be null. |
130 HistoryURLProvider* history_url_provider_; | 136 HistoryURLProvider* history_url_provider_; |
131 | 137 |
132 AutocompleteProviderListener* listener_; | 138 AutocompleteProviderListener* listener_; |
133 | 139 |
134 // The URL for which a suggestion fetch is pending. | 140 // The URL for which a suggestion fetch is pending. |
(...skipping 24 matching lines...) Expand all Loading... |
159 // Whether we are waiting for a most visited visited urls callback to run. | 165 // Whether we are waiting for a most visited visited urls callback to run. |
160 bool waiting_for_most_visited_urls_request_; | 166 bool waiting_for_most_visited_urls_request_; |
161 | 167 |
162 // For callbacks that may be run after destruction. | 168 // For callbacks that may be run after destruction. |
163 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; | 169 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; |
164 | 170 |
165 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); | 171 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); |
166 }; | 172 }; |
167 | 173 |
168 #endif // COMPONENTS_OMNIBOX_BROWSER_ZERO_SUGGEST_PROVIDER_H_ | 174 #endif // COMPONENTS_OMNIBOX_BROWSER_ZERO_SUGGEST_PROVIDER_H_ |
OLD | NEW |