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

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: Rebase 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
« no previous file with comments | « ash/test/shell_test_api.cc ('k') | ash/wm/maximize_mode/maximize_mode_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
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 // TODO(jonross): move this into the destructor. Currently separated as
66 // ShellOberver notifies of maximize mode ending, and the observers end up
67 // attempting to access MaximizeModeController via the Shell. If done in
68 // destructor the controller is null, and the observers segfault.
69 // Shuts down down the MaximizeModeWindowManager and notifies all observers.
70 void Shutdown();
71
53 // AccelerometerObserver: 72 // AccelerometerObserver:
54 virtual void OnAccelerometerUpdated(const gfx::Vector3dF& base, 73 virtual void OnAccelerometerUpdated(const gfx::Vector3dF& base,
55 const gfx::Vector3dF& lid) OVERRIDE; 74 const gfx::Vector3dF& lid) OVERRIDE;
56 75
57 private: 76 private:
58 friend class MaximizeModeControllerTest; 77 friend class MaximizeModeControllerTest;
78 friend class MaximizeModeWindowManagerTest;
59 79
60 // Detect hinge rotation from |base| and |lid| accelerometers and 80 // Detect hinge rotation from |base| and |lid| accelerometers and
61 // automatically start / stop maximize mode. 81 // automatically start / stop maximize mode.
62 void HandleHingeRotation(const gfx::Vector3dF& base, 82 void HandleHingeRotation(const gfx::Vector3dF& base,
63 const gfx::Vector3dF& lid); 83 const gfx::Vector3dF& lid);
64 84
65 // Detect screen rotation from |lid| accelerometer and automatically rotate 85 // Detect screen rotation from |lid| accelerometer and automatically rotate
66 // screen. 86 // screen.
67 void HandleScreenRotation(const gfx::Vector3dF& lid); 87 void HandleScreenRotation(const gfx::Vector3dF& lid);
68 88
69 // Sets the display rotation and suppresses display notifications. 89 // Sets the display rotation and suppresses display notifications.
70 void SetDisplayRotation(DisplayManager* display_manager, 90 void SetDisplayRotation(DisplayManager* display_manager,
71 gfx::Display::Rotation rotation); 91 gfx::Display::Rotation rotation);
72 92
73 // Enables MaximizeModeWindowManager, and determines the current state of 93 // Enables MaximizeModeWindowManager, and determines the current state of
74 // rotation lock. 94 // rotation lock.
75 void EnterMaximizeMode(); 95 void EnterMaximizeMode();
76 96
77 // Removes MaximizeModeWindowManager and resets the display rotation if there 97 // Removes MaximizeModeWindowManager and resets the display rotation if there
78 // is no rotation lock. 98 // is no rotation lock.
79 void LeaveMaximizeMode(); 99 void LeaveMaximizeMode();
80 100
101 // The maximized window manager (if enabled).
102 scoped_ptr<MaximizeModeWindowManager> maximize_mode_window_manager_;
103
81 // An event targeter controller which traps mouse and keyboard events while 104 // An event targeter controller which traps mouse and keyboard events while
82 // maximize mode is engaged. 105 // maximize mode is engaged.
83 scoped_ptr<MaximizeModeEventBlocker> event_blocker_; 106 scoped_ptr<MaximizeModeEventBlocker> event_blocker_;
84 107
85 // An event handler used to detect screenshot actions while in maximize mode. 108 // An event handler used to detect screenshot actions while in maximize mode.
86 scoped_ptr<ui::EventHandler> event_handler_; 109 scoped_ptr<ui::EventHandler> event_handler_;
87 110
88 // When true calls to OnAccelerometerUpdated will not rotate the display. 111 // When true calls to OnAccelerometerUpdated will not rotate the display.
89 bool rotation_locked_; 112 bool rotation_locked_;
90 113
91 // Whether we have ever seen accelerometer data. 114 // Whether we have ever seen accelerometer data.
92 bool have_seen_accelerometer_data_; 115 bool have_seen_accelerometer_data_;
93 116
94 // True when the screen's orientation is being changed. 117 // True when the screen's orientation is being changed.
95 bool in_set_screen_rotation_; 118 bool in_set_screen_rotation_;
96 119
97 // The rotation of the display set by the user. This rotation will be 120 // The rotation of the display set by the user. This rotation will be
98 // restored upon exiting maximize mode. 121 // restored upon exiting maximize mode.
99 gfx::Display::Rotation user_rotation_; 122 gfx::Display::Rotation user_rotation_;
100 123
101 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); 124 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController);
102 }; 125 };
103 126
104 } // namespace ash 127 } // namespace ash
105 128
106 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ 129 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ash/test/shell_test_api.cc ('k') | ash/wm/maximize_mode/maximize_mode_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698