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 #pragma once | 7 #pragma once |
8 | 8 |
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 "base/time.h" | 13 #include "base/time.h" |
14 #include "chrome/browser/autocomplete/autocomplete_match.h" | 14 #include "chrome/browser/autocomplete/autocomplete_match.h" |
15 #include "chrome/browser/autocomplete/history_provider.h" | 15 #include "chrome/browser/autocomplete/history_provider.h" |
16 #include "chrome/browser/history/shortcuts_backend.h" | 16 #include "chrome/browser/history/shortcuts_backend.h" |
17 | 17 |
18 class Profile; | 18 class Profile; |
19 | 19 |
20 // Provider of recently autocompleted links. Provides autocomplete suggestions | 20 // Provider of recently autocompleted links. Provides autocomplete suggestions |
21 // from previously selected suggestions. The more often a user selects a | 21 // from previously selected suggestions. The more often a user selects a |
22 // suggestion for a given search term the higher will be that suggestion's | 22 // suggestion for a given search term the higher will be that suggestion's |
23 // ranking for future uses of that search term. | 23 // ranking for future uses of that search term. |
24 class ShortcutsProvider | 24 class ShortcutsProvider |
25 : public AutocompleteProvider, | 25 : public AutocompleteProvider, |
26 public history::ShortcutsBackend::ShortcutsBackendObserver { | 26 public history::ShortcutsBackend::ShortcutsBackendObserver { |
27 public: | 27 public: |
28 ShortcutsProvider(ACProviderListener* listener, Profile* profile); | 28 ShortcutsProvider(ACProviderListener* listener, Profile* profile); |
29 virtual ~ShortcutsProvider(); | |
30 | 29 |
31 // Performs the autocompletion synchronously. Since no asynch completion is | 30 // Performs the autocompletion synchronously. Since no asynch completion is |
32 // performed |minimal_changes| is ignored. | 31 // performed |minimal_changes| is ignored. |
33 virtual void Start(const AutocompleteInput& input, | 32 virtual void Start(const AutocompleteInput& input, |
34 bool minimal_changes) OVERRIDE; | 33 bool minimal_changes) OVERRIDE; |
35 | 34 |
36 virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE; | 35 virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE; |
37 | 36 |
38 private: | 37 private: |
39 friend class ShortcutsProviderTest; | 38 friend class ShortcutsProviderTest; |
40 FRIEND_TEST_ALL_PREFIXES(ShortcutsProviderTest, ClassifyAllMatchesInString); | 39 FRIEND_TEST_ALL_PREFIXES(ShortcutsProviderTest, ClassifyAllMatchesInString); |
41 FRIEND_TEST_ALL_PREFIXES(ShortcutsProviderTest, CalculateScore); | 40 FRIEND_TEST_ALL_PREFIXES(ShortcutsProviderTest, CalculateScore); |
42 FRIEND_TEST_ALL_PREFIXES(ShortcutsProviderTest, DeleteMatch); | 41 FRIEND_TEST_ALL_PREFIXES(ShortcutsProviderTest, DeleteMatch); |
43 | 42 |
| 43 virtual ~ShortcutsProvider(); |
| 44 |
44 // ShortcutsBackendObserver: | 45 // ShortcutsBackendObserver: |
45 virtual void OnShortcutsLoaded() OVERRIDE; | 46 virtual void OnShortcutsLoaded() OVERRIDE; |
46 | 47 |
47 void DeleteMatchesWithURLs(const std::set<GURL>& urls); | 48 void DeleteMatchesWithURLs(const std::set<GURL>& urls); |
48 void DeleteShortcutsWithURLs(const std::set<GURL>& urls); | 49 void DeleteShortcutsWithURLs(const std::set<GURL>& urls); |
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 AutocompleteMatch ShortcutToACMatch( | 54 AutocompleteMatch ShortcutToACMatch( |
(...skipping 29 matching lines...) Expand all Loading... |
83 // For unit-test only. | 84 // For unit-test only. |
84 void set_shortcuts_backend(history::ShortcutsBackend* shortcuts_backend); | 85 void set_shortcuts_backend(history::ShortcutsBackend* shortcuts_backend); |
85 | 86 |
86 std::string languages_; | 87 std::string languages_; |
87 bool initialized_; | 88 bool initialized_; |
88 | 89 |
89 scoped_refptr<history::ShortcutsBackend> shortcuts_backend_; | 90 scoped_refptr<history::ShortcutsBackend> shortcuts_backend_; |
90 }; | 91 }; |
91 | 92 |
92 #endif // CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_PROVIDER_H_ | 93 #endif // CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_PROVIDER_H_ |
OLD | NEW |