- add sources.
[platform/framework/web/crosswalk.git] / src / ash / wm / system_gesture_event_filter.h
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.
4
5 #ifndef ASH_WM_SYSTEM_GESTURE_EVENT_FILTER_H_
6 #define ASH_WM_SYSTEM_GESTURE_EVENT_FILTER_H_
7
8 #include "ash/shell.h"
9 #include "ash/touch/touch_uma.h"
10 #include "base/timer/timer.h"
11 #include "ui/aura/window_observer.h"
12 #include "ui/events/event_handler.h"
13 #include "ui/gfx/point.h"
14
15 #include <map>
16
17 namespace aura {
18 class Window;
19 }
20
21 namespace ui {
22 class LocatedEvent;
23 }
24
25 namespace ash {
26
27 namespace test {
28 class SystemGestureEventFilterTest;
29 }
30
31 namespace internal {
32 class LongPressAffordanceHandler;
33 class OverviewGestureHandler;
34 class SystemPinchHandler;
35 class TouchUMA;
36 class TwoFingerDragHandler;
37
38 // An event filter which handles system level gesture events.
39 class SystemGestureEventFilter : public ui::EventHandler,
40                                  public aura::WindowObserver {
41  public:
42   SystemGestureEventFilter();
43   virtual ~SystemGestureEventFilter();
44
45   // Overridden from ui::EventHandler:
46   virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
47   virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
48   virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
49   virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
50
51   // Overridden from aura::WindowObserver.
52   virtual void OnWindowVisibilityChanged(aura::Window* window,
53                                          bool visible) OVERRIDE;
54   virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
55
56  private:
57   friend class ash::test::SystemGestureEventFilterTest;
58
59   // Removes system-gesture handlers for a window.
60   void ClearGestureHandlerForWindow(aura::Window* window);
61
62   typedef std::map<aura::Window*, SystemPinchHandler*> WindowPinchHandlerMap;
63   // Created on demand when a system-level pinch gesture is initiated. Destroyed
64   // when the system-level pinch gesture ends for the window.
65   WindowPinchHandlerMap pinch_handlers_;
66
67   bool system_gestures_enabled_;
68
69   scoped_ptr<LongPressAffordanceHandler> long_press_affordance_;
70   scoped_ptr<OverviewGestureHandler> overview_gesture_handler_;
71   scoped_ptr<TwoFingerDragHandler> two_finger_drag_;
72
73   DISALLOW_COPY_AND_ASSIGN(SystemGestureEventFilter);
74 };
75
76 }  // namespace internal
77 }  // namespace ash
78
79 #endif  // ASH_WM_SYSTEM_GESTURE_EVENT_FILTER_H_