Chromium Code Reviews| 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 UI_APP_LIST_APP_LIST_ITEM_MODEL_H_ | 5 #ifndef UI_APP_LIST_APP_LIST_ITEM_MODEL_H_ |
| 6 #define UI_APP_LIST_APP_LIST_ITEM_MODEL_H_ | 6 #define UI_APP_LIST_APP_LIST_ITEM_MODEL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "sync/api/string_ordinal.h" | |
| 12 #include "ui/app_list/app_list_export.h" | 13 #include "ui/app_list/app_list_export.h" |
| 13 #include "ui/gfx/image/image_skia.h" | 14 #include "ui/gfx/image/image_skia.h" |
| 14 | 15 |
| 15 namespace ui { | 16 namespace ui { |
| 16 class MenuModel; | 17 class MenuModel; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace app_list { | 20 namespace app_list { |
| 20 | 21 |
| 21 class AppListItemModelObserver; | 22 class AppListItemModelObserver; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 39 void SetHighlighted(bool highlighted); | 40 void SetHighlighted(bool highlighted); |
| 40 bool highlighted() const { return highlighted_; } | 41 bool highlighted() const { return highlighted_; } |
| 41 | 42 |
| 42 void SetIsInstalling(bool is_installing); | 43 void SetIsInstalling(bool is_installing); |
| 43 bool is_installing() const { return is_installing_; } | 44 bool is_installing() const { return is_installing_; } |
| 44 | 45 |
| 45 void SetPercentDownloaded(int percent_downloaded); | 46 void SetPercentDownloaded(int percent_downloaded); |
| 46 int percent_downloaded() const { return percent_downloaded_; } | 47 int percent_downloaded() const { return percent_downloaded_; } |
| 47 | 48 |
| 48 const std::string& id() const { return id_; } | 49 const std::string& id() const { return id_; } |
| 50 const syncer::StringOrdinal& position() const { return position_; } | |
| 51 void set_position(syncer::StringOrdinal& new_position) { | |
| 52 position_ = new_position; | |
|
xiyuan
2013/10/18 23:04:08
Should we add an observer method for this as well?
stevenjb
2013/10/19 01:04:43
Yes, when we sync this will need to be more than a
| |
| 53 } | |
| 49 | 54 |
| 50 void AddObserver(AppListItemModelObserver* observer); | 55 void AddObserver(AppListItemModelObserver* observer); |
| 51 void RemoveObserver(AppListItemModelObserver* observer); | 56 void RemoveObserver(AppListItemModelObserver* observer); |
| 52 | 57 |
| 53 // Returns a string used for initially sorting the apps (used by | 58 // Returns a string used for initially sorting the apps (used by |
| 54 // AppListModel::AddItem). Defaults to an empty string. | 59 // AppListModel::AddItem). Defaults to an empty string. |
| 55 virtual std::string GetSortOrder() const; | 60 virtual std::string GetSortOrder() const; |
| 56 | 61 |
| 57 // Activates (opens) the item. Does nothing by default. | 62 // Activates (opens) the item. Does nothing by default. |
| 58 virtual void Activate(int event_flags); | 63 virtual void Activate(int event_flags); |
| 59 | 64 |
| 60 // Returns a static const char* identifier for the subclass (defaults to ""). | 65 // Returns a static const char* identifier for the subclass (defaults to ""). |
| 61 // Pointers can be compared for quick type checking. | 66 // Pointers can be compared for quick type checking. |
| 62 virtual const char* GetAppType() const; | 67 virtual const char* GetAppType() const; |
| 63 | 68 |
| 64 // Returns the context menu model for this item, or NULL if there is currently | 69 // Returns the context menu model for this item, or NULL if there is currently |
| 65 // no menu for the item (e.g. during install). | 70 // no menu for the item (e.g. during install). |
| 66 // Note the returned menu model is owned by this item. | 71 // Note the returned menu model is owned by this item. |
| 67 virtual ui::MenuModel* GetContextMenuModel(); | 72 virtual ui::MenuModel* GetContextMenuModel(); |
| 68 | 73 |
| 69 private: | 74 private: |
| 70 const std::string id_; | 75 const std::string id_; |
| 76 syncer::StringOrdinal position_; | |
| 71 gfx::ImageSkia icon_; | 77 gfx::ImageSkia icon_; |
| 72 bool has_shadow_; | 78 bool has_shadow_; |
| 73 std::string title_; | 79 std::string title_; |
| 74 std::string full_name_; | 80 std::string full_name_; |
| 75 bool highlighted_; | 81 bool highlighted_; |
| 76 bool is_installing_; | 82 bool is_installing_; |
| 77 int percent_downloaded_; | 83 int percent_downloaded_; |
| 78 | 84 |
| 79 ObserverList<AppListItemModelObserver> observers_; | 85 ObserverList<AppListItemModelObserver> observers_; |
| 80 | 86 |
| 81 DISALLOW_COPY_AND_ASSIGN(AppListItemModel); | 87 DISALLOW_COPY_AND_ASSIGN(AppListItemModel); |
| 82 }; | 88 }; |
| 83 | 89 |
| 84 } // namespace app_list | 90 } // namespace app_list |
| 85 | 91 |
| 86 #endif // UI_APP_LIST_APP_LIST_ITEM_MODEL_H_ | 92 #endif // UI_APP_LIST_APP_LIST_ITEM_MODEL_H_ |
| OLD | NEW |