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 | |
131 // Checks whether we have a set of zero suggest results cached, and if so | 125 // Checks whether we have a set of zero suggest results cached, and if so |
132 // populates |matches_| with cached results. | 126 // populates |matches_| with cached results. |
133 void MaybeUseCachedSuggestions(); | 127 void MaybeUseCachedSuggestions(); |
134 | 128 |
135 // Used for efficiency when creating the verbatim match. Can be null. | 129 // Used for efficiency when creating the verbatim match. Can be null. |
136 HistoryURLProvider* history_url_provider_; | 130 HistoryURLProvider* history_url_provider_; |
137 | 131 |
138 AutocompleteProviderListener* listener_; | 132 AutocompleteProviderListener* listener_; |
139 | 133 |
140 // The URL for which a suggestion fetch is pending. | 134 // The URL for which a suggestion fetch is pending. |
(...skipping 24 matching lines...) Expand all Loading... |
165 // Whether we are waiting for a most visited visited urls callback to run. | 159 // Whether we are waiting for a most visited visited urls callback to run. |
166 bool waiting_for_most_visited_urls_request_; | 160 bool waiting_for_most_visited_urls_request_; |
167 | 161 |
168 // For callbacks that may be run after destruction. | 162 // For callbacks that may be run after destruction. |
169 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; | 163 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; |
170 | 164 |
171 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); | 165 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); |
172 }; | 166 }; |
173 | 167 |
174 #endif // COMPONENTS_OMNIBOX_BROWSER_ZERO_SUGGEST_PROVIDER_H_ | 168 #endif // COMPONENTS_OMNIBOX_BROWSER_ZERO_SUGGEST_PROVIDER_H_ |
OLD | NEW |