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

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

Issue 312423003: Cleanup AutocompleteInput and AutocompleteProvider Functions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Return a std::pair Created 6 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/autocomplete/autocomplete_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // A suggested upper bound for how many matches a provider should return. 234 // A suggested upper bound for how many matches a provider should return.
235 // TODO(pkasting): http://b/1111299 , http://b/933133 This should go away once 235 // TODO(pkasting): http://b/1111299 , http://b/933133 This should go away once
236 // we have good relevance heuristics; the controller should handle all 236 // we have good relevance heuristics; the controller should handle all
237 // culling. 237 // culling.
238 static const size_t kMaxMatches; 238 static const size_t kMaxMatches;
239 239
240 protected: 240 protected:
241 friend class base::RefCountedThreadSafe<AutocompleteProvider>; 241 friend class base::RefCountedThreadSafe<AutocompleteProvider>;
242 FRIEND_TEST_ALL_PREFIXES(BookmarkProviderTest, InlineAutocompletion); 242 FRIEND_TEST_ALL_PREFIXES(BookmarkProviderTest, InlineAutocompletion);
243 243
244 typedef std::pair<bool, base::string16> FixupReturn;
245
244 virtual ~AutocompleteProvider(); 246 virtual ~AutocompleteProvider();
245 247
246 // Updates the starred state of each of the matches in matches_ from the 248 // Updates the starred state of each of the matches in matches_ from the
247 // profile's bookmark bar model. 249 // profile's bookmark bar model.
248 void UpdateStarredStateOfMatches(); 250 void UpdateStarredStateOfMatches();
249 251
250 // Fixes up user URL input to make it more possible to match against. Among 252 // Fixes up user URL input to make it more possible to match against. Among
251 // many other things, this takes care of the following: 253 // many other things, this takes care of the following:
252 // * Prepending file:// to file URLs 254 // * Prepending file:// to file URLs
253 // * Converting drive letters in file URLs to uppercase 255 // * Converting drive letters in file URLs to uppercase
254 // * Converting case-insensitive parts of URLs (like the scheme and domain) 256 // * Converting case-insensitive parts of URLs (like the scheme and domain)
255 // to lowercase 257 // to lowercase
256 // * Convert spaces to %20s 258 // * Convert spaces to %20s
257 // Note that we don't do this in AutocompleteInput's constructor, because if 259 // Note that we don't do this in AutocompleteInput's constructor, because if
258 // e.g. we convert a Unicode hostname to punycode, other providers will show 260 // e.g. we convert a Unicode hostname to punycode, other providers will show
259 // output that surprises the user ("Search Google for xn--6ca.com"). 261 // output that surprises the user ("Search Google for xn--6ca.com").
260 // Returns false if the fixup attempt resulted in an empty string (which 262 // Returns a bool indicating whether fixup succeeded, as well as the fixed-up
261 // providers generally can't do anything with). 263 // input text. The returned string will be the same as the input string if
262 static bool FixupUserInput(AutocompleteInput* input); 264 // fixup failed; this lets callers who don't care about failure simply use the
265 // string unconditionally.
266 static FixupReturn FixupUserInput(const AutocompleteInput& input);
263 267
264 // Trims "http:" and up to two subsequent slashes from |url|. Returns the 268 // Trims "http:" and up to two subsequent slashes from |url|. Returns the
265 // number of characters that were trimmed. 269 // number of characters that were trimmed.
266 // NOTE: For a view-source: URL, this will trim from after "view-source:" and 270 // NOTE: For a view-source: URL, this will trim from after "view-source:" and
267 // return 0. 271 // return 0.
268 static size_t TrimHttpPrefix(base::string16* url); 272 static size_t TrimHttpPrefix(base::string16* url);
269 273
270 // The profile associated with the AutocompleteProvider. Reference is not 274 // The profile associated with the AutocompleteProvider. Reference is not
271 // owned by us. 275 // owned by us.
272 Profile* profile_; 276 Profile* profile_;
273 277
274 AutocompleteProviderListener* listener_; 278 AutocompleteProviderListener* listener_;
275 ACMatches matches_; 279 ACMatches matches_;
276 bool done_; 280 bool done_;
277 281
278 Type type_; 282 Type type_;
279 283
280 private: 284 private:
281 DISALLOW_COPY_AND_ASSIGN(AutocompleteProvider); 285 DISALLOW_COPY_AND_ASSIGN(AutocompleteProvider);
282 }; 286 };
283 287
284 typedef std::vector<AutocompleteProvider*> ACProviders; 288 typedef std::vector<AutocompleteProvider*> ACProviders;
285 289
286 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_H_ 290 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/autocomplete_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698