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