| 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 10 matching lines...) Expand all Loading... |
| 21 // suggestion for a given search term the higher will be that suggestion's | 21 // suggestion for a given search term the higher will be that suggestion's |
| 22 // ranking for future uses of that search term. | 22 // ranking for future uses of that search term. |
| 23 class ShortcutsProvider | 23 class ShortcutsProvider |
| 24 : public AutocompleteProvider, | 24 : public AutocompleteProvider, |
| 25 public ShortcutsBackend::ShortcutsBackendObserver { | 25 public ShortcutsBackend::ShortcutsBackendObserver { |
| 26 public: | 26 public: |
| 27 explicit ShortcutsProvider(Profile* profile); | 27 explicit ShortcutsProvider(Profile* profile); |
| 28 | 28 |
| 29 // Performs the autocompletion synchronously. Since no asynch completion is | 29 // Performs the autocompletion synchronously. Since no asynch completion is |
| 30 // performed |minimal_changes| is ignored. | 30 // performed |minimal_changes| is ignored. |
| 31 virtual void Start(const AutocompleteInput& input, | 31 void Start(const AutocompleteInput& input, bool minimal_changes) override; |
| 32 bool minimal_changes) override; | |
| 33 | 32 |
| 34 virtual void DeleteMatch(const AutocompleteMatch& match) override; | 33 void DeleteMatch(const AutocompleteMatch& match) override; |
| 35 | 34 |
| 36 private: | 35 private: |
| 37 friend class ClassifyTest; | 36 friend class ClassifyTest; |
| 38 friend class ShortcutsProviderTest; | 37 friend class ShortcutsProviderTest; |
| 39 FRIEND_TEST_ALL_PREFIXES(ShortcutsProviderTest, CalculateScore); | 38 FRIEND_TEST_ALL_PREFIXES(ShortcutsProviderTest, CalculateScore); |
| 40 | 39 |
| 41 typedef std::multimap<base::char16, base::string16> WordMap; | 40 typedef std::multimap<base::char16, base::string16> WordMap; |
| 42 | 41 |
| 43 virtual ~ShortcutsProvider(); | 42 ~ShortcutsProvider() override; |
| 44 | 43 |
| 45 // ShortcutsBackendObserver: | 44 // ShortcutsBackendObserver: |
| 46 virtual void OnShortcutsLoaded() override; | 45 void OnShortcutsLoaded() override; |
| 47 | 46 |
| 48 // Performs the autocomplete matching and scoring. | 47 // Performs the autocomplete matching and scoring. |
| 49 void GetMatches(const AutocompleteInput& input); | 48 void GetMatches(const AutocompleteInput& input); |
| 50 | 49 |
| 51 // Returns an AutocompleteMatch corresponding to |shortcut|. Assigns it | 50 // Returns an AutocompleteMatch corresponding to |shortcut|. Assigns it |
| 52 // |relevance| score in the process, and highlights the description and | 51 // |relevance| score in the process, and highlights the description and |
| 53 // contents against |input|, which should be the lower-cased version of | 52 // contents against |input|, which should be the lower-cased version of |
| 54 // the user's input. |input| and |fixed_up_input_text| are used to decide | 53 // the user's input. |input| and |fixed_up_input_text| are used to decide |
| 55 // what can be inlined. | 54 // what can be inlined. |
| 56 AutocompleteMatch ShortcutToACMatch( | 55 AutocompleteMatch ShortcutToACMatch( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 102 |
| 104 // The default max relevance unless overridden by a field trial. | 103 // The default max relevance unless overridden by a field trial. |
| 105 static const int kShortcutsProviderDefaultMaxRelevance; | 104 static const int kShortcutsProviderDefaultMaxRelevance; |
| 106 | 105 |
| 107 Profile* profile_; | 106 Profile* profile_; |
| 108 std::string languages_; | 107 std::string languages_; |
| 109 bool initialized_; | 108 bool initialized_; |
| 110 }; | 109 }; |
| 111 | 110 |
| 112 #endif // CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_PROVIDER_H_ | 111 #endif // CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_PROVIDER_H_ |
| OLD | NEW |