platformKeys: Add per-extension sign permissions.
[chromium-blink-merge.git] / ash / wm / gestures / shelf_gesture_handler.cc
blobeb485ad2d1890a342dac6a636da531272797b04b
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
3 // found in the LICENSE file.
5 #include "ash/wm/gestures/shelf_gesture_handler.h"
7 #include "ash/root_window_controller.h"
8 #include "ash/session/session_state_delegate.h"
9 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shelf/shelf_types.h"
11 #include "ash/shelf/shelf_widget.h"
12 #include "ash/shell.h"
13 #include "ash/system/status_area_widget.h"
14 #include "ash/wm/window_state.h"
15 #include "ash/wm/window_util.h"
16 #include "ui/aura/window.h"
17 #include "ui/compositor/layer.h"
18 #include "ui/compositor/scoped_layer_animation_settings.h"
19 #include "ui/gfx/transform.h"
20 #include "ui/views/widget/widget.h"
22 namespace ash {
24 ShelfGestureHandler::ShelfGestureHandler()
25 : drag_in_progress_(false) {
28 ShelfGestureHandler::~ShelfGestureHandler() {
31 bool ShelfGestureHandler::ProcessGestureEvent(const ui::GestureEvent& event) {
32 Shell* shell = Shell::GetInstance();
33 if (!shell->session_state_delegate()->NumberOfLoggedInUsers() ||
34 shell->session_state_delegate()->IsScreenLocked()) {
35 // The gestures are disabled in the lock/login screen.
36 return false;
39 // TODO(oshima): Find the root window controller from event's location.
40 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
42 ShelfLayoutManager* shelf = controller->GetShelfLayoutManager();
44 if (event.type() == ui::ET_GESTURE_WIN8_EDGE_SWIPE) {
45 shelf->OnGestureEdgeSwipe(event);
46 return true;
49 const aura::Window* fullscreen = controller->GetWindowForFullscreenMode();
50 if (fullscreen &&
51 ash::wm::GetWindowState(fullscreen)->hide_shelf_when_fullscreen()) {
52 return false;
55 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) {
56 drag_in_progress_ = true;
57 shelf->StartGestureDrag(event);
58 return true;
61 if (!drag_in_progress_)
62 return false;
64 if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE) {
65 shelf->UpdateGestureDrag(event);
66 return true;
69 drag_in_progress_ = false;
71 if (event.type() == ui::ET_GESTURE_SCROLL_END ||
72 event.type() == ui::ET_SCROLL_FLING_START) {
73 shelf->CompleteGestureDrag(event);
74 return true;
77 // Unexpected event. Reset the state and let the event fall through.
78 shelf->CancelGestureDrag();
79 return false;
82 } // namespace ash