Only fsync leveldb's directory when the manifest is being updated.
[chromium-blink-merge.git] / ash / wm / gestures / shelf_gesture_handler.cc
blob2d3e9b99a5e40de57ab66e85594fea98c70a3698
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_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/gestures/tray_gesture_handler.h"
15 #include "ash/wm/window_properties.h"
16 #include "ash/wm/window_util.h"
17 #include "ui/aura/window.h"
18 #include "ui/compositor/layer.h"
19 #include "ui/compositor/scoped_layer_animation_settings.h"
20 #include "ui/gfx/transform.h"
21 #include "ui/views/widget/widget.h"
23 namespace ash {
24 namespace internal {
26 ShelfGestureHandler::ShelfGestureHandler()
27 : drag_in_progress_(false) {
30 ShelfGestureHandler::~ShelfGestureHandler() {
33 bool ShelfGestureHandler::ProcessGestureEvent(const ui::GestureEvent& event) {
34 Shell* shell = Shell::GetInstance();
35 if (!shell->session_state_delegate()->NumberOfLoggedInUsers() ||
36 shell->session_state_delegate()->IsScreenLocked()) {
37 // The gestures are disabled in the lock/login screen.
38 return false;
41 // TODO(oshima): Find the root window controller from event's location.
42 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
44 ShelfLayoutManager* shelf = controller->GetShelfLayoutManager();
46 // The gesture are disabled for fullscreen windows that are not in immersive
47 // mode.
48 aura::Window* fullscreen = controller->GetFullscreenWindow();
49 if (fullscreen && !shelf->FullscreenWithMinimalChrome())
50 return false;
52 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) {
53 drag_in_progress_ = true;
54 shelf->StartGestureDrag(event);
55 return true;
58 if (!drag_in_progress_)
59 return false;
61 if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE) {
62 if (tray_handler_) {
63 if (!tray_handler_->UpdateGestureDrag(event))
64 tray_handler_.reset();
65 } else if (shelf->UpdateGestureDrag(event) ==
66 ShelfLayoutManager::DRAG_TRAY) {
67 tray_handler_.reset(new TrayGestureHandler());
70 return true;
73 drag_in_progress_ = false;
75 if (event.type() == ui::ET_GESTURE_SCROLL_END ||
76 event.type() == ui::ET_SCROLL_FLING_START) {
77 if (tray_handler_) {
78 tray_handler_->CompleteGestureDrag(event);
79 tray_handler_.reset();
82 shelf->CompleteGestureDrag(event);
83 return true;
86 // Unexpected event. Reset the state and let the event fall through.
87 shelf->CancelGestureDrag();
88 return false;
91 } // namespace internal
92 } // namespace ash