Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/common/shelf/app_list_shelf_item_delegate.h" | 5 #include "ash/common/shelf/app_list_shelf_item_delegate.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/shelf_model.h" | 7 #include "ash/common/shelf/shelf_model.h" |
| 8 #include "ash/common/wm_shell.h" | 8 #include "ash/common/wm_shell.h" |
| 9 #include "base/memory/ptr_util.h" | |
| 9 #include "grit/ash_strings.h" | 10 #include "grit/ash_strings.h" |
| 10 #include "ui/app_list/app_list_switches.h" | 11 #include "ui/app_list/app_list_switches.h" |
| 11 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 12 | 13 |
| 13 namespace ash { | 14 namespace ash { |
| 14 | 15 |
| 15 AppListShelfItemDelegate::AppListShelfItemDelegate() { | 16 // static |
| 17 void AppListShelfItemDelegate::CreateAppListItemAndDelegate( | |
| 18 ShelfModel* shelf_model) { | |
| 19 // 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.
| |
| 16 ShelfItem app_list; | 20 ShelfItem app_list; |
| 17 app_list.type = TYPE_APP_LIST; | 21 app_list.type = TYPE_APP_LIST; |
| 18 WmShell::Get()->shelf_model()->Add(app_list); | 22 int app_list_index = shelf_model->Add(app_list); |
| 23 DCHECK_GE(app_list_index, 0); | |
| 24 | |
| 25 // Create an AppListShelfItemDelegate for that item. | |
| 26 ShelfID app_list_id = shelf_model->items()[app_list_index].id; | |
| 27 DCHECK_GE(app_list_id, 0); | |
| 28 // 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
| |
| 29 shelf_model->SetShelfItemDelegate( | |
| 30 app_list_id, base::MakeUnique<AppListShelfItemDelegate>()); | |
| 19 } | 31 } |
| 20 | 32 |
| 33 AppListShelfItemDelegate::AppListShelfItemDelegate() {} | |
| 34 | |
| 21 AppListShelfItemDelegate::~AppListShelfItemDelegate() { | 35 AppListShelfItemDelegate::~AppListShelfItemDelegate() { |
| 22 // ShelfItemDelegateManager owns and destroys this class. | 36 // ShelfItemDelegateManager owns and destroys this class. |
| 23 } | 37 } |
| 24 | 38 |
| 25 ShelfItemDelegate::PerformedAction AppListShelfItemDelegate::ItemSelected( | 39 ShelfItemDelegate::PerformedAction AppListShelfItemDelegate::ItemSelected( |
| 26 const ui::Event& event) { | 40 const ui::Event& event) { |
| 27 WmShell::Get()->ToggleAppList(); | 41 WmShell::Get()->ToggleAppList(); |
| 28 return ShelfItemDelegate::kAppListMenuShown; | 42 return ShelfItemDelegate::kAppListMenuShown; |
| 29 } | 43 } |
| 30 | 44 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 58 return true; | 72 return true; |
| 59 } | 73 } |
| 60 | 74 |
| 61 bool AppListShelfItemDelegate::ShouldShowTooltip() { | 75 bool AppListShelfItemDelegate::ShouldShowTooltip() { |
| 62 return true; | 76 return true; |
| 63 } | 77 } |
| 64 | 78 |
| 65 void AppListShelfItemDelegate::Close() {} | 79 void AppListShelfItemDelegate::Close() {} |
| 66 | 80 |
| 67 } // namespace ash | 81 } // namespace ash |
| OLD | NEW |