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