Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Side by Side Diff: chrome/browser/autocomplete/autocomplete_controller.h

Issue 10832256: Experimental AutocompleteProvider for zerosuggest. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rename flag and add comments. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/string16.h" 11 #include "base/string16.h"
12 #include "base/timer.h" 12 #include "base/timer.h"
13 #include "chrome/browser/autocomplete/autocomplete_input.h" 13 #include "chrome/browser/autocomplete/autocomplete_input.h"
14 #include "chrome/browser/autocomplete/autocomplete_provider.h" 14 #include "chrome/browser/autocomplete/autocomplete_provider.h"
15 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" 15 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h"
16 #include "chrome/browser/autocomplete/autocomplete_result.h" 16 #include "chrome/browser/autocomplete/autocomplete_result.h"
17 17
18 class AutocompleteControllerDelegate; 18 class AutocompleteControllerDelegate;
19 class KeywordProvider; 19 class KeywordProvider;
20 class Profile; 20 class Profile;
21 class SearchProvider; 21 class SearchProvider;
22 class ZerosuggestProvider;
22 23
23 // The AutocompleteController is the center of the autocomplete system. A 24 // The AutocompleteController is the center of the autocomplete system. A
24 // class creates an instance of the controller, which in turn creates a set of 25 // class creates an instance of the controller, which in turn creates a set of
25 // AutocompleteProviders to serve it. The owning class can ask the controller 26 // AutocompleteProviders to serve it. The owning class can ask the controller
26 // to Start() a query; the controller in turn passes this call down to the 27 // to Start() a query; the controller in turn passes this call down to the
27 // providers, each of which keeps track of its own matches and whether it has 28 // providers, each of which keeps track of its own matches and whether it has
28 // finished processing the query. When a provider gets more matches or finishes 29 // finished processing the query. When a provider gets more matches or finishes
29 // processing, it notifies the controller, which merges the combined matches 30 // processing, it notifies the controller, which merges the combined matches
30 // together and makes the result available to interested observers. 31 // together and makes the result available to interested observers.
31 // 32 //
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 bool allow_exact_keyword_match, 102 bool allow_exact_keyword_match,
102 AutocompleteInput::MatchesRequested matches_requested); 103 AutocompleteInput::MatchesRequested matches_requested);
103 104
104 // Cancels the current query, ensuring there will be no future notifications 105 // Cancels the current query, ensuring there will be no future notifications
105 // fired. If new matches have come in since the most recent notification was 106 // fired. If new matches have come in since the most recent notification was
106 // fired, they will be discarded. 107 // fired, they will be discarded.
107 // 108 //
108 // If |clear_result| is true, the controller will also erase the result set. 109 // If |clear_result| is true, the controller will also erase the result set.
109 void Stop(bool clear_result); 110 void Stop(bool clear_result);
110 111
112 // Begin asynchronously fetching Zerosuggest suggestions for |url|.
113 // |user_text| is the text entered in the omnibox, which may be non-empty if
114 // the user previously focused in the omnibox during this interaction.
115 // TODO(jered): Rip out |user_text| once the first match is decoupled from
116 // the current typing in the omnibox.
117 void StartZerosuggest(const GURL& url, const string16& user_text);
118
119 // Cancels any pending Zerosuggest fetch.
120 void StopZerosuggest();
121
111 // Asks the relevant provider to delete |match|, and ensures observers are 122 // Asks the relevant provider to delete |match|, and ensures observers are
112 // notified of resulting changes immediately. This should only be called when 123 // notified of resulting changes immediately. This should only be called when
113 // no query is running. 124 // no query is running.
114 void DeleteMatch(const AutocompleteMatch& match); 125 void DeleteMatch(const AutocompleteMatch& match);
115 126
116 // Removes any entries that were copied from the last result. This is used by 127 // Removes any entries that were copied from the last result. This is used by
117 // the popup to ensure it's not showing an out-of-date query. 128 // the popup to ensure it's not showing an out-of-date query.
118 void ExpireCopiedEntries(); 129 void ExpireCopiedEntries();
119 130
120 #ifdef UNIT_TEST 131 #ifdef UNIT_TEST
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 192
182 AutocompleteControllerDelegate* delegate_; 193 AutocompleteControllerDelegate* delegate_;
183 194
184 // A list of all providers. 195 // A list of all providers.
185 ACProviders providers_; 196 ACProviders providers_;
186 197
187 KeywordProvider* keyword_provider_; 198 KeywordProvider* keyword_provider_;
188 199
189 SearchProvider* search_provider_; 200 SearchProvider* search_provider_;
190 201
202 ZerosuggestProvider* zerosuggest_provider_;
203
191 // Input passed to Start. 204 // Input passed to Start.
192 AutocompleteInput input_; 205 AutocompleteInput input_;
193 206
194 // Data from the autocomplete query. 207 // Data from the autocomplete query.
195 AutocompleteResult result_; 208 AutocompleteResult result_;
196 209
197 // Timer used to remove any matches copied from the last result. When run 210 // Timer used to remove any matches copied from the last result. When run
198 // invokes |ExpireCopiedEntries|. 211 // invokes |ExpireCopiedEntries|.
199 base::OneShotTimer<AutocompleteController> expire_timer_; 212 base::OneShotTimer<AutocompleteController> expire_timer_;
200 213
201 // True if a query is not currently running. 214 // True if a query is not currently running.
202 bool done_; 215 bool done_;
203 216
204 // Are we in Start()? This is used to avoid updating |result_| and sending 217 // Are we in Start()? This is used to avoid updating |result_| and sending
205 // notifications until Start() has been invoked on all providers. 218 // notifications until Start() has been invoked on all providers.
206 bool in_start_; 219 bool in_start_;
207 220
208 Profile* profile_; 221 Profile* profile_;
209 222
210 DISALLOW_COPY_AND_ASSIGN(AutocompleteController); 223 DISALLOW_COPY_AND_ASSIGN(AutocompleteController);
211 }; 224 };
212 225
213 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ 226 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698