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

Side by Side Diff: ash/launcher/app_list_launcher_item_delegate.cc

Issue 23606016: Refactor LauncherItemController and LauncherItemDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for LauncherTest and observing LauncherModel in DelegateManager Created 7 years, 3 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
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/launcher/app_list_launcher_item_delegate.h" 5 #include "ash/launcher/app_list_launcher_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 AppListLauncherItemDelegate::AppListLauncherItemDelegate() { 15 AppListLauncherItemDelegate::AppListLauncherItemDelegate() {
18 // TODO(simon.hong81): This works for the moment, but the AppList LauncherItem 16 // TODO(simon.hong81): This works for the moment, but the AppList LauncherItem
19 // creation should move here. 17 // creation should move here.
20 ash::Shell::GetInstance()->launcher_item_delegate_manager()->
21 RegisterLauncherItemDelegate(ash::TYPE_APP_LIST, this);
22 } 18 }
23 19
24 AppListLauncherItemDelegate::~AppListLauncherItemDelegate() { 20 AppListLauncherItemDelegate::~AppListLauncherItemDelegate() {
25 // Don't unregister this from LauncherItemDelegateManager. 21 // LauncerItemDelegateManager owns and destroys this class.
26 // LauncherItemDelegateManager is already destroyed.
27 } 22 }
28 23
29 void AppListLauncherItemDelegate::ItemSelected(const LauncherItem& item, 24 void AppListLauncherItemDelegate::ItemSelected(const ui::Event& event) {
30 const ui::Event& event) {
31 // Pass NULL here to show the app list in the currently active RootWindow. 25 // Pass NULL here to show the app list in the currently active RootWindow.
32 Shell::GetInstance()->ToggleAppList(NULL); 26 Shell::GetInstance()->ToggleAppList(NULL);
33 } 27 }
34 28
35 base::string16 AppListLauncherItemDelegate::GetTitle(const LauncherItem& item) { 29 base::string16 AppListLauncherItemDelegate::GetTitle() {
36 LauncherModel* model = Shell::GetInstance()->launcher_model(); 30 LauncherModel* model = Shell::GetInstance()->launcher_model();
37 DCHECK(model); 31 DCHECK(model);
38 return model->status() == LauncherModel::STATUS_LOADING ? 32 return model->status() == LauncherModel::STATUS_LOADING ?
39 l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_SYNCING_TITLE) : 33 l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_SYNCING_TITLE) :
40 l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE); 34 l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE);
41 } 35 }
42 36
43 ui::MenuModel* AppListLauncherItemDelegate::CreateContextMenu( 37 ui::MenuModel* AppListLauncherItemDelegate::CreateContextMenu(
44 const LauncherItem& item,
45 aura::RootWindow* root_window) { 38 aura::RootWindow* root_window) {
46 return NULL; 39 return NULL;
47 } 40 }
48 41
49 LauncherMenuModel* AppListLauncherItemDelegate::CreateApplicationMenu( 42 LauncherMenuModel* AppListLauncherItemDelegate::CreateApplicationMenu(
50 const LauncherItem& item,
51 int event_flags) { 43 int event_flags) {
52 // AppList does not show an application menu. 44 // AppList does not show an application menu.
53 return NULL; 45 return NULL;
54 } 46 }
55 47
56 bool AppListLauncherItemDelegate::IsDraggable(const LauncherItem& item) { 48 bool AppListLauncherItemDelegate::IsDraggable() {
57 return false; 49 return false;
58 } 50 }
59 51
60 bool AppListLauncherItemDelegate::ShouldShowTooltip(const LauncherItem& item) { 52 bool AppListLauncherItemDelegate::ShouldShowTooltip() {
61 return true; 53 return true;
62 } 54 }
63 55
64 } // namespace internal 56 } // namespace internal
65 } // namespace ash 57 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698