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/extensions/extension_enable_flow_delegate.h"
13 #include "extensions/browser/extension_icon_image.h"
14 #include "extensions/browser/extension_registry_observer.h"
15 #include "ui/app_list/search_result.h"
17 class AppListControllerDelegate
;
18 class ExtensionEnableFlow
;
25 namespace extensions
{
26 class ExtensionRegistry
;
33 class AppResult
: public SearchResult
,
34 public extensions::IconImage::Observer
,
35 public AppContextMenuDelegate
,
36 public ExtensionEnableFlowDelegate
,
37 public extensions::ExtensionRegistryObserver
{
39 AppResult(Profile
* profile
,
40 const std::string
& app_id
,
41 AppListControllerDelegate
* controller
,
42 bool is_recommendation
);
43 ~AppResult() override
;
45 void UpdateFromLastLaunched(const base::Time
& current_time
,
46 const base::Time
& last_launched
);
48 // SearchResult overrides:
49 void Open(int event_flags
) override
;
50 scoped_ptr
<SearchResult
> Duplicate() const override
;
51 ui::MenuModel
* GetContextMenuModel() override
;
54 void StartObservingExtensionRegistry();
55 void StopObservingExtensionRegistry();
57 // Checks if extension is disabled and if enable flow should be started.
58 // Returns true if extension enable flow is started or there is already one
60 bool RunExtensionEnableFlow();
62 // Updates the app item's icon, if necessary making it gray.
65 // extensions::IconImage::Observer overrides:
66 void OnExtensionIconImageChanged(extensions::IconImage
* image
) override
;
68 // AppContextMenuDelegate overrides:
69 void ExecuteLaunchCommand(int event_flags
) override
;
71 // ExtensionEnableFlowDelegate overrides:
72 void ExtensionEnableFlowFinished() override
;
73 void ExtensionEnableFlowAborted(bool user_initiated
) override
;
75 // extensions::ExtensionRegistryObserver override:
76 void OnExtensionLoaded(content::BrowserContext
* browser_context
,
77 const extensions::Extension
* extension
) override
;
78 void OnShutdown(extensions::ExtensionRegistry
* registry
) override
;
81 const std::string app_id_
;
82 AppListControllerDelegate
* controller_
;
84 bool is_platform_app_
;
85 scoped_ptr
<extensions::IconImage
> icon_
;
86 scoped_ptr
<AppContextMenu
> context_menu_
;
87 scoped_ptr
<ExtensionEnableFlow
> extension_enable_flow_
;
89 extensions::ExtensionRegistry
* extension_registry_
;
91 DISALLOW_COPY_AND_ASSIGN(AppResult
);
94 } // namespace app_list
96 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_RESULT_H_