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. To enable | 7 // and generates search query suggestions based on the current URL. To enable |
8 // this provider, point --experimental-zero-suggest-url-prefix at an | 8 // this provider, point --experimental-zero-suggest-url-prefix at an |
9 // appropriate suggestion service. | 9 // appropriate suggestion service. |
10 // | 10 // |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 static ZeroSuggestProvider* Create(AutocompleteProviderListener* listener, | 56 static ZeroSuggestProvider* Create(AutocompleteProviderListener* listener, |
57 TemplateURLService* template_url_service, | 57 TemplateURLService* template_url_service, |
58 Profile* profile); | 58 Profile* profile); |
59 | 59 |
60 // Registers a preference used to cache zero suggest results. | 60 // Registers a preference used to cache zero suggest results. |
61 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 61 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
62 | 62 |
63 // AutocompleteProvider: | 63 // AutocompleteProvider: |
64 virtual void Start(const AutocompleteInput& input, | 64 virtual void Start(const AutocompleteInput& input, |
65 bool minimal_changes) OVERRIDE; | 65 bool minimal_changes) OVERRIDE; |
| 66 virtual void Stop(bool clear_cached_results) OVERRIDE; |
66 virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE; | 67 virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE; |
| 68 virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE; |
67 | 69 |
68 // Sets |field_trial_triggered_| to false. | 70 // Sets |field_trial_triggered_| to false. |
69 virtual void ResetSession() OVERRIDE; | 71 virtual void ResetSession() OVERRIDE; |
70 | 72 |
71 protected: | |
72 // BaseSearchProvider: | |
73 virtual void ModifyProviderInfo( | |
74 metrics::OmniboxEventProto_ProviderInfo* provider_info) const OVERRIDE; | |
75 | |
76 private: | 73 private: |
77 ZeroSuggestProvider(AutocompleteProviderListener* listener, | 74 ZeroSuggestProvider(AutocompleteProviderListener* listener, |
78 TemplateURLService* template_url_service, | 75 TemplateURLService* template_url_service, |
79 Profile* profile); | 76 Profile* profile); |
80 | 77 |
81 virtual ~ZeroSuggestProvider(); | 78 virtual ~ZeroSuggestProvider(); |
82 | 79 |
83 // BaseSearchProvider: | 80 // BaseSearchProvider: |
84 virtual const TemplateURL* GetTemplateURL(bool is_keyword) const OVERRIDE; | 81 virtual const TemplateURL* GetTemplateURL(bool is_keyword) const OVERRIDE; |
85 virtual const AutocompleteInput GetInput(bool is_keyword) const OVERRIDE; | 82 virtual const AutocompleteInput GetInput(bool is_keyword) const OVERRIDE; |
86 virtual bool ShouldAppendExtraParams( | 83 virtual bool ShouldAppendExtraParams( |
87 const SearchSuggestionParser::SuggestResult& result) const OVERRIDE; | 84 const SearchSuggestionParser::SuggestResult& result) const OVERRIDE; |
88 virtual void StopSuggest() OVERRIDE; | |
89 virtual void ClearAllResults() OVERRIDE; | |
90 virtual void RecordDeletionResult(bool success) OVERRIDE; | 85 virtual void RecordDeletionResult(bool success) OVERRIDE; |
91 | 86 |
92 // net::URLFetcherDelegate: | 87 // net::URLFetcherDelegate: |
93 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 88 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
94 | 89 |
95 // Optionally, cache the received |json_data| and return true if we want | 90 // Optionally, cache the received |json_data| and return true if we want |
96 // to stop processing results at this point. The |parsed_data| is the parsed | 91 // to stop processing results at this point. The |parsed_data| is the parsed |
97 // version of |json_data| used to determine if we received an empty result. | 92 // version of |json_data| used to determine if we received an empty result. |
98 bool StoreSuggestionResponse(const std::string& json_data, | 93 bool StoreSuggestionResponse(const std::string& json_data, |
99 const base::Value& parsed_data); | 94 const base::Value& parsed_data); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 160 |
166 history::MostVisitedURLList most_visited_urls_; | 161 history::MostVisitedURLList most_visited_urls_; |
167 | 162 |
168 // For callbacks that may be run after destruction. | 163 // For callbacks that may be run after destruction. |
169 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; | 164 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; |
170 | 165 |
171 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); | 166 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); |
172 }; | 167 }; |
173 | 168 |
174 #endif // CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ | 169 #endif // CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ |
OLD | NEW |