| 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_RESULT_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_RESULT_H_ |
| 6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_RESULT_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_RESULT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/scoped_observer.h" |
| 11 #include "chrome/browser/extensions/extension_icon_image.h" | 12 #include "chrome/browser/extensions/extension_icon_image.h" |
| 12 #include "chrome/browser/extensions/install_observer.h" | |
| 13 #include "chrome/browser/ui/app_list/app_context_menu_delegate.h" | 13 #include "chrome/browser/ui/app_list/app_context_menu_delegate.h" |
| 14 #include "chrome/browser/ui/app_list/search/chrome_search_result.h" | 14 #include "chrome/browser/ui/app_list/search/chrome_search_result.h" |
| 15 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" | 15 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" |
| 16 #include "extensions/browser/extension_registry_observer.h" |
| 16 | 17 |
| 17 class AppListControllerDelegate; | 18 class AppListControllerDelegate; |
| 18 class ExtensionEnableFlow; | 19 class ExtensionEnableFlow; |
| 19 class Profile; | 20 class Profile; |
| 20 | 21 |
| 21 namespace extensions { | 22 namespace extensions { |
| 22 class InstallTracker; | 23 class ExtensionRegistry; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace app_list { | 26 namespace app_list { |
| 26 | 27 |
| 27 class AppContextMenu; | 28 class AppContextMenu; |
| 28 class TokenizedString; | 29 class TokenizedString; |
| 29 class TokenizedStringMatch; | 30 class TokenizedStringMatch; |
| 30 | 31 |
| 31 class AppResult : public ChromeSearchResult, | 32 class AppResult : public ChromeSearchResult, |
| 32 public extensions::IconImage::Observer, | 33 public extensions::IconImage::Observer, |
| 33 public AppContextMenuDelegate, | 34 public AppContextMenuDelegate, |
| 34 public ExtensionEnableFlowDelegate, | 35 public ExtensionEnableFlowDelegate, |
| 35 public extensions::InstallObserver { | 36 public extensions::ExtensionRegistryObserver { |
| 36 public: | 37 public: |
| 37 AppResult(Profile* profile, | 38 AppResult(Profile* profile, |
| 38 const std::string& app_id, | 39 const std::string& app_id, |
| 39 AppListControllerDelegate* controller); | 40 AppListControllerDelegate* controller); |
| 40 virtual ~AppResult(); | 41 virtual ~AppResult(); |
| 41 | 42 |
| 42 void UpdateFromMatch(const TokenizedString& title, | 43 void UpdateFromMatch(const TokenizedString& title, |
| 43 const TokenizedStringMatch& match); | 44 const TokenizedStringMatch& match); |
| 44 | 45 |
| 45 // ChromeSearchResult overides: | 46 // ChromeSearchResult overides: |
| 46 virtual void Open(int event_flags) OVERRIDE; | 47 virtual void Open(int event_flags) OVERRIDE; |
| 47 virtual void InvokeAction(int action_index, int event_flags) OVERRIDE; | 48 virtual void InvokeAction(int action_index, int event_flags) OVERRIDE; |
| 48 virtual scoped_ptr<ChromeSearchResult> Duplicate() OVERRIDE; | 49 virtual scoped_ptr<ChromeSearchResult> Duplicate() OVERRIDE; |
| 49 virtual ui::MenuModel* GetContextMenuModel() OVERRIDE; | 50 virtual ui::MenuModel* GetContextMenuModel() OVERRIDE; |
| 50 virtual ChromeSearchResultType GetType() OVERRIDE; | 51 virtual ChromeSearchResultType GetType() OVERRIDE; |
| 51 | 52 |
| 52 private: | 53 private: |
| 53 void StartObservingInstall(); | |
| 54 void StopObservingInstall(); | |
| 55 | |
| 56 // Checks if extension is disabled and if enable flow should be started. | 54 // Checks if extension is disabled and if enable flow should be started. |
| 57 // Returns true if extension enable flow is started or there is already one | 55 // Returns true if extension enable flow is started or there is already one |
| 58 // running. | 56 // running. |
| 59 bool RunExtensionEnableFlow(); | 57 bool RunExtensionEnableFlow(); |
| 60 | 58 |
| 61 // Updates the app item's icon, if necessary making it gray. | 59 // Updates the app item's icon, if necessary making it gray. |
| 62 void UpdateIcon(); | 60 void UpdateIcon(); |
| 63 | 61 |
| 64 // extensions::IconImage::Observer overrides: | 62 // extensions::IconImage::Observer overrides: |
| 65 virtual void OnExtensionIconImageChanged( | 63 virtual void OnExtensionIconImageChanged( |
| 66 extensions::IconImage* image) OVERRIDE; | 64 extensions::IconImage* image) OVERRIDE; |
| 67 | 65 |
| 68 // AppContextMenuDelegate overrides: | 66 // AppContextMenuDelegate overrides: |
| 69 virtual void ExecuteLaunchCommand(int event_flags) OVERRIDE; | 67 virtual void ExecuteLaunchCommand(int event_flags) OVERRIDE; |
| 70 | 68 |
| 71 // ExtensionEnableFlowDelegate overrides: | 69 // ExtensionEnableFlowDelegate overrides: |
| 72 virtual void ExtensionEnableFlowFinished() OVERRIDE; | 70 virtual void ExtensionEnableFlowFinished() OVERRIDE; |
| 73 virtual void ExtensionEnableFlowAborted(bool user_initiated) OVERRIDE; | 71 virtual void ExtensionEnableFlowAborted(bool user_initiated) OVERRIDE; |
| 74 | 72 |
| 75 // extensions::InstallObserver overrides: | 73 // extensions::ExtensionRegistryObserver override: |
| 76 virtual void OnExtensionLoaded( | 74 virtual void OnExtensionLoaded( |
| 75 content::BrowserContext* browser_context, |
| 77 const extensions::Extension* extension) OVERRIDE; | 76 const extensions::Extension* extension) OVERRIDE; |
| 78 virtual void OnExtensionUninstalled( | 77 virtual void OnExtensionUninstalled( |
| 78 content::BrowserContext* browser_context, |
| 79 const extensions::Extension* extension) OVERRIDE; | 79 const extensions::Extension* extension) OVERRIDE; |
| 80 virtual void OnShutdown() OVERRIDE; | |
| 81 | 80 |
| 82 Profile* profile_; | 81 Profile* profile_; |
| 83 const std::string app_id_; | 82 const std::string app_id_; |
| 84 AppListControllerDelegate* controller_; | 83 AppListControllerDelegate* controller_; |
| 85 | 84 |
| 85 ScopedObserver<extensions::ExtensionRegistry, |
| 86 extensions::ExtensionRegistryObserver> |
| 87 extension_registry_observer_; |
| 88 |
| 86 bool is_platform_app_; | 89 bool is_platform_app_; |
| 87 scoped_ptr<extensions::IconImage> icon_; | 90 scoped_ptr<extensions::IconImage> icon_; |
| 88 scoped_ptr<AppContextMenu> context_menu_; | 91 scoped_ptr<AppContextMenu> context_menu_; |
| 89 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; | 92 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; |
| 90 | 93 |
| 91 extensions::InstallTracker* install_tracker_; // Not owned. | |
| 92 | |
| 93 DISALLOW_COPY_AND_ASSIGN(AppResult); | 94 DISALLOW_COPY_AND_ASSIGN(AppResult); |
| 94 }; | 95 }; |
| 95 | 96 |
| 96 } // namespace app_list | 97 } // namespace app_list |
| 97 | 98 |
| 98 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_RESULT_H_ | 99 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_APP_RESULT_H_ |
| OLD | NEW |