Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / app_list / search / app_search_provider.h
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_SEARCH_PROVIDER_H_
6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_SEARCH_PROVIDER_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_vector.h"
10 #include "base/scoped_observer.h"
11 #include "extensions/browser/extension_registry_observer.h"
12 #include "ui/app_list/search_provider.h"
13
14 class AppListControllerDelegate;
15 class Profile;
16
17 namespace extensions {
18 class ExtensionRegistry;
19 class ExtensionSet;
20 }
21
22 namespace app_list {
23
24 namespace test {
25 class AppSearchProviderTest;
26 }
27
28 class AppSearchProvider : public SearchProvider,
29                           public extensions::ExtensionRegistryObserver {
30  public:
31   AppSearchProvider(Profile* profile,
32                     AppListControllerDelegate* list_controller);
33   ~AppSearchProvider() override;
34
35   // SearchProvider overrides:
36   void Start(const base::string16& query) override;
37   void Stop() override;
38
39  private:
40   class App;
41   typedef ScopedVector<App> Apps;
42
43   friend test::AppSearchProviderTest;
44
45   void StartImpl(const base::Time& current_time, const base::string16& query);
46
47   // Adds extensions to apps container if they should be displayed.
48   void AddApps(const extensions::ExtensionSet& extensions);
49   void RefreshApps();
50
51   // extensions::ExtensionRegistryObserver overrides:
52   void OnExtensionLoaded(content::BrowserContext* browser_context,
53                          const extensions::Extension* extension) override;
54   void OnExtensionUninstalled(content::BrowserContext* browser_context,
55                               const extensions::Extension* extension,
56                               extensions::UninstallReason reason) override;
57
58   Profile* profile_;
59   AppListControllerDelegate* list_controller_;
60
61   ScopedObserver<extensions::ExtensionRegistry,
62                  extensions::ExtensionRegistryObserver>
63       extension_registry_observer_;
64
65   Apps apps_;
66
67   DISALLOW_COPY_AND_ASSIGN(AppSearchProvider);
68 };
69
70 }  // namespace app_list
71
72 #endif  // CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_SEARCH_PROVIDER_H_