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

Unified Diff: ash/shelf/shelf_model.cc

Issue 2811853002: reland: mash: Remove ChromeLauncherController's |id_to_item_controller_map_|. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « ash/shelf/shelf_model.h ('k') | ash/shelf/shelf_model_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shelf/shelf_model.cc
diff --git a/ash/shelf/shelf_model.cc b/ash/shelf/shelf_model.cc
index 08483bc742db4b0478bd81924f5388b0b9aabc34..bfc37d2a261edb7c3030df0a9c5a6ff6ee9cab2b 100644
--- a/ash/shelf/shelf_model.cc
+++ b/ash/shelf/shelf_model.cc
@@ -70,10 +70,7 @@ void ShelfModel::RemoveItemAt(int index) {
DCHECK(index >= 0 && index < item_count());
ShelfItem old_item(items_[index]);
items_.erase(items_.begin() + index);
- RemoveShelfItemDelegate(old_item.id);
- // TODO(jamescook): Fold this into ShelfItemRemoved in existing observers.
- for (auto& observer : observers_)
- observer.OnSetShelfItemDelegate(old_item.id, nullptr);
+ id_to_item_delegate_map_.erase(old_item.id);
for (auto& observer : observers_)
observer.ShelfItemRemoved(index, old_item);
}
@@ -160,14 +157,9 @@ int ShelfModel::FirstPanelIndex() const {
void ShelfModel::SetShelfItemDelegate(
ShelfID id,
std::unique_ptr<ShelfItemDelegate> item_delegate) {
- // If another ShelfItemDelegate is already registered for |id|, we assume
- // that this request is replacing ShelfItemDelegate for |id| with
- // |item_delegate|.
- RemoveShelfItemDelegate(id);
-
- for (auto& observer : observers_)
- observer.OnSetShelfItemDelegate(id, item_delegate.get());
-
+ if (item_delegate)
+ item_delegate->set_shelf_id(id);
+ // This assignment replaces any ShelfItemDelegate already registered for |id|.
id_to_item_delegate_map_[id] = std::move(item_delegate);
}
@@ -203,9 +195,4 @@ int ShelfModel::ValidateInsertionIndex(ShelfItemType type, int index) const {
return index;
}
-void ShelfModel::RemoveShelfItemDelegate(ShelfID id) {
- if (id_to_item_delegate_map_.find(id) != id_to_item_delegate_map_.end())
- id_to_item_delegate_map_.erase(id);
-}
-
} // namespace ash
« no previous file with comments | « ash/shelf/shelf_model.h ('k') | ash/shelf/shelf_model_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698