summaryrefslogtreecommitdiffstats
path: root/ash/shelf/app_list_shelf_item_delegate.cc
blob: 7013d2be1f3dff6dd5a50a5e03bd794752a50d98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/shelf/app_list_shelf_item_delegate.h"

#include "ash/shelf/shelf_model.h"
#include "ash/shell.h"
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"

namespace ash {
namespace internal {

AppListShelfItemDelegate::AppListShelfItemDelegate() {
  LauncherItem app_list;
  app_list.type = TYPE_APP_LIST;
  Shell::GetInstance()->shelf_model()->Add(app_list);
}

AppListShelfItemDelegate::~AppListShelfItemDelegate() {
  // ShelfItemDelegateManager owns and destroys this class.
}

bool AppListShelfItemDelegate::ItemSelected(const ui::Event& event) {
  // Pass NULL here to show the app list in the currently active RootWindow.
  Shell::GetInstance()->ToggleAppList(NULL);
  return false;
}

base::string16 AppListShelfItemDelegate::GetTitle() {
  ShelfModel* model = Shell::GetInstance()->shelf_model();
  DCHECK(model);
  return model->status() == ShelfModel::STATUS_LOADING ?
      l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_SYNCING_TITLE) :
      l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE);
}

ui::MenuModel* AppListShelfItemDelegate::CreateContextMenu(
    aura::Window* root_window) {
  return NULL;
}

ShelfMenuModel* AppListShelfItemDelegate::CreateApplicationMenu(
    int event_flags) {
  // AppList does not show an application menu.
  return NULL;
}

bool AppListShelfItemDelegate::IsDraggable() {
  return false;
}

bool AppListShelfItemDelegate::ShouldShowTooltip() {
  return true;
}

}  // namespace internal
}  // namespace ash