| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 non-keyword autocomplete entries that start with | 6 // responsible for all non-keyword autocomplete entries that start with |
| 7 // "Search <engine> for ...", including searching for the current input string, | 7 // "Search <engine> for ...", including searching for the current input string, |
| 8 // search history, and search suggestions. An instance of it gets created and | 8 // search 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 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
| 24 #include "chrome/browser/autocomplete/autocomplete.h" | 24 #include "chrome/browser/autocomplete/autocomplete.h" |
| 25 #include "chrome/browser/autocomplete/autocomplete_match.h" | 25 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 26 #include "chrome/browser/history/history_types.h" | 26 #include "chrome/browser/history/history_types.h" |
| 27 #include "chrome/browser/search_engines/template_url.h" | 27 #include "chrome/browser/search_engines/template_url.h" |
| 28 #include "chrome/browser/search_engines/template_url_id.h" | 28 #include "chrome/browser/search_engines/template_url_id.h" |
| 29 #include "content/common/url_fetcher.h" | 29 #include "content/common/url_fetcher.h" |
| 30 | 30 |
| 31 class Profile; | 31 class Profile; |
| 32 |
| 33 namespace base { |
| 32 class Value; | 34 class Value; |
| 35 } |
| 33 | 36 |
| 34 // Autocomplete provider for searches and suggestions from a search engine. | 37 // Autocomplete provider for searches and suggestions from a search engine. |
| 35 // | 38 // |
| 36 // After construction, the autocomplete controller repeatedly calls Start() | 39 // After construction, the autocomplete controller repeatedly calls Start() |
| 37 // with some user input, each time expecting to receive a small set of the best | 40 // with some user input, each time expecting to receive a small set of the best |
| 38 // matches (either synchronously or asynchronously). | 41 // matches (either synchronously or asynchronously). |
| 39 // | 42 // |
| 40 // Initially the provider creates a match that searches for the current input | 43 // Initially the provider creates a match that searches for the current input |
| 41 // text. It also starts a task to query the Suggest servers. When that data | 44 // text. It also starts a task to query the Suggest servers. When that data |
| 42 // comes back, the provider creates and returns matches for the best | 45 // comes back, the provider creates and returns matches for the best |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 void StopSuggest(); | 195 void StopSuggest(); |
| 193 | 196 |
| 194 // Creates a URLFetcher requesting suggest results for the specified | 197 // Creates a URLFetcher requesting suggest results for the specified |
| 195 // TemplateURL. Ownership of the returned URLFetchet passes to the caller. | 198 // TemplateURL. Ownership of the returned URLFetchet passes to the caller. |
| 196 URLFetcher* CreateSuggestFetcher(int id, | 199 URLFetcher* CreateSuggestFetcher(int id, |
| 197 const TemplateURL& provider, | 200 const TemplateURL& provider, |
| 198 const string16& text); | 201 const string16& text); |
| 199 | 202 |
| 200 // Parses the results from the Suggest server and stores up to kMaxMatches of | 203 // Parses the results from the Suggest server and stores up to kMaxMatches of |
| 201 // them in server_results_. Returns whether parsing succeeded. | 204 // them in server_results_. Returns whether parsing succeeded. |
| 202 bool ParseSuggestResults(Value* root_val, | 205 bool ParseSuggestResults(base::Value* root_val, |
| 203 bool is_keyword, | 206 bool is_keyword, |
| 204 const string16& input_text, | 207 const string16& input_text, |
| 205 SuggestResults* suggest_results); | 208 SuggestResults* suggest_results); |
| 206 | 209 |
| 207 // Converts the parsed server results in server_results_ to a set of | 210 // Converts the parsed server results in server_results_ to a set of |
| 208 // AutocompleteMatches and adds them to |matches_|. This also sets |done_| | 211 // AutocompleteMatches and adds them to |matches_|. This also sets |done_| |
| 209 // correctly. | 212 // correctly. |
| 210 void ConvertResultsToAutocompleteMatches(); | 213 void ConvertResultsToAutocompleteMatches(); |
| 211 | 214 |
| 212 // Converts the first navigation result in |navigation_results| to an | 215 // Converts the first navigation result in |navigation_results| to an |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 // Has FinalizeInstantQuery been invoked since the last |Start|? | 320 // Has FinalizeInstantQuery been invoked since the last |Start|? |
| 318 bool instant_finalized_; | 321 bool instant_finalized_; |
| 319 | 322 |
| 320 // The |suggest_text| parameter passed to FinalizeInstantQuery. | 323 // The |suggest_text| parameter passed to FinalizeInstantQuery. |
| 321 string16 default_provider_suggest_text_; | 324 string16 default_provider_suggest_text_; |
| 322 | 325 |
| 323 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 326 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
| 324 }; | 327 }; |
| 325 | 328 |
| 326 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 329 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
| OLD | NEW |