Home | History | Annotate | Download | only in autocomplete
      1 // Copyright (c) 2010 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 #pragma once
      8 
      9 #include "base/compiler_specific.h"
     10 #include "chrome/browser/autocomplete/autocomplete.h"
     11 
     12 namespace history {
     13 
     14 class HistoryBackend;
     15 class URLDatabase;
     16 class URLRow;
     17 
     18 }  // namespace history
     19 
     20 // This class is a base class for the history autocomplete providers and
     21 // provides functions useful to all derived classes.
     22 class HistoryProvider : public AutocompleteProvider {
     23  public:
     24   virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE;
     25 
     26  protected:
     27   enum MatchType {
     28     NORMAL,
     29     WHAT_YOU_TYPED,
     30     INLINE_AUTOCOMPLETE
     31   };
     32 
     33   HistoryProvider(ACProviderListener* listener,
     34                   Profile* profile,
     35                   const char* name);
     36 
     37   // Fixes up user URL input to make it more possible to match against.  Among
     38   // many other things, this takes care of the following:
     39   // * Prepending file:// to file URLs
     40   // * Converting drive letters in file URLs to uppercase
     41   // * Converting case-insensitive parts of URLs (like the scheme and domain)
     42   //   to lowercase
     43   // * Convert spaces to %20s
     44   // Note that we don't do this in AutocompleteInput's constructor, because if
     45   // e.g. we convert a Unicode hostname to punycode, other providers will show
     46   // output that surprises the user ("Search Google for xn--6ca.com").
     47   static string16 FixupUserInput(const AutocompleteInput& input);
     48 
     49   // Trims "http:" and up to two subsequent slashes from |url|.  Returns the
     50   // number of characters that were trimmed.
     51   // NOTE: For a view-source: URL, this will trim from after "view-source:" and
     52   // return 0.
     53   static size_t TrimHttpPrefix(string16* url);
     54 };
     55 
     56 #endif  // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_H_
     57