| 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/common/shelf/shelf_window_watcher_item_delegate.h" | 5 #include "ash/common/shelf/shelf_window_watcher_item_delegate.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/shelf_item_types.h" | |
| 8 #include "ash/common/wm/window_state.h" | |
| 9 #include "ash/common/wm_window.h" | 7 #include "ash/common/wm_window.h" |
| 10 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
| 11 | 9 |
| 12 namespace ash { | 10 namespace ash { |
| 13 | 11 |
| 14 ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(WmWindow* window) | 12 ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(WmWindow* window) |
| 15 : window_(window) {} | 13 : window_(window) {} |
| 16 | 14 |
| 17 ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() {} | 15 ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() {} |
| 18 | 16 |
| 19 ShelfItemDelegate::PerformedAction ShelfWindowWatcherItemDelegate::ItemSelected( | 17 ShelfItemDelegate::PerformedAction ShelfWindowWatcherItemDelegate::ItemSelected( |
| 20 const ui::Event& event) { | 18 const ui::Event& event) { |
| 21 wm::WindowState* window_state = window_->GetWindowState(); | 19 if (window_->IsActive()) { |
| 22 if (window_state->IsActive()) { | |
| 23 if (event.type() & ui::ET_KEY_RELEASED) { | 20 if (event.type() & ui::ET_KEY_RELEASED) { |
| 24 window_->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE); | 21 window_->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE); |
| 25 return kNoAction; | 22 return kNoAction; |
| 26 } else { | |
| 27 window_state->Minimize(); | |
| 28 return kExistingWindowMinimized; | |
| 29 } | 23 } |
| 30 } else { | 24 window_->Minimize(); |
| 31 window_state->Activate(); | 25 return kExistingWindowMinimized; |
| 32 return kExistingWindowActivated; | |
| 33 } | 26 } |
| 27 window_->Activate(); |
| 28 return kExistingWindowActivated; |
| 34 } | 29 } |
| 35 | 30 |
| 36 base::string16 ShelfWindowWatcherItemDelegate::GetTitle() { | 31 base::string16 ShelfWindowWatcherItemDelegate::GetTitle() { |
| 37 return window_->GetShelfItemDetails()->title; | 32 return window_->GetTitle(); |
| 38 } | 33 } |
| 39 | 34 |
| 40 ShelfMenuModel* ShelfWindowWatcherItemDelegate::CreateApplicationMenu( | 35 ShelfMenuModel* ShelfWindowWatcherItemDelegate::CreateApplicationMenu( |
| 41 int event_flags) { | 36 int event_flags) { |
| 42 return nullptr; | 37 return nullptr; |
| 43 } | 38 } |
| 44 | 39 |
| 45 bool ShelfWindowWatcherItemDelegate::IsDraggable() { | 40 bool ShelfWindowWatcherItemDelegate::IsDraggable() { |
| 46 return true; | 41 return true; |
| 47 } | 42 } |
| 48 | 43 |
| 49 bool ShelfWindowWatcherItemDelegate::CanPin() const { | 44 bool ShelfWindowWatcherItemDelegate::CanPin() const { |
| 50 return true; | 45 return true; |
| 51 } | 46 } |
| 52 | 47 |
| 53 bool ShelfWindowWatcherItemDelegate::ShouldShowTooltip() { | 48 bool ShelfWindowWatcherItemDelegate::ShouldShowTooltip() { |
| 54 return true; | 49 return true; |
| 55 } | 50 } |
| 56 | 51 |
| 57 void ShelfWindowWatcherItemDelegate::Close() { | 52 void ShelfWindowWatcherItemDelegate::Close() { |
| 58 window_->CloseWidget(); | 53 window_->CloseWidget(); |
| 59 } | 54 } |
| 60 | 55 |
| 61 } // namespace ash | 56 } // namespace ash |
| OLD | NEW |