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