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 ShelfItemDelegate::PerformedAction
ShelfWindowWatcherItemDelegate::ItemSelected(
32 const ui::Event
& event
) {
33 wm::WindowState
* window_state
= wm::GetWindowState(window_
);
34 if (window_state
->IsActive()) {
35 if (event
.type() & ui::ET_KEY_RELEASED
) {
36 ::wm::AnimateWindow(window_
, ::wm::WINDOW_ANIMATION_TYPE_BOUNCE
);
39 window_state
->Minimize();
40 return kExistingWindowMinimized
;
43 window_state
->Activate();
44 return kExistingWindowActivated
;
48 base::string16
ShelfWindowWatcherItemDelegate::GetTitle() {
49 return GetShelfItemDetailsForWindow(window_
)->title
;
52 ui::MenuModel
* ShelfWindowWatcherItemDelegate::CreateContextMenu(
53 aura::Window
* root_window
) {
54 ash::ShelfItem item
= *(model_
->ItemByID(GetShelfIDForWindow(window_
)));
55 return Shell::GetInstance()->delegate()->CreateContextMenu(root_window
,
60 ShelfMenuModel
* ShelfWindowWatcherItemDelegate::CreateApplicationMenu(
65 bool ShelfWindowWatcherItemDelegate::IsDraggable() {
69 bool ShelfWindowWatcherItemDelegate::ShouldShowTooltip() {