Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Unified Diff: ui/app_list/app_list_item_list.h

Issue 148403007: Protect AppListItemList Add/Remove and fix sync bugs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/app_list/app_list_item_list.h
diff --git a/ui/app_list/app_list_item_list.h b/ui/app_list/app_list_item_list.h
index d52acf2c8bee3bf9d401c3a51b208d8673e106e6..a5fa15263a6ffa09f3d65c2bfeb2eea3c5a8fafe 100644
--- a/ui/app_list/app_list_item_list.h
+++ b/ui/app_list/app_list_item_list.h
@@ -37,25 +37,39 @@ class APP_LIST_EXPORT AppListItemList {
// Note: Requires a linear search.
bool FindItemIndex(const std::string& id, size_t* index);
+ // Moves item at |from_index| to |to_index|.
+ // Triggers observers_.OnListItemMoved().
+ void MoveItem(size_t from_index, size_t to_index);
+
+ // Sets the position of |item| which is expected to be a member of
+ // |app_list_items_| and sorts the list accordingly.
+ void SetItemPosition(AppListItem* item,
+ const syncer::StringOrdinal& new_position);
+
+ AppListItem* item_at(size_t index) {
+ DCHECK_LT(index, app_list_items_.size());
+ return app_list_items_[index];
+ }
+ const AppListItem* item_at(size_t index) const {
+ DCHECK_LT(index, app_list_items_.size());
+ return app_list_items_[index];
+ }
+ size_t item_count() const { return app_list_items_.size(); }
+
+ private:
+ friend class AppListItemListTest;
+ friend class AppListModel;
+ friend class AppListModelTest; // TODO(stevenjb): Remove dependency
+
// Adds |item| to the end of |app_list_items_|. Takes ownership of |item|.
// Triggers observers_.OnListItemAdded(). Returns the index of the added item.
size_t AddItem(AppListItem* item);
- // Inserts |item| at the |index| into |app_list_items_|. Takes ownership of
- // |item|. Triggers observers_.OnListItemAdded().
- void InsertItemAt(AppListItem* item, size_t index);
-
// Finds item matching |id| in |app_list_items_| (linear search) and deletes
// it. Triggers observers_.OnListItemRemoved() after removing the item from
// the list and before deleting it.
void DeleteItem(const std::string& id);
- // Deletes all items matching |type| which must be a statically defined
- // type descriptor, e.g. AppListFolderItem::kItemType. If |type| is NULL,
- // deletes all items. Triggers observers_.OnListItemRemoved() for each item
- // as for DeleteItem.
- void DeleteItemsByType(const char* type);
-
// Removes the item with matching |id| in |app_list_items_| without deleting
// it. Returns a scoped pointer containing the removed item.
scoped_ptr<AppListItem> RemoveItem(const std::string& id);
@@ -64,22 +78,6 @@ class APP_LIST_EXPORT AppListItemList {
// Returns a scoped pointer containing the removed item.
scoped_ptr<AppListItem> RemoveItemAt(size_t index);
- // Moves item at |from_index| to |to_index|.
- // Triggers observers_.OnListItemMoved().
- void MoveItem(size_t from_index, size_t to_index);
-
- // Sets the position of |item| which is expected to be a member of
- // |app_list_items_| and sorts the list accordingly.
- void SetItemPosition(AppListItem* item,
- const syncer::StringOrdinal& new_position);
-
- AppListItem* item_at(size_t index) {
- DCHECK_LT(index, app_list_items_.size());
- return app_list_items_[index];
- }
- size_t item_count() const { return app_list_items_.size(); }
-
- private:
// Deletes item at |index| and signals observers.
void DeleteItemAt(size_t index);

Powered by Google App Engine
This is Rietveld 408576698