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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_H_
8 #include "base/compiler_specific.h"
9 #include "chrome/browser/autocomplete/autocomplete_provider.h"
11 class AutocompleteInput;
12 struct AutocompleteMatch;
14 // This class is a base class for the history autocomplete providers and
15 // provides functions useful to all derived classes.
16 class HistoryProvider : public AutocompleteProvider {
18 virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE;
21 HistoryProvider(AutocompleteProviderListener* listener,
23 AutocompleteProvider::Type type);
24 virtual ~HistoryProvider();
26 // Finds and removes the match from the current collection of matches and
28 void DeleteMatchFromMatches(const AutocompleteMatch& match);
30 // Fixes up user URL input to make it more possible to match against. Among
31 // many other things, this takes care of the following:
32 // * Prepending file:// to file URLs
33 // * Converting drive letters in file URLs to uppercase
34 // * Converting case-insensitive parts of URLs (like the scheme and domain)
36 // * Convert spaces to %20s
37 // Note that we don't do this in AutocompleteInput's constructor, because if
38 // e.g. we convert a Unicode hostname to punycode, other providers will show
39 // output that surprises the user ("Search Google for xn--6ca.com").
40 // Returns false if the fixup attempt resulted in an empty string (which
41 // providers generally can't do anything with).
42 static bool FixupUserInput(AutocompleteInput* input);
44 // Trims "http:" and up to two subsequent slashes from |url|. Returns the
45 // number of characters that were trimmed.
46 // NOTE: For a view-source: URL, this will trim from after "view-source:" and
48 static size_t TrimHttpPrefix(string16* url);
50 // Returns true if inline autocompletion should be prevented. Use this instead
51 // of |input.prevent_inline_autocomplete| if the input is passed through
52 // FixupUserInput(). This method returns true if
53 // |input.prevent_inline_autocomplete()| is true or the input text contains
54 // trailing whitespace.
55 bool PreventInlineAutocomplete(const AutocompleteInput& input);
58 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_H_