| 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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
| 15 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" | |
| 16 #include "components/omnibox/autocomplete_input.h" | 15 #include "components/omnibox/autocomplete_input.h" |
| 17 #include "components/omnibox/autocomplete_provider.h" | 16 #include "components/omnibox/autocomplete_provider.h" |
| 17 #include "components/omnibox/autocomplete_provider_client.h" |
| 18 #include "components/omnibox/autocomplete_provider_listener.h" | 18 #include "components/omnibox/autocomplete_provider_listener.h" |
| 19 #include "components/omnibox/autocomplete_result.h" | 19 #include "components/omnibox/autocomplete_result.h" |
| 20 | 20 |
| 21 class AutocompleteControllerDelegate; | 21 class AutocompleteControllerDelegate; |
| 22 class HistoryURLProvider; | 22 class HistoryURLProvider; |
| 23 class KeywordProvider; | 23 class KeywordProvider; |
| 24 class Profile; | |
| 25 class SearchProvider; | 24 class SearchProvider; |
| 26 class TemplateURLService; | 25 class TemplateURLService; |
| 27 class ZeroSuggestProvider; | 26 class ZeroSuggestProvider; |
| 28 | 27 |
| 29 // The AutocompleteController is the center of the autocomplete system. A | 28 // The AutocompleteController is the center of the autocomplete system. A |
| 30 // class creates an instance of the controller, which in turn creates a set of | 29 // class creates an instance of the controller, which in turn creates a set of |
| 31 // AutocompleteProviders to serve it. The owning class can ask the controller | 30 // AutocompleteProviders to serve it. The owning class can ask the controller |
| 32 // to Start() a query; the controller in turn passes this call down to the | 31 // to Start() a query; the controller in turn passes this call down to the |
| 33 // providers, each of which keeps track of its own matches and whether it has | 32 // providers, each of which keeps track of its own matches and whether it has |
| 34 // finished processing the query. When a provider gets more matches or finishes | 33 // finished processing the query. When a provider gets more matches or finishes |
| (...skipping 12 matching lines...) Expand all Loading... |
| 47 // The coordinator for autocomplete queries, responsible for combining the | 46 // The coordinator for autocomplete queries, responsible for combining the |
| 48 // matches from a series of providers into one AutocompleteResult. | 47 // matches from a series of providers into one AutocompleteResult. |
| 49 class AutocompleteController : public AutocompleteProviderListener { | 48 class AutocompleteController : public AutocompleteProviderListener { |
| 50 public: | 49 public: |
| 51 typedef std::vector<scoped_refptr<AutocompleteProvider> > Providers; | 50 typedef std::vector<scoped_refptr<AutocompleteProvider> > Providers; |
| 52 | 51 |
| 53 // |provider_types| is a bitmap containing AutocompleteProvider::Type values | 52 // |provider_types| is a bitmap containing AutocompleteProvider::Type values |
| 54 // that will (potentially, depending on platform, flags, etc.) be | 53 // that will (potentially, depending on platform, flags, etc.) be |
| 55 // instantiated. |template_url_service| is used to create URLs from the | 54 // instantiated. |template_url_service| is used to create URLs from the |
| 56 // autocomplete results. | 55 // autocomplete results. |
| 57 AutocompleteController(Profile* profile, | 56 AutocompleteController(scoped_ptr<AutocompleteProviderClient> provider_client, |
| 58 TemplateURLService* template_url_service, | |
| 59 AutocompleteControllerDelegate* delegate, | 57 AutocompleteControllerDelegate* delegate, |
| 60 int provider_types); | 58 int provider_types); |
| 61 ~AutocompleteController() override; | 59 ~AutocompleteController() override; |
| 62 | 60 |
| 63 // Starts an autocomplete query, which continues until all providers are | 61 // Starts an autocomplete query, which continues until all providers are |
| 64 // done or the query is Stop()ed. It is safe to Start() a new query without | 62 // done or the query is Stop()ed. It is safe to Start() a new query without |
| 65 // Stop()ing the previous one. | 63 // Stop()ing the previous one. |
| 66 // | 64 // |
| 67 // See AutocompleteInput::AutocompleteInput(...) for more details regarding | 65 // See AutocompleteInput::AutocompleteInput(...) for more details regarding |
| 68 // |input| params. | 66 // |input| params. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 void StartStopTimer(); | 192 void StartStopTimer(); |
| 195 | 193 |
| 196 // Helper function for Stop(). |due_to_user_inactivity| means this call was | 194 // Helper function for Stop(). |due_to_user_inactivity| means this call was |
| 197 // triggered by a user's idleness, i.e., not an explicit user action. | 195 // triggered by a user's idleness, i.e., not an explicit user action. |
| 198 void StopHelper(bool clear_result, | 196 void StopHelper(bool clear_result, |
| 199 bool due_to_user_inactivity); | 197 bool due_to_user_inactivity); |
| 200 | 198 |
| 201 AutocompleteControllerDelegate* delegate_; | 199 AutocompleteControllerDelegate* delegate_; |
| 202 | 200 |
| 203 // The client passed to the providers. | 201 // The client passed to the providers. |
| 204 scoped_ptr<ChromeAutocompleteProviderClient> provider_client_; | 202 scoped_ptr<AutocompleteProviderClient> provider_client_; |
| 205 | 203 |
| 206 // A list of all providers. | 204 // A list of all providers. |
| 207 Providers providers_; | 205 Providers providers_; |
| 208 | 206 |
| 209 HistoryURLProvider* history_url_provider_; | 207 HistoryURLProvider* history_url_provider_; |
| 210 | 208 |
| 211 KeywordProvider* keyword_provider_; | 209 KeywordProvider* keyword_provider_; |
| 212 | 210 |
| 213 SearchProvider* search_provider_; | 211 SearchProvider* search_provider_; |
| 214 | 212 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // Are we in Start()? This is used to avoid updating |result_| and sending | 250 // Are we in Start()? This is used to avoid updating |result_| and sending |
| 253 // notifications until Start() has been invoked on all providers. | 251 // notifications until Start() has been invoked on all providers. |
| 254 bool in_start_; | 252 bool in_start_; |
| 255 | 253 |
| 256 TemplateURLService* template_url_service_; | 254 TemplateURLService* template_url_service_; |
| 257 | 255 |
| 258 DISALLOW_COPY_AND_ASSIGN(AutocompleteController); | 256 DISALLOW_COPY_AND_ASSIGN(AutocompleteController); |
| 259 }; | 257 }; |
| 260 | 258 |
| 261 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ | 259 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ |
| OLD | NEW |