| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/shelf/shelf_window_watcher_item_delegate.h" | 5 #include "ash/shelf/shelf_window_watcher_item_delegate.h" |
| 6 | 6 |
| 7 #include "ash/common/wm/window_state.h" | 7 #include "ash/common/wm/window_state.h" |
| 8 #include "ash/common/wm_window.h" |
| 8 #include "ash/shelf/shelf_util.h" | 9 #include "ash/shelf/shelf_util.h" |
| 9 #include "ash/shell.h" | 10 #include "ui/events/event.h" |
| 10 #include "ash/wm/window_state_aura.h" | |
| 11 #include "ui/aura/window.h" | |
| 12 #include "ui/views/widget/widget.h" | |
| 13 #include "ui/wm/core/window_animations.h" | 11 #include "ui/wm/core/window_animations.h" |
| 14 | 12 |
| 15 namespace ash { | 13 namespace ash { |
| 16 | 14 |
| 17 ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate( | 15 ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(WmWindow* window) |
| 18 aura::Window* window) | |
| 19 : window_(window) {} | 16 : window_(window) {} |
| 20 | 17 |
| 21 ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() {} | 18 ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() {} |
| 22 | 19 |
| 23 void ShelfWindowWatcherItemDelegate::Close() { | |
| 24 views::Widget::GetWidgetForNativeWindow(window_)->Close(); | |
| 25 } | |
| 26 | |
| 27 ShelfItemDelegate::PerformedAction ShelfWindowWatcherItemDelegate::ItemSelected( | 20 ShelfItemDelegate::PerformedAction ShelfWindowWatcherItemDelegate::ItemSelected( |
| 28 const ui::Event& event) { | 21 const ui::Event& event) { |
| 29 wm::WindowState* window_state = wm::GetWindowState(window_); | 22 wm::WindowState* window_state = window_->GetWindowState(); |
| 30 if (window_state->IsActive()) { | 23 if (window_state->IsActive()) { |
| 31 if (event.type() & ui::ET_KEY_RELEASED) { | 24 if (event.type() & ui::ET_KEY_RELEASED) { |
| 32 ::wm::AnimateWindow(window_, ::wm::WINDOW_ANIMATION_TYPE_BOUNCE); | 25 window_->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE); |
| 33 return kNoAction; | 26 return kNoAction; |
| 34 } else { | 27 } else { |
| 35 window_state->Minimize(); | 28 window_state->Minimize(); |
| 36 return kExistingWindowMinimized; | 29 return kExistingWindowMinimized; |
| 37 } | 30 } |
| 38 } else { | 31 } else { |
| 39 window_state->Activate(); | 32 window_state->Activate(); |
| 40 return kExistingWindowActivated; | 33 return kExistingWindowActivated; |
| 41 } | 34 } |
| 42 } | 35 } |
| 43 | 36 |
| 44 base::string16 ShelfWindowWatcherItemDelegate::GetTitle() { | 37 base::string16 ShelfWindowWatcherItemDelegate::GetTitle() { |
| 45 return GetShelfItemDetailsForWindow(window_)->title; | 38 return window_->GetShelfItemDetails()->title; |
| 46 } | 39 } |
| 47 | 40 |
| 48 ShelfMenuModel* ShelfWindowWatcherItemDelegate::CreateApplicationMenu( | 41 ShelfMenuModel* ShelfWindowWatcherItemDelegate::CreateApplicationMenu( |
| 49 int event_flags) { | 42 int event_flags) { |
| 50 return nullptr; | 43 return nullptr; |
| 51 } | 44 } |
| 52 | 45 |
| 53 bool ShelfWindowWatcherItemDelegate::IsDraggable() { | 46 bool ShelfWindowWatcherItemDelegate::IsDraggable() { |
| 54 return true; | 47 return true; |
| 55 } | 48 } |
| 56 | 49 |
| 57 bool ShelfWindowWatcherItemDelegate::CanPin() const { | 50 bool ShelfWindowWatcherItemDelegate::CanPin() const { |
| 58 return true; | 51 return true; |
| 59 } | 52 } |
| 60 | 53 |
| 61 bool ShelfWindowWatcherItemDelegate::ShouldShowTooltip() { | 54 bool ShelfWindowWatcherItemDelegate::ShouldShowTooltip() { |
| 62 return true; | 55 return true; |
| 63 } | 56 } |
| 64 | 57 |
| 58 void ShelfWindowWatcherItemDelegate::Close() { |
| 59 window_->CloseWidget(); |
| 60 } |
| 61 |
| 65 } // namespace ash | 62 } // namespace ash |
| OLD | NEW |