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 ProvidesMatchesOnOmniboxFocus when the user focuses | 40 // The controller will call Start() with |on_focus| set when the user focuses |
41 // the 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 set | 42 // Start() with some user input, each time expecting to receive an updated set |
43 // 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, |
| 61 bool minimal_changes, |
| 62 bool called_due_to_focus) override; |
61 void Stop(bool clear_cached_results) override; | 63 void Stop(bool clear_cached_results) override; |
62 void DeleteMatch(const AutocompleteMatch& match) override; | 64 void DeleteMatch(const AutocompleteMatch& match) override; |
63 void AddProviderInfo(ProvidersInfo* provider_info) const override; | 65 void AddProviderInfo(ProvidersInfo* provider_info) const override; |
64 bool ProvidesMatchesOnOmniboxFocus() const override; | |
65 | 66 |
66 // Sets |field_trial_triggered_| to false. | 67 // Sets |field_trial_triggered_| to false. |
67 void ResetSession() override; | 68 void ResetSession() override; |
68 | 69 |
69 private: | 70 private: |
70 ZeroSuggestProvider(AutocompleteProviderListener* listener, | 71 ZeroSuggestProvider(AutocompleteProviderListener* listener, |
71 TemplateURLService* template_url_service, | 72 TemplateURLService* template_url_service, |
72 Profile* profile); | 73 Profile* profile); |
73 | 74 |
74 ~ZeroSuggestProvider() override; | 75 ~ZeroSuggestProvider() override; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // Whether we are waiting for a most visited visited urls callback to run. | 162 // Whether we are waiting for a most visited visited urls callback to run. |
162 bool waiting_for_most_visited_urls_request_; | 163 bool waiting_for_most_visited_urls_request_; |
163 | 164 |
164 // For callbacks that may be run after destruction. | 165 // For callbacks that may be run after destruction. |
165 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; | 166 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; |
166 | 167 |
167 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); | 168 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); |
168 }; | 169 }; |
169 | 170 |
170 #endif // CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ | 171 #endif // CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ |
OLD | NEW |