Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ash / wm / maximize_mode / maximize_mode_controller.h
1 // Copyright 2014 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_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_
6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_
7
8 #include "ash/accelerometer/accelerometer_observer.h"
9 #include "ash/ash_export.h"
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12
13 namespace ash {
14
15 class MaximizeModeEventBlocker;
16
17 // MaximizeModeController listens to accelerometer events and automatically
18 // enters and exits maximize mode when the lid is opened beyond the triggering
19 // angle and rotates the display to match the device when in maximize mode.
20 class ASH_EXPORT MaximizeModeController : public AccelerometerObserver {
21  public:
22   MaximizeModeController();
23   virtual ~MaximizeModeController();
24
25   // True if |rotation_lock_| has been set, and OnAccelerometerUpdated will not
26   // change the display rotation.
27   bool rotation_locked() {
28     return rotation_locked_;
29   }
30
31   // If |rotation_locked| future calls to OnAccelerometerUpdated will not
32   // change the display rotation.
33   void set_rotation_locked(bool rotation_locked) {
34     rotation_locked_ = rotation_locked;
35   }
36
37   // AccelerometerObserver:
38   virtual void OnAccelerometerUpdated(const gfx::Vector3dF& base,
39                                       const gfx::Vector3dF& lid) OVERRIDE;
40
41  private:
42   // Detect hinge rotation from |base| and |lid| accelerometers and
43   // automatically start / stop maximize mode.
44   void HandleHingeRotation(const gfx::Vector3dF& base,
45                            const gfx::Vector3dF& lid);
46
47   // Detect screen rotation from |lid| accelerometer and automatically rotate
48   // screen.
49   void HandleScreenRotation(const gfx::Vector3dF& lid);
50
51   // An event handler which traps mouse and keyboard events while maximize
52   // mode is engaged.
53   scoped_ptr<MaximizeModeEventBlocker> event_blocker_;
54
55   // When true calls to OnAccelerometerUpdated will not rotate the display.
56   bool rotation_locked_;
57
58   DISALLOW_COPY_AND_ASSIGN(MaximizeModeController);
59 };
60
61 }  // namespace ash
62
63 #endif  // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_