summaryrefslogtreecommitdiffstats
path: root/chromium/ash/shell/window_watcher_shelf_item_delegate.cc
blob: ecb4308c944db9b9b7f16f2858e7b3a7f668a170 (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
// 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/shell/window_watcher_shelf_item_delegate.h"

#include "ash/shell/window_watcher.h"
#include "ash/wm/window_util.h"
#include "ui/aura/window.h"

namespace ash {
namespace shell {

WindowWatcherShelfItemDelegate::WindowWatcherShelfItemDelegate(
    LauncherID id,
    WindowWatcher* watcher)
    : id_(id), watcher_(watcher) {
  DCHECK_GT(id_, 0);
  DCHECK(watcher_);
}

WindowWatcherShelfItemDelegate::~WindowWatcherShelfItemDelegate() {
}

bool WindowWatcherShelfItemDelegate::ItemSelected(const ui::Event& event) {
  aura::Window* window = watcher_->GetWindowByID(id_);
  if (window->type() == aura::client::WINDOW_TYPE_PANEL)
    wm::MoveWindowToEventRoot(window, event);
  window->Show();
  wm::ActivateWindow(window);
  return false;
}

base::string16 WindowWatcherShelfItemDelegate::GetTitle() {
  return watcher_->GetWindowByID(id_)->title();
}

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

ShelfMenuModel* WindowWatcherShelfItemDelegate::CreateApplicationMenu(
    int event_flags) {
  return NULL;
}

bool WindowWatcherShelfItemDelegate::IsDraggable() {
  return true;
}

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

}  // namespace shell
}  // namespace ash