OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_UI_APP_LIST_SEARCH_APP_SEARCH_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_SEARCH_PROVIDER_H_ |
6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_SEARCH_PROVIDER_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_SEARCH_PROVIDER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/scoped_observer.h" | 10 #include "base/scoped_observer.h" |
11 #include "extensions/browser/extension_registry_observer.h" | 11 #include "extensions/browser/extension_registry_observer.h" |
12 #include "ui/app_list/search_provider.h" | 12 #include "ui/app_list/search_provider.h" |
13 | 13 |
14 class AppListControllerDelegate; | 14 class AppListControllerDelegate; |
15 class Profile; | 15 class Profile; |
16 | 16 |
| 17 namespace base { |
| 18 class Clock; |
| 19 } |
| 20 |
17 namespace extensions { | 21 namespace extensions { |
18 class ExtensionRegistry; | 22 class ExtensionRegistry; |
19 class ExtensionSet; | 23 class ExtensionSet; |
20 } | 24 } |
21 | 25 |
22 namespace app_list { | 26 namespace app_list { |
23 | 27 |
24 namespace test { | 28 namespace test { |
25 class AppSearchProviderTest; | 29 class AppSearchProviderTest; |
26 } | 30 } |
27 | 31 |
28 class AppSearchProvider : public SearchProvider, | 32 class AppSearchProvider : public SearchProvider, |
29 public extensions::ExtensionRegistryObserver { | 33 public extensions::ExtensionRegistryObserver { |
30 public: | 34 public: |
31 AppSearchProvider(Profile* profile, | 35 AppSearchProvider(Profile* profile, |
32 AppListControllerDelegate* list_controller); | 36 AppListControllerDelegate* list_controller, |
| 37 scoped_ptr<base::Clock> clock); |
33 ~AppSearchProvider() override; | 38 ~AppSearchProvider() override; |
34 | 39 |
35 // SearchProvider overrides: | 40 // SearchProvider overrides: |
36 void Start(const base::string16& query) override; | 41 void Start(const base::string16& query) override; |
37 void Stop() override; | 42 void Stop() override; |
38 | 43 |
39 private: | 44 private: |
40 class App; | 45 class App; |
41 typedef ScopedVector<App> Apps; | 46 typedef ScopedVector<App> Apps; |
42 | 47 |
43 friend test::AppSearchProviderTest; | |
44 | |
45 void StartImpl(const base::Time& current_time, const base::string16& query); | |
46 void UpdateResults(); | 48 void UpdateResults(); |
47 | 49 |
48 // Adds extensions to apps container if they should be displayed. | 50 // Adds extensions to apps container if they should be displayed. |
49 void AddApps(const extensions::ExtensionSet& extensions); | 51 void AddApps(const extensions::ExtensionSet& extensions); |
50 void RefreshApps(); | 52 void RefreshApps(); |
51 | 53 |
52 // extensions::ExtensionRegistryObserver overrides: | 54 // extensions::ExtensionRegistryObserver overrides: |
53 void OnExtensionLoaded(content::BrowserContext* browser_context, | 55 void OnExtensionLoaded(content::BrowserContext* browser_context, |
54 const extensions::Extension* extension) override; | 56 const extensions::Extension* extension) override; |
55 void OnExtensionUninstalled(content::BrowserContext* browser_context, | 57 void OnExtensionUninstalled(content::BrowserContext* browser_context, |
56 const extensions::Extension* extension, | 58 const extensions::Extension* extension, |
57 extensions::UninstallReason reason) override; | 59 extensions::UninstallReason reason) override; |
58 | 60 |
59 Profile* profile_; | 61 Profile* profile_; |
60 AppListControllerDelegate* list_controller_; | 62 AppListControllerDelegate* list_controller_; |
61 | 63 |
62 base::string16 query_; | 64 base::string16 query_; |
63 base::Time search_time_; | |
64 | 65 |
65 ScopedObserver<extensions::ExtensionRegistry, | 66 ScopedObserver<extensions::ExtensionRegistry, |
66 extensions::ExtensionRegistryObserver> | 67 extensions::ExtensionRegistryObserver> |
67 extension_registry_observer_; | 68 extension_registry_observer_; |
68 | 69 |
69 Apps apps_; | 70 Apps apps_; |
70 | 71 |
| 72 scoped_ptr<base::Clock> clock_; |
| 73 |
71 DISALLOW_COPY_AND_ASSIGN(AppSearchProvider); | 74 DISALLOW_COPY_AND_ASSIGN(AppSearchProvider); |
72 }; | 75 }; |
73 | 76 |
74 } // namespace app_list | 77 } // namespace app_list |
75 | 78 |
76 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_SEARCH_PROVIDER_H_ | 79 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_SEARCH_PROVIDER_H_ |
OLD | NEW |