| 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> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 typedef std::multimap<char16, base::string16> WordMap; | 43 typedef std::multimap<char16, base::string16> WordMap; |
| 44 | 44 |
| 45 virtual ~ShortcutsProvider(); | 45 virtual ~ShortcutsProvider(); |
| 46 | 46 |
| 47 // ShortcutsBackendObserver: | 47 // ShortcutsBackendObserver: |
| 48 virtual void OnShortcutsLoaded() OVERRIDE; | 48 virtual void OnShortcutsLoaded() OVERRIDE; |
| 49 | 49 |
| 50 // Performs the autocomplete matching and scoring. | 50 // Performs the autocomplete matching and scoring. |
| 51 void GetMatches(const AutocompleteInput& input); | 51 void GetMatches(const AutocompleteInput& input); |
| 52 | 52 |
| 53 // Returns an AutocompleteMatch corresponding to |shortcut|. Assigns it | 53 // Returns an AutocompleteMatch corresponding to |shortcut|. |
| 54 // |relevance| score in the process, and highlights the description | 54 // Assigns it |relevance| score in the process, and highlights the |
| 55 // and contents against |term_string|, which should be the lower-cased | 55 // description and contents against |term_string|, which should be |
| 56 // version of the user's input. If |prevent_inline_autocomplete|, no | 56 // the lower-cased version of the user's input. |term_string| and |
| 57 // matches with inline completions will be allowed to be the default match. | 57 // |fixed_up_term_string| are used to decide what can be inlined. |
| 58 // If |prevent_inline_autocomplete|, no matches with inline |
| 59 // 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 |