Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: ash/shelf/shelf_window_watcher_item_delegate.cc

Issue 2192553002: mash: Convert ShelfWindowWatcher to wm common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits and better test Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
OLDNEW
« no previous file with comments | « ash/shelf/shelf_window_watcher_item_delegate.h ('k') | ash/shelf/shelf_window_watcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698