| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ash/common/shelf/app_list_shelf_item_delegate.h" | |
| 6 | |
| 7 #include "ash/common/shelf/shelf_model.h" | |
| 8 #include "ash/common/wm_shell.h" | |
| 9 #include "ash/strings/grit/ash_strings.h" | |
| 10 #include "base/memory/ptr_util.h" | |
| 11 #include "ui/app_list/app_list_switches.h" | |
| 12 #include "ui/base/l10n/l10n_util.h" | |
| 13 | |
| 14 namespace ash { | |
| 15 | |
| 16 // static | |
| 17 void AppListShelfItemDelegate::CreateAppListItemAndDelegate(ShelfModel* model) { | |
| 18 // Add the app list item to the shelf model. | |
| 19 ShelfItem item; | |
| 20 item.type = TYPE_APP_LIST; | |
| 21 item.title = l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE); | |
| 22 int index = model->Add(item); | |
| 23 DCHECK_GE(index, 0); | |
| 24 | |
| 25 // Create an AppListShelfItemDelegate for that item. | |
| 26 ShelfID id = model->items()[index].id; | |
| 27 DCHECK_GE(id, 0); | |
| 28 model->SetShelfItemDelegate(id, base::MakeUnique<AppListShelfItemDelegate>()); | |
| 29 } | |
| 30 | |
| 31 AppListShelfItemDelegate::AppListShelfItemDelegate() {} | |
| 32 | |
| 33 AppListShelfItemDelegate::~AppListShelfItemDelegate() {} | |
| 34 | |
| 35 ShelfAction AppListShelfItemDelegate::ItemSelected(ui::EventType event_type, | |
| 36 int event_flags, | |
| 37 int64_t display_id, | |
| 38 ShelfLaunchSource source) { | |
| 39 WmShell::Get()->ToggleAppList(); | |
| 40 return SHELF_ACTION_APP_LIST_SHOWN; | |
| 41 } | |
| 42 | |
| 43 ShelfAppMenuItemList AppListShelfItemDelegate::GetAppMenuItems( | |
| 44 int event_flags) { | |
| 45 // Return an empty item list to avoid showing an application menu. | |
| 46 return ShelfAppMenuItemList(); | |
| 47 } | |
| 48 | |
| 49 void AppListShelfItemDelegate::ExecuteCommand(uint32_t command_id, | |
| 50 int event_flags) { | |
| 51 // This delegate does not support showing an application menu. | |
| 52 NOTIMPLEMENTED(); | |
| 53 } | |
| 54 | |
| 55 void AppListShelfItemDelegate::Close() {} | |
| 56 | |
| 57 } // namespace ash | |
| OLD | NEW |