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/shelf/app_list_shelf_item_delegate.h" | 5 #include "ash/shelf/app_list_shelf_item_delegate.h" |
6 | 6 |
| 7 #include "ash/launcher/launcher_item_delegate_manager.h" |
7 #include "ash/launcher/launcher_model.h" | 8 #include "ash/launcher/launcher_model.h" |
8 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_delegate.h" |
9 #include "grit/ash_strings.h" | 11 #include "grit/ash_strings.h" |
10 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
11 | 13 |
12 namespace ash { | 14 namespace ash { |
13 namespace internal { | 15 namespace internal { |
14 | 16 |
15 AppListShelfItemDelegate::AppListShelfItemDelegate() { | 17 AppListShelfItemDelegate::AppListShelfItemDelegate() { |
16 LauncherItem app_list; | 18 LauncherItem app_list; |
17 app_list.type = TYPE_APP_LIST; | 19 app_list.type = TYPE_APP_LIST; |
18 Shell::GetInstance()->launcher_model()->Add(app_list); | 20 Shell::GetInstance()->launcher_model()->Add(app_list); |
| 21 |
| 22 ash::Shell::GetInstance()->launcher_item_delegate_manager()-> |
| 23 RegisterLauncherItemDelegate(ash::TYPE_APP_LIST, this); |
19 } | 24 } |
20 | 25 |
21 AppListShelfItemDelegate::~AppListShelfItemDelegate() { | 26 AppListShelfItemDelegate::~AppListShelfItemDelegate() { |
22 // LauncherItemDelegateManager owns and destroys this class. | 27 // Don't unregister this from LauncherItemDelegateManager. |
| 28 // LauncherItemDelegateManager is already destroyed. |
23 } | 29 } |
24 | 30 |
25 void AppListShelfItemDelegate::ItemSelected(const ui::Event& event) { | 31 void AppListShelfItemDelegate::ItemSelected(const LauncherItem& item, |
| 32 const ui::Event& event) { |
26 // Pass NULL here to show the app list in the currently active RootWindow. | 33 // Pass NULL here to show the app list in the currently active RootWindow. |
27 Shell::GetInstance()->ToggleAppList(NULL); | 34 Shell::GetInstance()->ToggleAppList(NULL); |
28 } | 35 } |
29 | 36 |
30 base::string16 AppListShelfItemDelegate::GetTitle() { | 37 base::string16 AppListShelfItemDelegate::GetTitle(const LauncherItem& item) { |
31 LauncherModel* model = Shell::GetInstance()->launcher_model(); | 38 LauncherModel* model = Shell::GetInstance()->launcher_model(); |
32 DCHECK(model); | 39 DCHECK(model); |
33 return model->status() == LauncherModel::STATUS_LOADING ? | 40 return model->status() == LauncherModel::STATUS_LOADING ? |
34 l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_SYNCING_TITLE) : | 41 l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_SYNCING_TITLE) : |
35 l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE); | 42 l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE); |
36 } | 43 } |
37 | 44 |
38 ui::MenuModel* AppListShelfItemDelegate::CreateContextMenu( | 45 ui::MenuModel* AppListShelfItemDelegate::CreateContextMenu( |
| 46 const LauncherItem& item, |
39 aura::RootWindow* root_window) { | 47 aura::RootWindow* root_window) { |
40 return NULL; | 48 return NULL; |
41 } | 49 } |
42 | 50 |
43 LauncherMenuModel* AppListShelfItemDelegate::CreateApplicationMenu( | 51 LauncherMenuModel* AppListShelfItemDelegate::CreateApplicationMenu( |
| 52 const LauncherItem& item, |
44 int event_flags) { | 53 int event_flags) { |
45 // AppList does not show an application menu. | 54 // AppList does not show an application menu. |
46 return NULL; | 55 return NULL; |
47 } | 56 } |
48 | 57 |
49 bool AppListShelfItemDelegate::IsDraggable() { | 58 bool AppListShelfItemDelegate::IsDraggable(const LauncherItem& item) { |
50 return false; | 59 return false; |
51 } | 60 } |
52 | 61 |
53 bool AppListShelfItemDelegate::ShouldShowTooltip() { | 62 bool AppListShelfItemDelegate::ShouldShowTooltip(const LauncherItem& item) { |
54 return true; | 63 return true; |
55 } | 64 } |
56 | 65 |
57 } // namespace internal | 66 } // namespace internal |
58 } // namespace ash | 67 } // namespace ash |
OLD | NEW |