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 #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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 239 |
240 protected: | 240 protected: |
241 friend class base::RefCountedThreadSafe<AutocompleteProvider>; | 241 friend class base::RefCountedThreadSafe<AutocompleteProvider>; |
242 | 242 |
243 virtual ~AutocompleteProvider(); | 243 virtual ~AutocompleteProvider(); |
244 | 244 |
245 // Updates the starred state of each of the matches in matches_ from the | 245 // Updates the starred state of each of the matches in matches_ from the |
246 // profile's bookmark bar model. | 246 // profile's bookmark bar model. |
247 void UpdateStarredStateOfMatches(); | 247 void UpdateStarredStateOfMatches(); |
248 | 248 |
| 249 // Fixes up user URL input to make it more possible to match against. Among |
| 250 // many other things, this takes care of the following: |
| 251 // * Prepending file:// to file URLs |
| 252 // * Converting drive letters in file URLs to uppercase |
| 253 // * Converting case-insensitive parts of URLs (like the scheme and domain) |
| 254 // to lowercase |
| 255 // * Convert spaces to %20s |
| 256 // Note that we don't do this in AutocompleteInput's constructor, because if |
| 257 // e.g. we convert a Unicode hostname to punycode, other providers will show |
| 258 // output that surprises the user ("Search Google for xn--6ca.com"). |
| 259 // Returns false if the fixup attempt resulted in an empty string (which |
| 260 // providers generally can't do anything with). |
| 261 static bool FixupUserInput(AutocompleteInput* input); |
| 262 |
| 263 // Trims "http:" and up to two subsequent slashes from |url|. Returns the |
| 264 // number of characters that were trimmed. |
| 265 // NOTE: For a view-source: URL, this will trim from after "view-source:" and |
| 266 // return 0. |
| 267 static size_t TrimHttpPrefix(base::string16* url); |
| 268 |
249 // The profile associated with the AutocompleteProvider. Reference is not | 269 // The profile associated with the AutocompleteProvider. Reference is not |
250 // owned by us. | 270 // owned by us. |
251 Profile* profile_; | 271 Profile* profile_; |
252 | 272 |
253 AutocompleteProviderListener* listener_; | 273 AutocompleteProviderListener* listener_; |
254 ACMatches matches_; | 274 ACMatches matches_; |
255 bool done_; | 275 bool done_; |
256 | 276 |
257 Type type_; | 277 Type type_; |
258 | 278 |
259 private: | 279 private: |
260 DISALLOW_COPY_AND_ASSIGN(AutocompleteProvider); | 280 DISALLOW_COPY_AND_ASSIGN(AutocompleteProvider); |
261 }; | 281 }; |
262 | 282 |
263 typedef std::vector<AutocompleteProvider*> ACProviders; | 283 typedef std::vector<AutocompleteProvider*> ACProviders; |
264 | 284 |
265 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_H_ | 285 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_H_ |
OLD | NEW |