| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_EXTENSION_APP_ITEM_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_ITEM_H_ |
| 6 #define CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_ITEM_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_ITEM_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/image_loading_tracker.h" | 11 #include "chrome/browser/extensions/extension_icon_image.h" |
| 12 #include "chrome/browser/ui/app_list/chrome_app_list_item.h" | 12 #include "chrome/browser/ui/app_list/chrome_app_list_item.h" |
| 13 #include "ui/base/models/simple_menu_model.h" | 13 #include "ui/base/models/simple_menu_model.h" |
| 14 | 14 |
| 15 class AppListController; | 15 class AppListController; |
| 16 class ExtensionResource; | 16 class ExtensionResource; |
| 17 class Profile; | 17 class Profile; |
| 18 class SkBitmap; | 18 class SkBitmap; |
| 19 | 19 |
| 20 namespace extensions { | 20 namespace extensions { |
| 21 class Extension; | 21 class Extension; |
| 22 } | 22 } |
| 23 | 23 |
| 24 // ExtensionAppItem represents an extension app in app list. | 24 // ExtensionAppItem represents an extension app in app list. |
| 25 class ExtensionAppItem : public ChromeAppListItem, | 25 class ExtensionAppItem : public ChromeAppListItem, |
| 26 public ImageLoadingTracker::Observer, | 26 public extensions::IconImage::Observer, |
| 27 public ui::SimpleMenuModel::Delegate { | 27 public ui::SimpleMenuModel::Delegate { |
| 28 public: | 28 public: |
| 29 ExtensionAppItem(Profile* profile, | 29 ExtensionAppItem(Profile* profile, |
| 30 const extensions::Extension* extension, | 30 const extensions::Extension* extension, |
| 31 AppListController* controller); | 31 AppListController* controller); |
| 32 virtual ~ExtensionAppItem(); | 32 virtual ~ExtensionAppItem(); |
| 33 | 33 |
| 34 // Gets extension associated with this model. Returns NULL if extension | 34 // Gets extension associated with this model. Returns NULL if extension |
| 35 // no longer exists. | 35 // no longer exists. |
| 36 const extensions::Extension* GetExtension() const; | 36 const extensions::Extension* GetExtension() const; |
| 37 | 37 |
| 38 const std::string& extension_id() const { | 38 const std::string& extension_id() const { |
| 39 return extension_id_; | 39 return extension_id_; |
| 40 } | 40 } |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 // Returns true if this item represents a version of the Talk extension. | 43 // Returns true if this item represents a version of the Talk extension. |
| 44 bool IsTalkExtension() const; | 44 bool IsTalkExtension() const; |
| 45 | 45 |
| 46 // Loads extension icon. | 46 // Loads extension icon. |
| 47 void LoadImage(const extensions::Extension* extension); | 47 void LoadImage(const extensions::Extension* extension); |
| 48 | 48 |
| 49 void ShowExtensionOptions(); | 49 void ShowExtensionOptions(); |
| 50 void ShowExtensionDetails(); | 50 void ShowExtensionDetails(); |
| 51 void StartExtensionUninstall(); | 51 void StartExtensionUninstall(); |
| 52 | 52 |
| 53 // Overridden from ImageLoadingTracker::Observer: | 53 // Overridden from extensions::IconImage::Observer: |
| 54 virtual void OnImageLoaded(const gfx::Image& image, | 54 virtual void OnExtensionIconImageChanged( |
| 55 const std::string& extension_id, | 55 extensions::IconImage* image) OVERRIDE; |
| 56 int tracker_index) OVERRIDE; | |
| 57 | 56 |
| 58 // Overridden from ui::SimpleMenuModel::Delegate: | 57 // Overridden from ui::SimpleMenuModel::Delegate: |
| 59 virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE; | 58 virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE; |
| 60 virtual string16 GetLabelForCommandId(int command_id) const OVERRIDE; | 59 virtual string16 GetLabelForCommandId(int command_id) const OVERRIDE; |
| 61 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 60 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| 62 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 61 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| 63 virtual bool GetAcceleratorForCommandId( | 62 virtual bool GetAcceleratorForCommandId( |
| 64 int command_id, | 63 int command_id, |
| 65 ui::Accelerator* acclelrator) OVERRIDE; | 64 ui::Accelerator* acclelrator) OVERRIDE; |
| 66 virtual void ExecuteCommand(int command_id) OVERRIDE; | 65 virtual void ExecuteCommand(int command_id) OVERRIDE; |
| 67 | 66 |
| 68 // Overridden from ChromeAppListItem: | 67 // Overridden from ChromeAppListItem: |
| 69 virtual void Activate(int event_flags) OVERRIDE; | 68 virtual void Activate(int event_flags) OVERRIDE; |
| 70 virtual ui::MenuModel* GetContextMenuModel() OVERRIDE; | 69 virtual ui::MenuModel* GetContextMenuModel() OVERRIDE; |
| 71 | 70 |
| 72 Profile* profile_; | 71 Profile* profile_; |
| 73 const std::string extension_id_; | 72 const std::string extension_id_; |
| 74 AppListController* controller_; | 73 AppListController* controller_; |
| 75 | 74 |
| 76 scoped_ptr<ImageLoadingTracker> tracker_; | 75 scoped_ptr<extensions::IconImage> icon_; |
| 77 scoped_ptr<ui::SimpleMenuModel> context_menu_model_; | 76 scoped_ptr<ui::SimpleMenuModel> context_menu_model_; |
| 78 | 77 |
| 79 DISALLOW_COPY_AND_ASSIGN(ExtensionAppItem); | 78 DISALLOW_COPY_AND_ASSIGN(ExtensionAppItem); |
| 80 }; | 79 }; |
| 81 | 80 |
| 82 #endif // CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_ITEM_H_ | 81 #endif // CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_ITEM_H_ |
| OLD | NEW |