| 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_SHORTCUTS_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_PROVIDER_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 13 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
| 14 #include "chrome/browser/autocomplete/url_prefix.h" |
| 14 #include "chrome/browser/history/shortcuts_backend.h" | 15 #include "chrome/browser/history/shortcuts_backend.h" |
| 15 | 16 |
| 16 class Profile; | 17 class Profile; |
| 17 | 18 |
| 18 namespace history { | 19 namespace history { |
| 19 class ShortcutsProviderTest; | 20 class ShortcutsProviderTest; |
| 20 } | 21 } |
| 21 | 22 |
| 22 // Provider of recently autocompleted links. Provides autocomplete suggestions | 23 // Provider of recently autocompleted links. Provides autocomplete suggestions |
| 23 // from previously selected suggestions. The more often a user selects a | 24 // from previously selected suggestions. The more often a user selects a |
| (...skipping 19 matching lines...) Expand all Loading... |
| 43 typedef std::multimap<char16, base::string16> WordMap; | 44 typedef std::multimap<char16, base::string16> WordMap; |
| 44 | 45 |
| 45 virtual ~ShortcutsProvider(); | 46 virtual ~ShortcutsProvider(); |
| 46 | 47 |
| 47 // ShortcutsBackendObserver: | 48 // ShortcutsBackendObserver: |
| 48 virtual void OnShortcutsLoaded() OVERRIDE; | 49 virtual void OnShortcutsLoaded() OVERRIDE; |
| 49 | 50 |
| 50 // Performs the autocomplete matching and scoring. | 51 // Performs the autocomplete matching and scoring. |
| 51 void GetMatches(const AutocompleteInput& input); | 52 void GetMatches(const AutocompleteInput& input); |
| 52 | 53 |
| 53 // Returns an AutocompleteMatch corresponding to |shortcut|. Assigns it | 54 // Returns an AutocompleteMatch corresponding to |shortcut|. Assigns it |
| 54 // |relevance| score in the process, and highlights the description | 55 // |relevance| score in the process, and highlights the description and |
| 55 // and contents against |term_string|, which should be the lower-cased | 56 // contents against |term_string|, which should be the lower-cased version |
| 56 // version of the user's input. If |prevent_inline_autocomplete|, no | 57 // of the user's input. |term_string| and |fixed_up_term_string| are used |
| 58 // to decide what can be inlined. If |prevent_inline_autocomplete|, no |
| 57 // matches with inline completions will be allowed to be the default match. | 59 // matches with inline completions will be allowed to be the default match. |
| 58 AutocompleteMatch ShortcutToACMatch( | 60 AutocompleteMatch ShortcutToACMatch( |
| 59 const history::ShortcutsBackend::Shortcut& shortcut, | 61 const history::ShortcutsBackend::Shortcut& shortcut, |
| 60 int relevance, | 62 int relevance, |
| 61 const base::string16& term_string, | 63 const base::string16& term_string, |
| 62 bool prevent_inline_autocomplete); | 64 const base::string16& fixed_up_term_string, |
| 65 const bool prevent_inline_autocomplete); |
| 63 | 66 |
| 64 // Returns a map mapping characters to groups of words from |text| that start | 67 // Returns a map mapping characters to groups of words from |text| that start |
| 65 // with those characters, ordered lexicographically descending so that longer | 68 // with those characters, ordered lexicographically descending so that longer |
| 66 // words appear before their prefixes (if any) within a particular | 69 // words appear before their prefixes (if any) within a particular |
| 67 // equal_range(). | 70 // equal_range(). |
| 68 static WordMap CreateWordMapForString(const base::string16& text); | 71 static WordMap CreateWordMapForString(const base::string16& text); |
| 69 | 72 |
| 70 // Given |text| and a corresponding base set of classifications | 73 // Given |text| and a corresponding base set of classifications |
| 71 // |original_class|, adds ACMatchClassification::MATCH markers for all | 74 // |original_class|, adds ACMatchClassification::MATCH markers for all |
| 72 // instances of the words from |find_words| within |text| and returns the | 75 // instances of the words from |find_words| within |text| and returns the |
| (...skipping 29 matching lines...) Expand all Loading... |
| 102 int CalculateScore( | 105 int CalculateScore( |
| 103 const base::string16& terms, | 106 const base::string16& terms, |
| 104 const history::ShortcutsBackend::Shortcut& shortcut, | 107 const history::ShortcutsBackend::Shortcut& shortcut, |
| 105 int max_relevance); | 108 int max_relevance); |
| 106 | 109 |
| 107 std::string languages_; | 110 std::string languages_; |
| 108 bool initialized_; | 111 bool initialized_; |
| 109 }; | 112 }; |
| 110 | 113 |
| 111 #endif // CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_PROVIDER_H_ | 114 #endif // CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_PROVIDER_H_ |
| OLD | NEW |