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