Home | History | Annotate | Download | only in search
      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   virtual ~AppSearchProvider();
     34 
     35   // SearchProvider overrides:
     36   virtual void Start(const base::string16& query) OVERRIDE;
     37   virtual 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   virtual void OnExtensionLoaded(
     53       content::BrowserContext* browser_context,
     54       const extensions::Extension* extension) OVERRIDE;
     55   virtual void OnExtensionUninstalled(
     56       content::BrowserContext* browser_context,
     57       const extensions::Extension* extension,
     58       extensions::UninstallReason reason) OVERRIDE;
     59 
     60   Profile* profile_;
     61   AppListControllerDelegate* list_controller_;
     62 
     63   ScopedObserver<extensions::ExtensionRegistry,
     64                  extensions::ExtensionRegistryObserver>
     65       extension_registry_observer_;
     66 
     67   Apps apps_;
     68 
     69   DISALLOW_COPY_AND_ASSIGN(AppSearchProvider);
     70 };
     71 
     72 }  // namespace app_list
     73 
     74 #endif  // CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_SEARCH_PROVIDER_H_
     75