Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ash / shelf / app_list_shelf_item_delegate.cc
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/shelf/shelf_model.h"
8 #include "ash/shell.h"
9 #include "ash/shell_delegate.h"
10 #include "grit/ash_strings.h"
11 #include "ui/base/l10n/l10n_util.h"
12
13 namespace ash {
14 namespace internal {
15
16 AppListShelfItemDelegate::AppListShelfItemDelegate() {
17   ShelfItem app_list;
18   app_list.type = TYPE_APP_LIST;
19   Shell::GetInstance()->shelf_model()->Add(app_list);
20 }
21
22 AppListShelfItemDelegate::~AppListShelfItemDelegate() {
23   // ShelfItemDelegateManager owns and destroys this class.
24 }
25
26 bool AppListShelfItemDelegate::ItemSelected(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 false;
30 }
31
32 base::string16 AppListShelfItemDelegate::GetTitle() {
33   ShelfModel* model = Shell::GetInstance()->shelf_model();
34   DCHECK(model);
35   return model->status() == ShelfModel::STATUS_LOADING ?
36       l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_SYNCING_TITLE) :
37       l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE);
38 }
39
40 ui::MenuModel* AppListShelfItemDelegate::CreateContextMenu(
41     aura::Window* root_window) {
42   return Shell::GetInstance()->delegate()->CreateContextMenu(root_window,
43                                                              NULL,
44                                                              NULL);
45 }
46
47 ShelfMenuModel* AppListShelfItemDelegate::CreateApplicationMenu(
48     int event_flags) {
49   // AppList does not show an application menu.
50   return NULL;
51 }
52
53 bool AppListShelfItemDelegate::IsDraggable() {
54   return false;
55 }
56
57 bool AppListShelfItemDelegate::ShouldShowTooltip() {
58   return true;
59 }
60
61 void AppListShelfItemDelegate::Close() {
62 }
63
64 }  // namespace internal
65 }  // namespace ash