Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: ash/shelf/app_list_shelf_item_delegate.cc

Issue 23606016: Refactor LauncherItemController and LauncherItemDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix for unittest.. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/shelf/app_list_shelf_item_delegate.h ('k') | ash/shell.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
8 #include "ash/launcher/launcher_model.h" 7 #include "ash/launcher/launcher_model.h"
9 #include "ash/shell.h" 8 #include "ash/shell.h"
10 #include "ash/shell_delegate.h"
11 #include "grit/ash_strings.h" 9 #include "grit/ash_strings.h"
12 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
13 11
14 namespace ash { 12 namespace ash {
15 namespace internal { 13 namespace internal {
16 14
17 AppListShelfItemDelegate::AppListShelfItemDelegate() { 15 AppListShelfItemDelegate::AppListShelfItemDelegate() {
18 LauncherItem app_list; 16 LauncherItem app_list;
19 app_list.type = TYPE_APP_LIST; 17 app_list.type = TYPE_APP_LIST;
20 Shell::GetInstance()->launcher_model()->Add(app_list); 18 Shell::GetInstance()->launcher_model()->Add(app_list);
21
22 ash::Shell::GetInstance()->launcher_item_delegate_manager()->
23 RegisterLauncherItemDelegate(ash::TYPE_APP_LIST, this);
24 } 19 }
25 20
26 AppListShelfItemDelegate::~AppListShelfItemDelegate() { 21 AppListShelfItemDelegate::~AppListShelfItemDelegate() {
27 // Don't unregister this from LauncherItemDelegateManager. 22 // LauncherItemDelegateManager owns and destroys this class.
28 // LauncherItemDelegateManager is already destroyed.
29 } 23 }
30 24
31 void AppListShelfItemDelegate::ItemSelected(const LauncherItem& item, 25 void AppListShelfItemDelegate::ItemSelected(const ui::Event& event) {
32 const ui::Event& event) {
33 // Pass NULL here to show the app list in the currently active RootWindow. 26 // Pass NULL here to show the app list in the currently active RootWindow.
34 Shell::GetInstance()->ToggleAppList(NULL); 27 Shell::GetInstance()->ToggleAppList(NULL);
35 } 28 }
36 29
37 base::string16 AppListShelfItemDelegate::GetTitle(const LauncherItem& item) { 30 base::string16 AppListShelfItemDelegate::GetTitle() {
38 LauncherModel* model = Shell::GetInstance()->launcher_model(); 31 LauncherModel* model = Shell::GetInstance()->launcher_model();
39 DCHECK(model); 32 DCHECK(model);
40 return model->status() == LauncherModel::STATUS_LOADING ? 33 return model->status() == LauncherModel::STATUS_LOADING ?
41 l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_SYNCING_TITLE) : 34 l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_SYNCING_TITLE) :
42 l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE); 35 l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE);
43 } 36 }
44 37
45 ui::MenuModel* AppListShelfItemDelegate::CreateContextMenu( 38 ui::MenuModel* AppListShelfItemDelegate::CreateContextMenu(
46 const LauncherItem& item,
47 aura::RootWindow* root_window) { 39 aura::RootWindow* root_window) {
48 return NULL; 40 return NULL;
49 } 41 }
50 42
51 LauncherMenuModel* AppListShelfItemDelegate::CreateApplicationMenu( 43 LauncherMenuModel* AppListShelfItemDelegate::CreateApplicationMenu(
52 const LauncherItem& item,
53 int event_flags) { 44 int event_flags) {
54 // AppList does not show an application menu. 45 // AppList does not show an application menu.
55 return NULL; 46 return NULL;
56 } 47 }
57 48
58 bool AppListShelfItemDelegate::IsDraggable(const LauncherItem& item) { 49 bool AppListShelfItemDelegate::IsDraggable() {
59 return false; 50 return false;
60 } 51 }
61 52
62 bool AppListShelfItemDelegate::ShouldShowTooltip(const LauncherItem& item) { 53 bool AppListShelfItemDelegate::ShouldShowTooltip() {
63 return true; 54 return true;
64 } 55 }
65 56
66 } // namespace internal 57 } // namespace internal
67 } // namespace ash 58 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/app_list_shelf_item_delegate.h ('k') | ash/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698