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..cd66619d67be3e950bff7f2e27ebd5c44d24feaa 100644 |
--- a/ash/common/shelf/app_list_shelf_item_delegate.cc |
+++ b/ash/common/shelf/app_list_shelf_item_delegate.cc |
@@ -6,18 +6,32 @@ |
#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 data model. |
msw
2016/07/21 21:30:53
nit: s/data/shelf/?
James Cook
2016/07/22 01:20:07
Done.
|
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); |
+ |
+ // Create an AppListShelfItemDelegate for that item. |
+ ShelfID app_list_id = shelf_model->items()[app_list_index].id; |
+ DCHECK_GE(app_list_id, 0); |
+ // The delegate manager owns the newly created shelf item delegate. |
msw
2016/07/21 21:30:53
nit: update comment (no more delegate manager)
James Cook
2016/07/22 01:20:07
Deleted comment since unique_ptr makes ownership t
|
+ shelf_model->SetShelfItemDelegate( |
+ app_list_id, base::MakeUnique<AppListShelfItemDelegate>()); |
} |
+AppListShelfItemDelegate::AppListShelfItemDelegate() {} |
+ |
AppListShelfItemDelegate::~AppListShelfItemDelegate() { |
// ShelfItemDelegateManager owns and destroys this class. |
} |