OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ | 5 #ifndef ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ |
6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ | 6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ |
7 | 7 |
8 #include "ash/accelerometer/accelerometer_observer.h" | 8 #include "ash/accelerometer/accelerometer_observer.h" |
9 #include "ash/ash_export.h" | 9 #include "ash/ash_export.h" |
10 #include "ash/display/display_manager.h" | |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "ui/message_center/message_center.h" | |
12 | 14 |
13 namespace ash { | 15 namespace ash { |
14 | 16 |
15 class MaximizeModeEventBlocker; | 17 class MaximizeModeEventBlocker; |
16 | 18 |
17 // MaximizeModeController listens to accelerometer events and automatically | 19 // MaximizeModeController listens to accelerometer events and automatically |
18 // enters and exits maximize mode when the lid is opened beyond the triggering | 20 // 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. | 21 // angle and rotates the display to match the device when in maximize mode. |
20 class ASH_EXPORT MaximizeModeController : public AccelerometerObserver { | 22 class ASH_EXPORT MaximizeModeController |
23 : public message_center::NotificationBlocker, | |
24 public AccelerometerObserver { | |
21 public: | 25 public: |
22 MaximizeModeController(); | 26 MaximizeModeController(); |
23 virtual ~MaximizeModeController(); | 27 virtual ~MaximizeModeController(); |
24 | 28 |
25 // True if |rotation_lock_| has been set, and OnAccelerometerUpdated will not | 29 // True if |rotation_lock_| has been set, and OnAccelerometerUpdated will not |
26 // change the display rotation. | 30 // change the display rotation. |
27 bool rotation_locked() { | 31 bool rotation_locked() { |
28 return rotation_locked_; | 32 return rotation_locked_; |
29 } | 33 } |
30 | 34 |
31 // If |rotation_locked| future calls to OnAccelerometerUpdated will not | 35 // If |rotation_locked| future calls to OnAccelerometerUpdated will not |
32 // change the display rotation. | 36 // change the display rotation. |
33 void set_rotation_locked(bool rotation_locked) { | 37 void set_rotation_locked(bool rotation_locked) { |
34 rotation_locked_ = rotation_locked; | 38 rotation_locked_ = rotation_locked; |
35 } | 39 } |
36 | 40 |
37 // AccelerometerObserver: | 41 // AccelerometerObserver: |
38 virtual void OnAccelerometerUpdated(const gfx::Vector3dF& base, | 42 virtual void OnAccelerometerUpdated(const gfx::Vector3dF& base, |
39 const gfx::Vector3dF& lid) OVERRIDE; | 43 const gfx::Vector3dF& lid) OVERRIDE; |
40 | 44 |
45 // message_center::NotificationBlocker: | |
46 virtual bool ShouldShowNotificationAsPopup( | |
47 const message_center::NotifierId& notifier_id) const OVERRIDE; | |
48 virtual bool ShouldShowNotification( | |
49 const message_center::NotifierId& notifier_id) const OVERRIDE; | |
jonross
2014/05/09 14:57:33
Nit: empty line after a function and a new scope d
bruthig
2014/05/14 00:36:16
Done.
| |
41 private: | 50 private: |
42 // Detect hinge rotation from |base| and |lid| accelerometers and | 51 // Detect hinge rotation from |base| and |lid| accelerometers and |
43 // automatically start / stop maximize mode. | 52 // automatically start / stop maximize mode. |
44 void HandleHingeRotation(const gfx::Vector3dF& base, | 53 void HandleHingeRotation(const gfx::Vector3dF& base, |
45 const gfx::Vector3dF& lid); | 54 const gfx::Vector3dF& lid); |
46 | 55 |
47 // Detect screen rotation from |lid| accelerometer and automatically rotate | 56 // Detect screen rotation from |lid| accelerometer and automatically rotate |
48 // screen. | 57 // screen. |
49 void HandleScreenRotation(const gfx::Vector3dF& lid); | 58 void HandleScreenRotation(const gfx::Vector3dF& lid); |
50 | 59 |
60 // Sets the display rotation and suppresses display notifications. | |
61 void SetDisplayRotation(DisplayManager* display_manager, | |
jonross
2014/05/09 14:57:33
Please forward declare DisplayManager
bruthig
2014/05/14 00:36:16
gfx::Display::Rotation also comes from display_man
| |
62 int64 display_id, | |
63 gfx::Display::Rotation rotation); | |
64 | |
65 // Set whether rotation notifications should be shown. | |
66 void set_show_notifications(bool should_show); | |
flackr
2014/05/08 21:56:15
non-trivial methods should use TitleCase. I.e. any
bruthig
2014/05/14 00:36:16
Done.
| |
67 | |
51 // Enables MaximizeModeWindowManager, and determines the current state of | 68 // Enables MaximizeModeWindowManager, and determines the current state of |
52 // rotation lock. | 69 // rotation lock. |
53 void EnterMaximizeMode(); | 70 void EnterMaximizeMode(); |
54 | 71 |
55 // Removes MaximizeModeWindowManager and resets the display rotation if there | 72 // Removes MaximizeModeWindowManager and resets the display rotation if there |
56 // is no rotation lock. | 73 // is no rotation lock. |
57 void LeaveMaximizeMode(); | 74 void LeaveMaximizeMode(); |
58 | 75 |
59 // An event handler which traps mouse and keyboard events while maximize | 76 // An event handler which traps mouse and keyboard events while maximize |
60 // mode is engaged. | 77 // mode is engaged. |
61 scoped_ptr<MaximizeModeEventBlocker> event_blocker_; | 78 scoped_ptr<MaximizeModeEventBlocker> event_blocker_; |
62 | 79 |
63 // When true calls to OnAccelerometerUpdated will not rotate the display. | 80 // When true calls to OnAccelerometerUpdated will not rotate the display. |
64 bool rotation_locked_; | 81 bool rotation_locked_; |
65 | 82 |
83 // When true will display notifications. Use set_show_notifications to | |
84 // change the value. | |
85 bool show_notifications_; | |
86 | |
66 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); | 87 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); |
67 }; | 88 }; |
68 | 89 |
69 } // namespace ash | 90 } // namespace ash |
70 | 91 |
71 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ | 92 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ |
OLD | NEW |