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.
5 #include "ash/shelf/app_list_shelf_item_delegate.h"
7 #include "ash/shelf/shelf_model.h"
9 #include "ash/shell_delegate.h"
10 #include "grit/ash_strings.h"
11 #include "ui/app_list/app_list_switches.h"
12 #include "ui/base/l10n/l10n_util.h"
16 AppListShelfItemDelegate::AppListShelfItemDelegate() {
18 app_list
.type
= TYPE_APP_LIST
;
19 Shell::GetInstance()->shelf_model()->Add(app_list
);
22 AppListShelfItemDelegate::~AppListShelfItemDelegate() {
23 // ShelfItemDelegateManager owns and destroys this class.
26 ShelfItemDelegate::PerformedAction
AppListShelfItemDelegate::ItemSelected(
27 const ui::Event
& event
) {
28 // Pass NULL here to show the app list in the currently active RootWindow.
29 Shell::GetInstance()->ToggleAppList(NULL
);
30 return ShelfItemDelegate::kAppListMenuShown
;
33 base::string16
AppListShelfItemDelegate::GetTitle() {
34 ShelfModel
* model
= Shell::GetInstance()->shelf_model();
37 if (app_list::switches::IsExperimentalAppListEnabled()) {
38 title_id
= model
->status() == ShelfModel::STATUS_LOADING
39 ? IDS_ASH_SHELF_APP_LIST_LAUNCHER_SYNCING_TITLE
40 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE
;
42 title_id
= model
->status() == ShelfModel::STATUS_LOADING
43 ? IDS_ASH_SHELF_APP_LIST_SYNCING_TITLE
44 : IDS_ASH_SHELF_APP_LIST_TITLE
;
46 return l10n_util::GetStringUTF16(title_id
);
49 ui::MenuModel
* AppListShelfItemDelegate::CreateContextMenu(
50 aura::Window
* root_window
) {
51 return Shell::GetInstance()->delegate()->CreateContextMenu(root_window
,
56 ShelfMenuModel
* AppListShelfItemDelegate::CreateApplicationMenu(
58 // AppList does not show an application menu.
62 bool AppListShelfItemDelegate::IsDraggable() {
66 bool AppListShelfItemDelegate::ShouldShowTooltip() {
70 void AppListShelfItemDelegate::Close() {