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