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_HISTORY_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 9 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
10 #include "chrome/browser/history/in_memory_url_index_types.h" | 10 #include "chrome/browser/history/in_memory_url_index_types.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 protected: | 21 protected: |
22 HistoryProvider(AutocompleteProviderListener* listener, | 22 HistoryProvider(AutocompleteProviderListener* listener, |
23 Profile* profile, | 23 Profile* profile, |
24 AutocompleteProvider::Type type); | 24 AutocompleteProvider::Type type); |
25 virtual ~HistoryProvider(); | 25 virtual ~HistoryProvider(); |
26 | 26 |
27 // Finds and removes the match from the current collection of matches and | 27 // Finds and removes the match from the current collection of matches and |
28 // backing data. | 28 // backing data. |
29 void DeleteMatchFromMatches(const AutocompleteMatch& match); | 29 void DeleteMatchFromMatches(const AutocompleteMatch& match); |
30 | 30 |
31 // Fixes up user URL input to make it more possible to match against. Among | |
32 // many other things, this takes care of the following: | |
33 // * Prepending file:// to file URLs | |
34 // * Converting drive letters in file URLs to uppercase | |
35 // * Converting case-insensitive parts of URLs (like the scheme and domain) | |
36 // to lowercase | |
37 // * Convert spaces to %20s | |
38 // Note that we don't do this in AutocompleteInput's constructor, because if | |
39 // e.g. we convert a Unicode hostname to punycode, other providers will show | |
40 // output that surprises the user ("Search Google for xn--6ca.com"). | |
41 // Returns false if the fixup attempt resulted in an empty string (which | |
42 // providers generally can't do anything with). | |
43 static bool FixupUserInput(AutocompleteInput* input); | |
44 | |
45 // Trims "http:" and up to two subsequent slashes from |url|. Returns the | |
46 // number of characters that were trimmed. | |
47 // NOTE: For a view-source: URL, this will trim from after "view-source:" and | |
48 // return 0. | |
49 static size_t TrimHttpPrefix(base::string16* url); | |
50 | |
51 // Returns true if inline autocompletion should be prevented. Use this instead | 31 // Returns true if inline autocompletion should be prevented. Use this instead |
52 // of |input.prevent_inline_autocomplete| if the input is passed through | 32 // of |input.prevent_inline_autocomplete| if the input is passed through |
53 // FixupUserInput(). This method returns true if | 33 // FixupUserInput(). This method returns true if |
54 // |input.prevent_inline_autocomplete()| is true or the input text contains | 34 // |input.prevent_inline_autocomplete()| is true or the input text contains |
55 // trailing whitespace. | 35 // trailing whitespace. |
56 bool PreventInlineAutocomplete(const AutocompleteInput& input); | 36 bool PreventInlineAutocomplete(const AutocompleteInput& input); |
57 | 37 |
58 // Fill and return an ACMatchClassifications structure given the |matches| | 38 // Fill and return an ACMatchClassifications structure given the |matches| |
59 // to highlight. | 39 // to highlight. |
60 static ACMatchClassifications SpansFromTermMatch( | 40 static ACMatchClassifications SpansFromTermMatch( |
61 const history::TermMatches& matches, | 41 const history::TermMatches& matches, |
62 size_t text_length, | 42 size_t text_length, |
63 bool is_url); | 43 bool is_url); |
64 }; | 44 }; |
65 | 45 |
66 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_H_ | 46 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_H_ |
OLD | NEW |