Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: ash/wm/maximize_mode/maximize_mode_controller.h

Issue 308683002: Move MaximizeModeWindowManager to the controller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "ash/display/display_manager.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "ui/gfx/display.h" 13 #include "ui/gfx/display.h"
14 14
15 namespace ui { 15 namespace ui {
16 class EventHandler; 16 class EventHandler;
17 } 17 }
18 18
19 namespace ash { 19 namespace ash {
20 20
21 class MaximizeModeControllerTest; 21 class MaximizeModeControllerTest;
22 class MaximizeModeEventBlocker; 22 class MaximizeModeEventBlocker;
23 class MaximizeModeWindowManager;
24 class MaximizeModeWindowManagerTest;
23 25
24 // MaximizeModeController listens to accelerometer events and automatically 26 // MaximizeModeController listens to accelerometer events and automatically
25 // enters and exits maximize mode when the lid is opened beyond the triggering 27 // enters and exits maximize mode when the lid is opened beyond the triggering
26 // angle and rotates the display to match the device when in maximize mode. 28 // angle and rotates the display to match the device when in maximize mode.
27 class ASH_EXPORT MaximizeModeController : public AccelerometerObserver { 29 class ASH_EXPORT MaximizeModeController : public AccelerometerObserver {
28 public: 30 public:
29 MaximizeModeController(); 31 MaximizeModeController();
30 virtual ~MaximizeModeController(); 32 virtual ~MaximizeModeController();
31 33
32 bool in_set_screen_rotation() const { 34 bool in_set_screen_rotation() const {
(...skipping 10 matching lines...) Expand all
43 // change the display rotation. 45 // change the display rotation.
44 void set_rotation_locked(bool rotation_locked) { 46 void set_rotation_locked(bool rotation_locked) {
45 rotation_locked_ = rotation_locked; 47 rotation_locked_ = rotation_locked;
46 } 48 }
47 49
48 // True if it is possible to enter maximize mode in the current 50 // True if it is possible to enter maximize mode in the current
49 // configuration. If this returns false, it should never be the case that 51 // configuration. If this returns false, it should never be the case that
50 // maximize mode becomes enabled. 52 // maximize mode becomes enabled.
51 bool CanEnterMaximizeMode(); 53 bool CanEnterMaximizeMode();
52 54
55 // TODO(jonross): Merge this with EnterMaximizeMode. Currently these are
56 // separate for several reasons: there is no internal display when running
oshima 2014/05/29 22:44:45 You can enable internal display for test using gf
jonross 2014/05/30 14:37:50 We found then also want to add that to where accel
57 // unittests; the event blocker prevents keyboard input when running ChromeOS
58 // on linux. http://crbug.com/362881
59 // Turn the always maximize mode window manager on or off.
60 void EnableMaximizeModeWindowManager(bool enable);
61
62 // Test if the MaximizeModeWindowManager is enabled or not.
63 bool IsMaximizeModeWindowManagerEnabled() const;
64
65 // Shutdowns down the MaximizeModeWindowManager and notifies all observers.
Mr4D (OOO till 08-26) 2014/05/29 22:15:24 Could you add a note here towards why you do not c
jonross 2014/05/30 14:37:50 Done. I'll upload on the next patch, once we deci
66 void Shutdown();
67
53 // AccelerometerObserver: 68 // AccelerometerObserver:
54 virtual void OnAccelerometerUpdated(const gfx::Vector3dF& base, 69 virtual void OnAccelerometerUpdated(const gfx::Vector3dF& base,
55 const gfx::Vector3dF& lid) OVERRIDE; 70 const gfx::Vector3dF& lid) OVERRIDE;
56 71
57 private: 72 private:
58 friend class MaximizeModeControllerTest; 73 friend class MaximizeModeControllerTest;
74 friend class MaximizeModeWindowManagerTest;
59 75
60 // Detect hinge rotation from |base| and |lid| accelerometers and 76 // Detect hinge rotation from |base| and |lid| accelerometers and
61 // automatically start / stop maximize mode. 77 // automatically start / stop maximize mode.
62 void HandleHingeRotation(const gfx::Vector3dF& base, 78 void HandleHingeRotation(const gfx::Vector3dF& base,
63 const gfx::Vector3dF& lid); 79 const gfx::Vector3dF& lid);
64 80
65 // Detect screen rotation from |lid| accelerometer and automatically rotate 81 // Detect screen rotation from |lid| accelerometer and automatically rotate
66 // screen. 82 // screen.
67 void HandleScreenRotation(const gfx::Vector3dF& lid); 83 void HandleScreenRotation(const gfx::Vector3dF& lid);
68 84
69 // Sets the display rotation and suppresses display notifications. 85 // Sets the display rotation and suppresses display notifications.
70 void SetDisplayRotation(DisplayManager* display_manager, 86 void SetDisplayRotation(DisplayManager* display_manager,
71 gfx::Display::Rotation rotation); 87 gfx::Display::Rotation rotation);
72 88
73 // Enables MaximizeModeWindowManager, and determines the current state of 89 // Enables MaximizeModeWindowManager, and determines the current state of
74 // rotation lock. 90 // rotation lock.
75 void EnterMaximizeMode(); 91 void EnterMaximizeMode();
76 92
77 // Removes MaximizeModeWindowManager and resets the display rotation if there 93 // Removes MaximizeModeWindowManager and resets the display rotation if there
78 // is no rotation lock. 94 // is no rotation lock.
79 void LeaveMaximizeMode(); 95 void LeaveMaximizeMode();
80 96
97 // The maximized window manager (if enabled).
98 scoped_ptr<MaximizeModeWindowManager> maximize_mode_window_manager_;
99
81 // An event targeter controller which traps mouse and keyboard events while 100 // An event targeter controller which traps mouse and keyboard events while
82 // maximize mode is engaged. 101 // maximize mode is engaged.
83 scoped_ptr<MaximizeModeEventBlocker> event_blocker_; 102 scoped_ptr<MaximizeModeEventBlocker> event_blocker_;
84 103
85 // An event handler used to detect screenshot actions while in maximize mode. 104 // An event handler used to detect screenshot actions while in maximize mode.
86 scoped_ptr<ui::EventHandler> event_handler_; 105 scoped_ptr<ui::EventHandler> event_handler_;
87 106
88 // When true calls to OnAccelerometerUpdated will not rotate the display. 107 // When true calls to OnAccelerometerUpdated will not rotate the display.
89 bool rotation_locked_; 108 bool rotation_locked_;
90 109
91 // Whether we have ever seen accelerometer data. 110 // Whether we have ever seen accelerometer data.
92 bool have_seen_accelerometer_data_; 111 bool have_seen_accelerometer_data_;
93 112
94 // True when the screen's orientation is being changed. 113 // True when the screen's orientation is being changed.
95 bool in_set_screen_rotation_; 114 bool in_set_screen_rotation_;
96 115
97 // The rotation of the display set by the user. This rotation will be 116 // The rotation of the display set by the user. This rotation will be
98 // restored upon exiting maximize mode. 117 // restored upon exiting maximize mode.
99 gfx::Display::Rotation user_rotation_; 118 gfx::Display::Rotation user_rotation_;
100 119
101 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); 120 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController);
102 }; 121 };
103 122
104 } // namespace ash 123 } // namespace ash
105 124
106 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ 125 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698