| 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/shelf/app_list_shelf_item_delegate.h" | |
| 6 | |
| 7 #include "ash/common/shelf/shelf_model.h" | |
| 8 #include "ash/shell.h" | |
| 9 #include "grit/ash_strings.h" | |
| 10 #include "ui/app_list/app_list_switches.h" | |
| 11 #include "ui/base/l10n/l10n_util.h" | |
| 12 | |
| 13 namespace ash { | |
| 14 | |
| 15 AppListShelfItemDelegate::AppListShelfItemDelegate() { | |
| 16 ShelfItem app_list; | |
| 17 app_list.type = TYPE_APP_LIST; | |
| 18 Shell::GetInstance()->shelf_model()->Add(app_list); | |
| 19 } | |
| 20 | |
| 21 AppListShelfItemDelegate::~AppListShelfItemDelegate() { | |
| 22 // ShelfItemDelegateManager owns and destroys this class. | |
| 23 } | |
| 24 | |
| 25 ShelfItemDelegate::PerformedAction AppListShelfItemDelegate::ItemSelected( | |
| 26 const ui::Event& event) { | |
| 27 // Pass NULL here to show the app list in the currently active RootWindow. | |
| 28 Shell::GetInstance()->ToggleAppList(NULL); | |
| 29 return ShelfItemDelegate::kAppListMenuShown; | |
| 30 } | |
| 31 | |
| 32 base::string16 AppListShelfItemDelegate::GetTitle() { | |
| 33 ShelfModel* model = Shell::GetInstance()->shelf_model(); | |
| 34 DCHECK(model); | |
| 35 int title_id; | |
| 36 if (app_list::switches::IsExperimentalAppListEnabled()) { | |
| 37 title_id = model->status() == ShelfModel::STATUS_LOADING | |
| 38 ? IDS_ASH_SHELF_APP_LIST_LAUNCHER_SYNCING_TITLE | |
| 39 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE; | |
| 40 } else { | |
| 41 title_id = model->status() == ShelfModel::STATUS_LOADING | |
| 42 ? IDS_ASH_SHELF_APP_LIST_SYNCING_TITLE | |
| 43 : IDS_ASH_SHELF_APP_LIST_TITLE; | |
| 44 } | |
| 45 return l10n_util::GetStringUTF16(title_id); | |
| 46 } | |
| 47 | |
| 48 ShelfMenuModel* AppListShelfItemDelegate::CreateApplicationMenu( | |
| 49 int event_flags) { | |
| 50 // AppList does not show an application menu. | |
| 51 return NULL; | |
| 52 } | |
| 53 | |
| 54 bool AppListShelfItemDelegate::IsDraggable() { | |
| 55 return false; | |
| 56 } | |
| 57 | |
| 58 bool AppListShelfItemDelegate::CanPin() const { | |
| 59 return true; | |
| 60 } | |
| 61 | |
| 62 bool AppListShelfItemDelegate::ShouldShowTooltip() { | |
| 63 return true; | |
| 64 } | |
| 65 | |
| 66 void AppListShelfItemDelegate::Close() {} | |
| 67 | |
| 68 } // namespace ash | |
| OLD | NEW |