| 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 19 matching lines...) Expand all Loading... |
| 30 namespace net { | 30 namespace net { |
| 31 class URLFetcher; | 31 class URLFetcher; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace user_prefs { | 34 namespace user_prefs { |
| 35 class PrefRegistrySyncable; | 35 class PrefRegistrySyncable; |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Autocomplete provider for searches based on the current URL. | 38 // Autocomplete provider for searches based on the current URL. |
| 39 // | 39 // |
| 40 // The controller will call StartZeroSuggest when the user focuses in the | 40 // The controller will call ProvidesMatchesOnOmniboxFocus when the user focuses |
| 41 // omnibox. After construction, the autocomplete controller repeatedly calls | 41 // the omnibox. After construction, the autocomplete controller repeatedly calls |
| 42 // Start() with some user input, each time expecting to receive an updated | 42 // Start() with some user input, each time expecting to receive an updated set |
| 43 // set of matches. | 43 // of matches. |
| 44 // | 44 // |
| 45 // TODO(jered): Consider deleting this class and building this functionality | 45 // TODO(jered): Consider deleting this class and building this functionality |
| 46 // into SearchProvider after dogfood and after we break the association between | 46 // into SearchProvider after dogfood and after we break the association between |
| 47 // omnibox text and suggestions. | 47 // omnibox text and suggestions. |
| 48 class ZeroSuggestProvider : public BaseSearchProvider, | 48 class ZeroSuggestProvider : public BaseSearchProvider, |
| 49 public net::URLFetcherDelegate { | 49 public net::URLFetcherDelegate { |
| 50 public: | 50 public: |
| 51 // Creates and returns an instance of this provider. | 51 // Creates and returns an instance of this provider. |
| 52 static ZeroSuggestProvider* Create(AutocompleteProviderListener* listener, | 52 static ZeroSuggestProvider* Create(AutocompleteProviderListener* listener, |
| 53 TemplateURLService* template_url_service, | 53 TemplateURLService* template_url_service, |
| 54 Profile* profile); | 54 Profile* profile); |
| 55 | 55 |
| 56 // Registers a preference used to cache zero suggest results. | 56 // Registers a preference used to cache zero suggest results. |
| 57 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 57 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 58 | 58 |
| 59 // AutocompleteProvider: | 59 // AutocompleteProvider: |
| 60 void Start(const AutocompleteInput& input, bool minimal_changes) override; | 60 void Start(const AutocompleteInput& input, bool minimal_changes) override; |
| 61 void Stop(bool clear_cached_results) override; | 61 void Stop(bool clear_cached_results) override; |
| 62 void DeleteMatch(const AutocompleteMatch& match) override; | 62 void DeleteMatch(const AutocompleteMatch& match) override; |
| 63 void AddProviderInfo(ProvidersInfo* provider_info) const override; | 63 void AddProviderInfo(ProvidersInfo* provider_info) const override; |
| 64 bool ProvidesMatchesOnOmniboxFocus() const override; |
| 64 | 65 |
| 65 // Sets |field_trial_triggered_| to false. | 66 // Sets |field_trial_triggered_| to false. |
| 66 void ResetSession() override; | 67 void ResetSession() override; |
| 67 | 68 |
| 68 private: | 69 private: |
| 69 ZeroSuggestProvider(AutocompleteProviderListener* listener, | 70 ZeroSuggestProvider(AutocompleteProviderListener* listener, |
| 70 TemplateURLService* template_url_service, | 71 TemplateURLService* template_url_service, |
| 71 Profile* profile); | 72 Profile* profile); |
| 72 | 73 |
| 73 ~ZeroSuggestProvider() override; | 74 ~ZeroSuggestProvider() override; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // Whether we are waiting for a most visited visited urls callback to run. | 161 // Whether we are waiting for a most visited visited urls callback to run. |
| 161 bool waiting_for_most_visited_urls_request_; | 162 bool waiting_for_most_visited_urls_request_; |
| 162 | 163 |
| 163 // For callbacks that may be run after destruction. | 164 // For callbacks that may be run after destruction. |
| 164 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; | 165 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; |
| 165 | 166 |
| 166 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); | 167 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); |
| 167 }; | 168 }; |
| 168 | 169 |
| 169 #endif // CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ | 170 #endif // CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ |
| OLD | NEW |