| 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 CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ | 9 #ifndef CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ |
| 10 #define CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ | 10 #define CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 AutocompleteMatch MatchForCurrentURL(); | 113 AutocompleteMatch MatchForCurrentURL(); |
| 114 | 114 |
| 115 // When the user is in the Most Visited field trial, we ask the TopSites | 115 // When the user is in the Most Visited field trial, we ask the TopSites |
| 116 // service for the most visited URLs during Run(). It calls back to this | 116 // service for the most visited URLs during Run(). It calls back to this |
| 117 // function to return those |urls|. | 117 // function to return those |urls|. |
| 118 void OnMostVisitedUrlsAvailable(const history::MostVisitedURLList& urls); | 118 void OnMostVisitedUrlsAvailable(const history::MostVisitedURLList& urls); |
| 119 | 119 |
| 120 // Returns the relevance score for the verbatim result. | 120 // Returns the relevance score for the verbatim result. |
| 121 int GetVerbatimRelevance() const; | 121 int GetVerbatimRelevance() const; |
| 122 | 122 |
| 123 // Whether we can show zero suggest on |current_page_url| without | 123 // Whether we can show zero suggest without sending |current_page_url| to |
| 124 // sending |current_page_url| as a parameter to the server at |suggest_url|. | 124 // |suggest_url| search provider. Also checks that other conditions for |
| 125 bool CanShowZeroSuggestWithoutSendingURL(const GURL& suggest_url, | 125 // non-contextual zero suggest are satisfied. |
| 126 const GURL& current_page_url) const; | 126 bool ShouldShowNonContextualZeroSuggest(const GURL& suggest_url, |
| 127 const GURL& current_page_url) const; |
| 127 | 128 |
| 128 // Checks whether we have a set of zero suggest results cached, and if so | 129 // Checks whether we have a set of zero suggest results cached, and if so |
| 129 // populates |matches_| with cached results. | 130 // populates |matches_| with cached results. |
| 130 void MaybeUseCachedSuggestions(); | 131 void MaybeUseCachedSuggestions(); |
| 131 | 132 |
| 132 AutocompleteProviderListener* listener_; | 133 AutocompleteProviderListener* listener_; |
| 133 Profile* profile_; | 134 Profile* profile_; |
| 134 | 135 |
| 135 // The URL for which a suggestion fetch is pending. | 136 // The URL for which a suggestion fetch is pending. |
| 136 std::string current_query_; | 137 std::string current_query_; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 157 | 158 |
| 158 history::MostVisitedURLList most_visited_urls_; | 159 history::MostVisitedURLList most_visited_urls_; |
| 159 | 160 |
| 160 // For callbacks that may be run after destruction. | 161 // For callbacks that may be run after destruction. |
| 161 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; | 162 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; |
| 162 | 163 |
| 163 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); | 164 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); |
| 164 }; | 165 }; |
| 165 | 166 |
| 166 #endif // CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ | 167 #endif // CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ |
| OLD | NEW |