Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / ash / shelf / shelf_window_watcher_item_delegate.cc
blob005d2d48169ec49354d5dd9ecfec0e9427a5eeb7
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"
9 #include "ash/shell.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"
16 namespace ash {
18 ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(
19 aura::Window* window, ShelfModel* model)
20 : window_(window),
21 model_(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);
36 } else {
37 window_state->Minimize();
39 } else {
40 window_state->Activate();
43 return false;
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,
54 this,
55 &item);
58 ShelfMenuModel* ShelfWindowWatcherItemDelegate::CreateApplicationMenu(
59 int event_flags) {
60 return NULL;
63 bool ShelfWindowWatcherItemDelegate::IsDraggable() {
64 return true;
67 bool ShelfWindowWatcherItemDelegate::ShouldShowTooltip() {
68 return true;
71 } // namespace ash