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.
5 #ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_RESULT_H_
6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_RESULT_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/ui/app_list/app_context_menu_delegate.h"
12 #include "chrome/browser/ui/app_list/search/chrome_search_result.h"
13 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h"
14 #include "extensions/browser/extension_icon_image.h"
15 #include "extensions/browser/extension_registry_observer.h"
17 class AppListControllerDelegate;
18 class ExtensionEnableFlow;
25 namespace extensions {
26 class ExtensionRegistry;
32 class TokenizedString;
33 class TokenizedStringMatch;
35 class AppResult : public ChromeSearchResult,
36 public extensions::IconImage::Observer,
37 public AppContextMenuDelegate,
38 public ExtensionEnableFlowDelegate,
39 public extensions::ExtensionRegistryObserver {
41 AppResult(Profile* profile,
42 const std::string& app_id,
43 AppListControllerDelegate* controller);
46 void UpdateFromMatch(const TokenizedString& title,
47 const TokenizedStringMatch& match);
49 void UpdateFromLastLaunched(const base::Time& current_time,
50 const base::Time& last_launched);
52 // ChromeSearchResult overides:
53 virtual void Open(int event_flags) OVERRIDE;
54 virtual void InvokeAction(int action_index, int event_flags) OVERRIDE;
55 virtual scoped_ptr<ChromeSearchResult> Duplicate() OVERRIDE;
56 virtual ui::MenuModel* GetContextMenuModel() OVERRIDE;
57 virtual ChromeSearchResultType GetType() OVERRIDE;
60 void StartObservingExtensionRegistry();
61 void StopObservingExtensionRegistry();
63 // Checks if extension is disabled and if enable flow should be started.
64 // Returns true if extension enable flow is started or there is already one
66 bool RunExtensionEnableFlow();
68 // Updates the app item's icon, if necessary making it gray.
71 // extensions::IconImage::Observer overrides:
72 virtual void OnExtensionIconImageChanged(
73 extensions::IconImage* image) OVERRIDE;
75 // AppContextMenuDelegate overrides:
76 virtual void ExecuteLaunchCommand(int event_flags) OVERRIDE;
78 // ExtensionEnableFlowDelegate overrides:
79 virtual void ExtensionEnableFlowFinished() OVERRIDE;
80 virtual void ExtensionEnableFlowAborted(bool user_initiated) OVERRIDE;
82 // extensions::ExtensionRegistryObserver override:
83 virtual void OnExtensionLoaded(
84 content::BrowserContext* browser_context,
85 const extensions::Extension* extension) OVERRIDE;
86 virtual void OnExtensionUninstalled(
87 content::BrowserContext* browser_context,
88 const extensions::Extension* extension,
89 extensions::UninstallReason reason) OVERRIDE;
90 virtual void OnShutdown(extensions::ExtensionRegistry* registry) OVERRIDE;
93 const std::string app_id_;
94 AppListControllerDelegate* controller_;
96 bool is_platform_app_;
97 scoped_ptr<extensions::IconImage> icon_;
98 scoped_ptr<AppContextMenu> context_menu_;
99 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_;
101 extensions::ExtensionRegistry* extension_registry_;
103 DISALLOW_COPY_AND_ASSIGN(AppResult);
106 } // namespace app_list
108 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_RESULT_H_