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

Side by Side Diff: ash/wm/gestures/shelf_gesture_handler.cc

Issue 2111443002: mash: Migrate SessionStateDelegate access to WmShell. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix win compile warning; use static Shell::GetPrimaryRootWindowController. Created 4 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/wm/gestures/shelf_gesture_handler.h" 5 #include "ash/wm/gestures/shelf_gesture_handler.h"
6 6
7 #include "ash/common/session/session_state_delegate.h" 7 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/common/shelf/shelf_types.h" 8 #include "ash/common/shelf/shelf_types.h"
9 #include "ash/common/wm/window_state.h" 9 #include "ash/common/wm/window_state.h"
10 #include "ash/common/wm_shell.h"
10 #include "ash/root_window_controller.h" 11 #include "ash/root_window_controller.h"
11 #include "ash/shelf/shelf_layout_manager.h" 12 #include "ash/shelf/shelf_layout_manager.h"
12 #include "ash/shelf/shelf_widget.h" 13 #include "ash/shelf/shelf_widget.h"
13 #include "ash/shell.h"
14 #include "ash/system/status_area_widget.h" 14 #include "ash/system/status_area_widget.h"
15 #include "ash/wm/window_state_aura.h" 15 #include "ash/wm/window_state_aura.h"
16 #include "ash/wm/window_util.h" 16 #include "ash/wm/window_util.h"
17 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
18 #include "ui/compositor/layer.h" 18 #include "ui/compositor/layer.h"
19 #include "ui/compositor/scoped_layer_animation_settings.h" 19 #include "ui/compositor/scoped_layer_animation_settings.h"
20 #include "ui/gfx/transform.h" 20 #include "ui/gfx/transform.h"
21 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
22 22
23 namespace ash { 23 namespace ash {
24 24
25 ShelfGestureHandler::ShelfGestureHandler() : drag_in_progress_(false) {} 25 ShelfGestureHandler::ShelfGestureHandler() : drag_in_progress_(false) {}
26 26
27 ShelfGestureHandler::~ShelfGestureHandler() {} 27 ShelfGestureHandler::~ShelfGestureHandler() {}
28 28
29 bool ShelfGestureHandler::ProcessGestureEvent( 29 bool ShelfGestureHandler::ProcessGestureEvent(
30 const ui::GestureEvent& event, 30 const ui::GestureEvent& event,
31 const aura::Window* event_target_window) { 31 const aura::Window* event_target_window) {
32 Shell* shell = Shell::GetInstance(); 32 if (!WmShell::Get()->GetSessionStateDelegate()->NumberOfLoggedInUsers() ||
James Cook 2016/06/29 21:12:23 optional nit: Cache either WmShell* or Delegate* (
msw 2016/06/29 21:43:34 I often rely on compiler optimizations for such pe
33 if (!shell->session_state_delegate()->NumberOfLoggedInUsers() || 33 WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked()) {
34 shell->session_state_delegate()->IsScreenLocked()) {
35 // The gestures are disabled in the lock/login screen. 34 // The gestures are disabled in the lock/login screen.
36 return false; 35 return false;
37 } 36 }
38 37
39 RootWindowController* controller = 38 RootWindowController* controller =
40 RootWindowController::ForWindow(event_target_window); 39 RootWindowController::ForWindow(event_target_window);
41 ShelfLayoutManager* shelf = controller->GetShelfLayoutManager(); 40 ShelfLayoutManager* shelf = controller->GetShelfLayoutManager();
42 41
43 if (event.type() == ui::ET_GESTURE_WIN8_EDGE_SWIPE) { 42 if (event.type() == ui::ET_GESTURE_WIN8_EDGE_SWIPE) {
44 shelf->OnGestureEdgeSwipe(event); 43 shelf->OnGestureEdgeSwipe(event);
45 return true; 44 return true;
46 } 45 }
47 46
48 const aura::Window* fullscreen = controller->GetWindowForFullscreenMode(); 47 const aura::Window* fullscreen = controller->GetWindowForFullscreenMode();
49 if (fullscreen && 48 if (fullscreen &&
50 ash::wm::GetWindowState(fullscreen)->hide_shelf_when_fullscreen()) { 49 wm::GetWindowState(fullscreen)->hide_shelf_when_fullscreen()) {
51 return false; 50 return false;
52 } 51 }
53 52
54 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) { 53 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) {
55 drag_in_progress_ = true; 54 drag_in_progress_ = true;
56 shelf->StartGestureDrag(event); 55 shelf->StartGestureDrag(event);
57 return true; 56 return true;
58 } 57 }
59 58
60 if (!drag_in_progress_) 59 if (!drag_in_progress_)
(...skipping 11 matching lines...) Expand all
72 shelf->CompleteGestureDrag(event); 71 shelf->CompleteGestureDrag(event);
73 return true; 72 return true;
74 } 73 }
75 74
76 // Unexpected event. Reset the state and let the event fall through. 75 // Unexpected event. Reset the state and let the event fall through.
77 shelf->CancelGestureDrag(); 76 shelf->CancelGestureDrag();
78 return false; 77 return false;
79 } 78 }
80 79
81 } // namespace ash 80 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698