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

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

Issue 10909130: autocomplete: Add AutocompleteProvider::Type enum. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update comments Created 8 years, 3 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 | Annotate | Revision Log
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_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_H_ 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // *~: Partial matches get a score on a sliding scale from about 575-1125 based 166 // *~: Partial matches get a score on a sliding scale from about 575-1125 based
167 // on how many times the URL for the Extension App has been typed and how 167 // on how many times the URL for the Extension App has been typed and how
168 // many of the letters match. 168 // many of the letters match.
169 // 169 //
170 // A single result provider for the autocomplete system. Given user input, the 170 // A single result provider for the autocomplete system. Given user input, the
171 // provider decides what (if any) matches to return, their relevance, and their 171 // provider decides what (if any) matches to return, their relevance, and their
172 // classifications. 172 // classifications.
173 class AutocompleteProvider 173 class AutocompleteProvider
174 : public base::RefCountedThreadSafe<AutocompleteProvider> { 174 : public base::RefCountedThreadSafe<AutocompleteProvider> {
175 public: 175 public:
176 // Different AutocompleteProvider implementations.
177 enum Type {
178 TYPE_BUILTIN = 1 << 0,
179 TYPE_EXTENSION_APP = 1 << 1,
Peter Kasting 2012/09/07 23:23:02 Nit: I guess this should be EXTENSION_APPS for con
Daniel Erat 2012/09/08 16:37:36 I noticed this too. The class is ExtensionAppCont
180 TYPE_HISTORY_CONTENTS = 1 << 2,
181 TYPE_HISTORY_QUICK = 1 << 3,
182 TYPE_HISTORY_URL = 1 << 4,
183 TYPE_KEYWORD = 1 << 5,
184 TYPE_SEARCH = 1 << 6,
185 TYPE_SHORTCUTS = 1 << 7,
186 TYPE_ZERO_SUGGEST = 1 << 8,
187 };
188
189 // Returns a string describing a particular AutocompleteProvider type.
190 static const char* TypeToString(Type type);
Peter Kasting 2012/09/07 23:23:02 Nit: Google style guide says constructors go befor
Daniel Erat 2012/09/08 16:37:36 Done.
176 191
177 AutocompleteProvider(AutocompleteProviderListener* listener, 192 AutocompleteProvider(AutocompleteProviderListener* listener,
178 Profile* profile, 193 Profile* profile,
179 const char* name); 194 Type type);
180 195
181 // Called to start an autocomplete query. The provider is responsible for 196 // Called to start an autocomplete query. The provider is responsible for
182 // tracking its matches for this query and whether it is done processing the 197 // tracking its matches for this query and whether it is done processing the
183 // query. When new matches are available or the provider finishes, it 198 // query. When new matches are available or the provider finishes, it
184 // calls the controller's OnProviderUpdate() method. The controller can then 199 // calls the controller's OnProviderUpdate() method. The controller can then
185 // get the new matches using the provider's accessors. 200 // get the new matches using the provider's accessors.
186 // Exception: Matches available immediately after starting the query (that 201 // Exception: Matches available immediately after starting the query (that
187 // is, synchronously) do not cause any notifications to be sent. The 202 // is, synchronously) do not cause any notifications to be sent. The
188 // controller is expected to check for these without prompting (since 203 // controller is expected to check for these without prompting (since
189 // otherwise, starting each provider running would result in a flurry of 204 // otherwise, starting each provider running would result in a flurry of
(...skipping 11 matching lines...) Expand all
201 // done. If the provider caches any results, it should clear the cache based 216 // done. If the provider caches any results, it should clear the cache based
202 // on the value of |clear_cached_results|. 217 // on the value of |clear_cached_results|.
203 virtual void Stop(bool clear_cached_results); 218 virtual void Stop(bool clear_cached_results);
204 219
205 // Returns the set of matches for the current query. 220 // Returns the set of matches for the current query.
206 const ACMatches& matches() const { return matches_; } 221 const ACMatches& matches() const { return matches_; }
207 222
208 // Returns whether the provider is done processing the query. 223 // Returns whether the provider is done processing the query.
209 bool done() const { return done_; } 224 bool done() const { return done_; }
210 225
211 // Returns the name of this provider. 226 // Returns this provider's type.
212 const std::string& name() const { return name_; } 227 Type type() const { return type(); }
228 const char* name() const { return TypeToString(type_); }
Peter Kasting 2012/09/07 23:23:02 Nit: This isn't a true cheap-accessor, so it shoul
Daniel Erat 2012/09/08 16:37:36 Done.
213 229
214 // Returns the enum equivalent to the name of this provider. 230 // Returns the enum equivalent to the name of this provider.
215 metrics::OmniboxEventProto_ProviderType AsOmniboxEventProviderType() const; 231 metrics::OmniboxEventProto_ProviderType AsOmniboxEventProviderType() const;
216 232
217 // Called to delete a match and the backing data that produced it. This 233 // Called to delete a match and the backing data that produced it. This
218 // match should not appear again in this or future queries. This can only be 234 // match should not appear again in this or future queries. This can only be
219 // called for matches the provider marks as deletable. This should only be 235 // called for matches the provider marks as deletable. This should only be
220 // called when no query is running. 236 // called when no query is running.
221 // NOTE: Remember to call OnProviderUpdate() if matches_ is updated. 237 // NOTE: Remember to call OnProviderUpdate() if matches_ is updated.
222 virtual void DeleteMatch(const AutocompleteMatch& match); 238 virtual void DeleteMatch(const AutocompleteMatch& match);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 void UpdateStarredStateOfMatches(); 274 void UpdateStarredStateOfMatches();
259 275
260 // The profile associated with the AutocompleteProvider. Reference is not 276 // The profile associated with the AutocompleteProvider. Reference is not
261 // owned by us. 277 // owned by us.
262 Profile* profile_; 278 Profile* profile_;
263 279
264 AutocompleteProviderListener* listener_; 280 AutocompleteProviderListener* listener_;
265 ACMatches matches_; 281 ACMatches matches_;
266 bool done_; 282 bool done_;
267 283
268 // The name of this provider. Used for logging. 284 Type type_;
269 std::string name_;
270 285
271 private: 286 private:
272 DISALLOW_COPY_AND_ASSIGN(AutocompleteProvider); 287 DISALLOW_COPY_AND_ASSIGN(AutocompleteProvider);
273 }; 288 };
274 289
275 typedef std::vector<AutocompleteProvider*> ACProviders; 290 typedef std::vector<AutocompleteProvider*> ACProviders;
276 291
277 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_H_ 292 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698