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 3 // found in the LICENSE file. 4 5 #ifndef UI_APP_LIST_APP_LIST_ITEM_MODEL_H_ 6 #define UI_APP_LIST_APP_LIST_ITEM_MODEL_H_ 7 8 #include <string> 9 10 #include "base/basictypes.h" 11 #include "base/observer_list.h" 12 #include "ui/app_list/app_list_export.h" 13 #include "ui/gfx/image/image_skia.h" 14 15 namespace ui { 16 class MenuModel; 17 } 18 19 namespace app_list { 20 21 class AppListItemModelObserver; 22 23 // AppListItemModel provides icon and title to be shown in a AppListItemView 24 // and action to be executed when the AppListItemView is activated. 25 class APP_LIST_EXPORT AppListItemModel { 26 public: 27 AppListItemModel(); 28 virtual ~AppListItemModel(); 29 30 void SetIcon(const gfx::ImageSkia& icon, bool has_shadow); 31 const gfx::ImageSkia& icon() const { return icon_; } 32 bool has_shadow() const { return has_shadow_; } 33 34 void SetTitle(const std::string& title); 35 const std::string& title() const { return title_; } 36 37 void SetHighlighted(bool highlighted); 38 bool highlighted() const { return highlighted_; } 39 40 void SetIsInstalling(bool is_installing); 41 bool is_installing() const { return is_installing_; } 42 43 void SetPercentDownloaded(int percent_downloaded); 44 int percent_downloaded() const { return percent_downloaded_; } 45 46 void set_app_id(const std::string& app_id) { app_id_ = app_id; } 47 const std::string& app_id() { return app_id_; } 48 49 void AddObserver(AppListItemModelObserver* observer); 50 void RemoveObserver(AppListItemModelObserver* observer); 51 52 // Returns the context menu model for this item. 53 // Note the returned menu model is owned by this item. 54 virtual ui::MenuModel* GetContextMenuModel(); 55 56 private: 57 gfx::ImageSkia icon_; 58 bool has_shadow_; 59 std::string title_; 60 bool highlighted_; 61 bool is_installing_; 62 int percent_downloaded_; 63 std::string app_id_; 64 65 ObserverList<AppListItemModelObserver> observers_; 66 67 DISALLOW_COPY_AND_ASSIGN(AppListItemModel); 68 }; 69 70 } // namespace app_list 71 72 #endif // UI_APP_LIST_APP_LIST_ITEM_MODEL_H_ 73