| 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 shelf model. |
| 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 shelf_model->SetShelfItemDelegate( |
| 29 app_list_id, base::MakeUnique<AppListShelfItemDelegate>()); |
| 19 } | 30 } |
| 20 | 31 |
| 21 AppListShelfItemDelegate::~AppListShelfItemDelegate() { | 32 AppListShelfItemDelegate::AppListShelfItemDelegate() {} |
| 22 // ShelfItemDelegateManager owns and destroys this class. | 33 |
| 23 } | 34 AppListShelfItemDelegate::~AppListShelfItemDelegate() {} |
| 24 | 35 |
| 25 ShelfItemDelegate::PerformedAction AppListShelfItemDelegate::ItemSelected( | 36 ShelfItemDelegate::PerformedAction AppListShelfItemDelegate::ItemSelected( |
| 26 const ui::Event& event) { | 37 const ui::Event& event) { |
| 27 WmShell::Get()->ToggleAppList(); | 38 WmShell::Get()->ToggleAppList(); |
| 28 return ShelfItemDelegate::kAppListMenuShown; | 39 return ShelfItemDelegate::kAppListMenuShown; |
| 29 } | 40 } |
| 30 | 41 |
| 31 base::string16 AppListShelfItemDelegate::GetTitle() { | 42 base::string16 AppListShelfItemDelegate::GetTitle() { |
| 32 ShelfModel* model = WmShell::Get()->shelf_model(); | 43 ShelfModel* model = WmShell::Get()->shelf_model(); |
| 33 DCHECK(model); | 44 DCHECK(model); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 58 return true; | 69 return true; |
| 59 } | 70 } |
| 60 | 71 |
| 61 bool AppListShelfItemDelegate::ShouldShowTooltip() { | 72 bool AppListShelfItemDelegate::ShouldShowTooltip() { |
| 62 return true; | 73 return true; |
| 63 } | 74 } |
| 64 | 75 |
| 65 void AppListShelfItemDelegate::Close() {} | 76 void AppListShelfItemDelegate::Close() {} |
| 66 | 77 |
| 67 } // namespace ash | 78 } // namespace ash |
| OLD | NEW |