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

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: cleanup 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
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.
}

Powered by Google App Engine
This is Rietveld 408576698