| 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 |
| 11 #ifndef CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 11 #ifndef CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
| 12 #define CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 12 #define CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
| 19 #include "chrome/browser/autocomplete/answers_cache.h" | 19 #include "chrome/browser/autocomplete/answers_cache.h" |
| 20 #include "chrome/browser/autocomplete/base_search_provider.h" | 20 #include "chrome/browser/autocomplete/base_search_provider.h" |
| 21 #include "components/metrics/proto/omnibox_input_type.pb.h" | 21 #include "components/metrics/proto/omnibox_input_type.pb.h" |
| 22 #include "components/search_engines/template_url.h" | 22 #include "components/search_engines/template_url.h" |
| 23 #include "net/url_request/url_fetcher_delegate.h" | 23 #include "net/url_request/url_fetcher_delegate.h" |
| 24 | 24 |
| 25 class AutocompleteProviderDelegate; |
| 25 class AutocompleteProviderListener; | 26 class AutocompleteProviderListener; |
| 26 class AutocompleteResult; | 27 class AutocompleteResult; |
| 27 class Profile; | |
| 28 class SearchProviderTest; | 28 class SearchProviderTest; |
| 29 class TemplateURLService; | 29 class TemplateURLService; |
| 30 | 30 |
| 31 namespace history { | 31 namespace history { |
| 32 struct KeywordSearchTermVisit; | 32 struct KeywordSearchTermVisit; |
| 33 } | 33 } |
| 34 | 34 |
| 35 namespace net { | 35 namespace net { |
| 36 class URLFetcher; | 36 class URLFetcher; |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Autocomplete provider for searches and suggestions from a search engine. | 39 // Autocomplete provider for searches and suggestions from a search engine. |
| 40 // | 40 // |
| 41 // After construction, the autocomplete controller repeatedly calls Start() | 41 // After construction, the autocomplete controller repeatedly calls Start() |
| 42 // with some user input, each time expecting to receive a small set of the best | 42 // with some user input, each time expecting to receive a small set of the best |
| 43 // matches (either synchronously or asynchronously). | 43 // matches (either synchronously or asynchronously). |
| 44 // | 44 // |
| 45 // Initially the provider creates a match that searches for the current input | 45 // Initially the provider creates a match that searches for the current input |
| 46 // text. It also starts a task to query the Suggest servers. When that data | 46 // text. It also starts a task to query the Suggest servers. When that data |
| 47 // comes back, the provider creates and returns matches for the best | 47 // comes back, the provider creates and returns matches for the best |
| 48 // suggestions. | 48 // suggestions. |
| 49 class SearchProvider : public BaseSearchProvider, | 49 class SearchProvider : public BaseSearchProvider, |
| 50 public net::URLFetcherDelegate { | 50 public net::URLFetcherDelegate { |
| 51 public: | 51 public: |
| 52 SearchProvider(AutocompleteProviderListener* listener, | 52 SearchProvider(AutocompleteProviderListener* listener, |
| 53 TemplateURLService* template_url_service, | 53 TemplateURLService* template_url_service, |
| 54 Profile* profile); | 54 scoped_ptr<AutocompleteProviderDelegate> delegate); |
| 55 | 55 |
| 56 // Extracts the suggest response metadata which SearchProvider previously | 56 // Extracts the suggest response metadata which SearchProvider previously |
| 57 // stored for |match|. | 57 // stored for |match|. |
| 58 static std::string GetSuggestMetadata(const AutocompleteMatch& match); | 58 static std::string GetSuggestMetadata(const AutocompleteMatch& match); |
| 59 | 59 |
| 60 // Answers prefetch handling - register displayed answers. Takes the top | 60 // Answers prefetch handling - register displayed answers. Takes the top |
| 61 // match for Autocomplete and registers the contained answer data, if any. | 61 // match for Autocomplete and registers the contained answer data, if any. |
| 62 void RegisterDisplayedAnswers(const AutocompleteResult& result); | 62 void RegisterDisplayedAnswers(const AutocompleteResult& result); |
| 63 | 63 |
| 64 // AutocompleteProvider: | 64 // AutocompleteProvider: |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 base::TimeTicks token_expiration_time_; | 358 base::TimeTicks token_expiration_time_; |
| 359 | 359 |
| 360 // Answers prefetch management. | 360 // Answers prefetch management. |
| 361 AnswersCache answers_cache_; // Cache for last answers seen. | 361 AnswersCache answers_cache_; // Cache for last answers seen. |
| 362 AnswersQueryData prefetch_data_; // Data to use for query prefetching. | 362 AnswersQueryData prefetch_data_; // Data to use for query prefetching. |
| 363 | 363 |
| 364 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 364 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
| 365 }; | 365 }; |
| 366 | 366 |
| 367 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 367 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
| OLD | NEW |