- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / autocomplete / history_provider.h
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.
4
5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_H_
7
8 #include "base/compiler_specific.h"
9 #include "chrome/browser/autocomplete/autocomplete_provider.h"
10
11 class AutocompleteInput;
12 struct AutocompleteMatch;
13
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 {
17  public:
18   virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE;
19
20  protected:
21   HistoryProvider(AutocompleteProviderListener* listener,
22                   Profile* profile,
23                   AutocompleteProvider::Type type);
24   virtual ~HistoryProvider();
25
26   // Finds and removes the match from the current collection of matches and
27   // backing data.
28   void DeleteMatchFromMatches(const AutocompleteMatch& match);
29
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)
35   //   to lowercase
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);
43
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
47   // return 0.
48   static size_t TrimHttpPrefix(string16* url);
49
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);
56 };
57
58 #endif  // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_H_