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

Unified Diff: ash/common/shelf/app_list_shelf_item_delegate.cc

Issue 2171813004: mash: Fold ShelfItemDelegateManager into ShelfModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: explicitly destroy ShelfItemDelegates Created 4 years, 5 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/common/shelf/app_list_shelf_item_delegate.h ('k') | ash/common/shelf/shelf_item_delegate_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/shelf/app_list_shelf_item_delegate.cc
diff --git a/ash/common/shelf/app_list_shelf_item_delegate.cc b/ash/common/shelf/app_list_shelf_item_delegate.cc
index ce1b5e3440120bce55121defca633f68a730a377..128a7e7866620bb83cb7006c282f7d418a03ea7d 100644
--- a/ash/common/shelf/app_list_shelf_item_delegate.cc
+++ b/ash/common/shelf/app_list_shelf_item_delegate.cc
@@ -6,22 +6,33 @@
#include "ash/common/shelf/shelf_model.h"
#include "ash/common/wm_shell.h"
+#include "base/memory/ptr_util.h"
#include "grit/ash_strings.h"
#include "ui/app_list/app_list_switches.h"
#include "ui/base/l10n/l10n_util.h"
namespace ash {
-AppListShelfItemDelegate::AppListShelfItemDelegate() {
+// static
+void AppListShelfItemDelegate::CreateAppListItemAndDelegate(
+ ShelfModel* shelf_model) {
+ // Add the app list item to the shelf model.
ShelfItem app_list;
app_list.type = TYPE_APP_LIST;
- WmShell::Get()->shelf_model()->Add(app_list);
-}
+ int app_list_index = shelf_model->Add(app_list);
+ DCHECK_GE(app_list_index, 0);
-AppListShelfItemDelegate::~AppListShelfItemDelegate() {
- // ShelfItemDelegateManager owns and destroys this class.
+ // Create an AppListShelfItemDelegate for that item.
+ ShelfID app_list_id = shelf_model->items()[app_list_index].id;
+ DCHECK_GE(app_list_id, 0);
+ shelf_model->SetShelfItemDelegate(
+ app_list_id, base::MakeUnique<AppListShelfItemDelegate>());
}
+AppListShelfItemDelegate::AppListShelfItemDelegate() {}
+
+AppListShelfItemDelegate::~AppListShelfItemDelegate() {}
+
ShelfItemDelegate::PerformedAction AppListShelfItemDelegate::ItemSelected(
const ui::Event& event) {
WmShell::Get()->ToggleAppList();
« no previous file with comments | « ash/common/shelf/app_list_shelf_item_delegate.h ('k') | ash/common/shelf/shelf_item_delegate_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698