| 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 Search autocomplete provider. This provider is | 5 // This file contains the Search autocomplete provider. This provider is |
| 6 // responsible for all autocomplete entries that start with "Search <engine> | 6 // responsible for all autocomplete entries that start with "Search <engine> |
| 7 // for ...", including searching for the current input string, search | 7 // for ...", including searching for the current input string, search |
| 8 // history, and search suggestions. An instance of it gets created and | 8 // history, and search suggestions. An instance of it gets created and |
| 9 // managed by the autocomplete controller. | 9 // managed by the autocomplete controller. |
| 10 | 10 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 Results* results); | 151 Results* results); |
| 152 | 152 |
| 153 // Calculates the relevance score for the keyword verbatim result (if the | 153 // Calculates the relevance score for the keyword verbatim result (if the |
| 154 // input matches one of the profile's keyword). | 154 // input matches one of the profile's keyword). |
| 155 static int CalculateRelevanceForKeywordVerbatim(AutocompleteInput::Type type, | 155 static int CalculateRelevanceForKeywordVerbatim(AutocompleteInput::Type type, |
| 156 bool prefer_keyword); | 156 bool prefer_keyword); |
| 157 | 157 |
| 158 // AutocompleteProvider: | 158 // AutocompleteProvider: |
| 159 virtual void Start(const AutocompleteInput& input, | 159 virtual void Start(const AutocompleteInput& input, |
| 160 bool minimal_changes) OVERRIDE; | 160 bool minimal_changes) OVERRIDE; |
| 161 virtual void Stop(bool clear_cached_results) OVERRIDE; | |
| 162 | 161 |
| 163 // net::URLFetcherDelegate: | 162 // net::URLFetcherDelegate: |
| 164 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 163 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 165 | 164 |
| 166 // BaseSearchProvider: | 165 // BaseSearchProvider: |
| 167 virtual const TemplateURL* GetTemplateURL( | 166 virtual const TemplateURL* GetTemplateURL( |
| 168 const SuggestResult& result) const OVERRIDE; | 167 const SuggestResult& result) const OVERRIDE; |
| 169 virtual const AutocompleteInput GetInput( | 168 virtual const AutocompleteInput GetInput( |
| 170 const SuggestResult& result) const OVERRIDE; | 169 const SuggestResult& result) const OVERRIDE; |
| 171 virtual bool ShouldAppendExtraParams( | 170 virtual bool ShouldAppendExtraParams( |
| 172 const SuggestResult& result) const OVERRIDE; | 171 const SuggestResult& result) const OVERRIDE; |
| 172 virtual void StopSuggest() OVERRIDE; |
| 173 virtual void ClearAllResults() OVERRIDE; |
| 173 | 174 |
| 174 // This gets called when we have requested a suggestion deletion from the | 175 // This gets called when we have requested a suggestion deletion from the |
| 175 // server to handle the results of the deletion. | 176 // server to handle the results of the deletion. |
| 176 void OnDeletionComplete(bool success, | 177 void OnDeletionComplete(bool success, |
| 177 SuggestionDeletionHandler* handler); | 178 SuggestionDeletionHandler* handler); |
| 178 | 179 |
| 179 // Records in UMA whether the deletion request resulted in success. | 180 // Records in UMA whether the deletion request resulted in success. |
| 180 // This is virtual so test code can override it to check that we | 181 // This is virtual so test code can override it to check that we |
| 181 // correctly handle the request result. | 182 // correctly handle the request result. |
| 182 virtual void RecordDeletionResult(bool success); | 183 virtual void RecordDeletionResult(bool success); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 194 // Determines whether an asynchronous subcomponent query should run for the | 195 // Determines whether an asynchronous subcomponent query should run for the |
| 195 // current input. If so, starts it if necessary; otherwise stops it. | 196 // current input. If so, starts it if necessary; otherwise stops it. |
| 196 // NOTE: This function does not update |done_|. Callers must do so. | 197 // NOTE: This function does not update |done_|. Callers must do so. |
| 197 void StartOrStopSuggestQuery(bool minimal_changes); | 198 void StartOrStopSuggestQuery(bool minimal_changes); |
| 198 | 199 |
| 199 // Returns true when the current query can be sent to the Suggest service. | 200 // Returns true when the current query can be sent to the Suggest service. |
| 200 // This will be false e.g. when Suggest is disabled, the query contains | 201 // This will be false e.g. when Suggest is disabled, the query contains |
| 201 // potentially private data, etc. | 202 // potentially private data, etc. |
| 202 bool IsQuerySuitableForSuggest() const; | 203 bool IsQuerySuitableForSuggest() const; |
| 203 | 204 |
| 204 // Stops the suggest query. | |
| 205 // NOTE: This does not update |done_|. Callers must do so. | |
| 206 void StopSuggest(); | |
| 207 | |
| 208 // Clears the current results. | |
| 209 void ClearAllResults(); | |
| 210 | |
| 211 // Removes stale results for both default and keyword providers. See comments | 205 // Removes stale results for both default and keyword providers. See comments |
| 212 // on RemoveStaleResults(). | 206 // on RemoveStaleResults(). |
| 213 void RemoveAllStaleResults(); | 207 void RemoveAllStaleResults(); |
| 214 | 208 |
| 215 // Apply calculated relevance scores to the current results. | 209 // Apply calculated relevance scores to the current results. |
| 216 void ApplyCalculatedRelevance(); | 210 void ApplyCalculatedRelevance(); |
| 217 void ApplyCalculatedSuggestRelevance(SuggestResults* list); | 211 void ApplyCalculatedSuggestRelevance(SuggestResults* list); |
| 218 void ApplyCalculatedNavigationRelevance(NavigationResults* list); | 212 void ApplyCalculatedNavigationRelevance(NavigationResults* list); |
| 219 | 213 |
| 220 // Starts a new URLFetcher requesting suggest results from |template_url|; | 214 // Starts a new URLFetcher requesting suggest results from |template_url|; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 // that a server delete a personalized suggestion. Making this a ScopedVector | 366 // that a server delete a personalized suggestion. Making this a ScopedVector |
| 373 // causes us to auto-cancel all such requests on shutdown. | 367 // causes us to auto-cancel all such requests on shutdown. |
| 374 SuggestionDeletionHandlers deletion_handlers_; | 368 SuggestionDeletionHandlers deletion_handlers_; |
| 375 | 369 |
| 376 GURL current_page_url_; | 370 GURL current_page_url_; |
| 377 | 371 |
| 378 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 372 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
| 379 }; | 373 }; |
| 380 | 374 |
| 381 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 375 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
| OLD | NEW |