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.
5 #include "ash/shelf/shelf_window_watcher_item_delegate.h"
7 #include "ash/shelf/shelf_model.h"
8 #include "ash/shelf/shelf_util.h"
10 #include "ash/shell_delegate.h"
11 #include "ash/wm/window_state.h"
12 #include "ui/aura/window.h"
13 #include "ui/views/widget/widget.h"
14 #include "ui/wm/core/window_animations.h"
18 ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(
19 aura::Window
* window
, ShelfModel
* model
)
24 ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() {
27 void ShelfWindowWatcherItemDelegate::Close() {
28 views::Widget::GetWidgetForNativeWindow(window_
)->Close();
31 bool ShelfWindowWatcherItemDelegate::ItemSelected(const ui::Event
& event
) {
32 wm::WindowState
* window_state
= wm::GetWindowState(window_
);
33 if (window_state
->IsActive()) {
34 if (event
.type() & ui::ET_KEY_RELEASED
) {
35 ::wm::AnimateWindow(window_
, ::wm::WINDOW_ANIMATION_TYPE_BOUNCE
);
37 window_state
->Minimize();
40 window_state
->Activate();
46 base::string16
ShelfWindowWatcherItemDelegate::GetTitle() {
47 return GetShelfItemDetailsForWindow(window_
)->title
;
50 ui::MenuModel
* ShelfWindowWatcherItemDelegate::CreateContextMenu(
51 aura::Window
* root_window
) {
52 ash::ShelfItem item
= *(model_
->ItemByID(GetShelfIDForWindow(window_
)));
53 return Shell::GetInstance()->delegate()->CreateContextMenu(root_window
,
58 ShelfMenuModel
* ShelfWindowWatcherItemDelegate::CreateApplicationMenu(
63 bool ShelfWindowWatcherItemDelegate::IsDraggable() {
67 bool ShelfWindowWatcherItemDelegate::ShouldShowTooltip() {