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/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/shell_observer.h" | 9 #include "ash/shell_observer.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 void SuspendImminent() override; | 90 void SuspendImminent() override; |
91 void SuspendDone(const base::TimeDelta& sleep_duration) override; | 91 void SuspendDone(const base::TimeDelta& sleep_duration) override; |
92 #endif // OS_CHROMEOS | 92 #endif // OS_CHROMEOS |
93 | 93 |
94 private: | 94 private: |
95 friend class MaximizeModeControllerTest; | 95 friend class MaximizeModeControllerTest; |
96 friend class MaximizeModeWindowManagerTest; | 96 friend class MaximizeModeWindowManagerTest; |
97 friend class test::MultiUserWindowManagerChromeOSTest; | 97 friend class test::MultiUserWindowManagerChromeOSTest; |
98 friend class test::VirtualKeyboardControllerTest; | 98 friend class test::VirtualKeyboardControllerTest; |
99 | 99 |
100 // Used for recording metrics for intervals of time spent in | |
101 // and out of TouchView. | |
102 enum TouchViewIntervalType { | |
flackr
2015/02/12 19:59:06
Why not a bool if we only have active an inactive?
tdanderson
2015/02/12 20:30:49
I prefer enums over bools in cases where it would
flackr
2015/02/12 20:44:43
Can also use RecordTouchViewUsageInterval(/* touch
jonross
2015/02/12 20:49:26
using a bool would clean up some of the logic in t
tdanderson
2015/02/12 21:38:22
Rob and I had a chat offline and he's OK leaving t
| |
103 TOUCH_VIEW_INTERVAL_INACTIVE, | |
104 TOUCH_VIEW_INTERVAL_ACTIVE | |
105 }; | |
106 | |
100 // Set the TickClock. This is only to be used by tests that need to | 107 // Set the TickClock. This is only to be used by tests that need to |
101 // artificially and deterministically control the current time. | 108 // artificially and deterministically control the current time. |
102 void SetTickClockForTest(scoped_ptr<base::TickClock> tick_clock); | 109 void SetTickClockForTest(scoped_ptr<base::TickClock> tick_clock); |
103 | 110 |
104 #if defined(OS_CHROMEOS) | 111 #if defined(OS_CHROMEOS) |
105 // Detect hinge rotation from base and lid accelerometers and automatically | 112 // Detect hinge rotation from base and lid accelerometers and automatically |
106 // start / stop maximize mode. | 113 // start / stop maximize mode. |
107 void HandleHingeRotation(const chromeos::AccelerometerUpdate& update); | 114 void HandleHingeRotation(const chromeos::AccelerometerUpdate& update); |
108 #endif | 115 #endif |
109 | 116 |
110 // Returns true if the lid was recently opened. | 117 // Returns true if the lid was recently opened. |
111 bool WasLidOpenedRecently() const; | 118 bool WasLidOpenedRecently() const; |
112 | 119 |
113 // Enables MaximizeModeWindowManager, and determines the current state of | 120 // Enables MaximizeModeWindowManager, and determines the current state of |
114 // rotation lock. | 121 // rotation lock. |
115 void EnterMaximizeMode(); | 122 void EnterMaximizeMode(); |
116 | 123 |
117 // Removes MaximizeModeWindowManager and resets the display rotation if there | 124 // Removes MaximizeModeWindowManager and resets the display rotation if there |
118 // is no rotation lock. | 125 // is no rotation lock. |
119 void LeaveMaximizeMode(); | 126 void LeaveMaximizeMode(); |
120 | 127 |
121 // Record UMA stats tracking touchview usage. | 128 // Record UMA stats tracking TouchView usage. If |type| is |
122 void RecordTouchViewStateTransition(); | 129 // TOUCH_VIEW_INTERVAL_INACTIVE, then record that TouchView has been |
130 // inactive from |touchview_usage_interval_start_time_| until now. | |
131 // Similarly, record that TouchView has been active if |type| is | |
132 // TOUCH_VIEW_INTERVAL_ACTIVE. | |
133 void RecordTouchViewUsageInterval(TouchViewIntervalType type); | |
123 | 134 |
124 // The maximized window manager (if enabled). | 135 // The maximized window manager (if enabled). |
125 scoped_ptr<MaximizeModeWindowManager> maximize_mode_window_manager_; | 136 scoped_ptr<MaximizeModeWindowManager> maximize_mode_window_manager_; |
126 | 137 |
127 // A helper class which when instantiated will block native events from the | 138 // A helper class which when instantiated will block native events from the |
128 // internal keyboard and touchpad. | 139 // internal keyboard and touchpad. |
129 scoped_ptr<ScopedDisableInternalMouseAndKeyboard> event_blocker_; | 140 scoped_ptr<ScopedDisableInternalMouseAndKeyboard> event_blocker_; |
130 | 141 |
131 // Whether we have ever seen accelerometer data. | 142 // Whether we have ever seen accelerometer data. |
132 bool have_seen_accelerometer_data_; | 143 bool have_seen_accelerometer_data_; |
133 | 144 |
134 // True when the hinge angle has been detected past 180 degrees. | 145 // True when the hinge angle has been detected past 180 degrees. |
135 bool lid_open_past_180_; | 146 bool lid_open_past_180_; |
136 | 147 |
137 // Tracks time spent in (and out of) touchview mode. | 148 // Tracks time spent in (and out of) touchview mode. |
138 base::Time last_touchview_transition_time_; | 149 base::Time touchview_usage_interval_start_time_; |
139 base::TimeDelta total_touchview_time_; | 150 base::TimeDelta total_touchview_time_; |
140 base::TimeDelta total_non_touchview_time_; | 151 base::TimeDelta total_non_touchview_time_; |
141 | 152 |
142 // Tracks the last time we received a lid open event. This is used to suppress | 153 // Tracks the last time we received a lid open event. This is used to suppress |
143 // erroneous accelerometer readings as the lid is opened but the accelerometer | 154 // erroneous accelerometer readings as the lid is opened but the accelerometer |
144 // reports readings that make the lid to appear near fully open. | 155 // reports readings that make the lid to appear near fully open. |
145 base::TimeTicks last_lid_open_time_; | 156 base::TimeTicks last_lid_open_time_; |
146 | 157 |
147 // Source for the current time in base::TimeTicks. | 158 // Source for the current time in base::TimeTicks. |
148 scoped_ptr<base::TickClock> tick_clock_; | 159 scoped_ptr<base::TickClock> tick_clock_; |
149 | 160 |
150 // Tracks when the lid is closed. Used to prevent entering maximize mode. | 161 // Tracks when the lid is closed. Used to prevent entering maximize mode. |
151 bool lid_is_closed_; | 162 bool lid_is_closed_; |
152 | 163 |
153 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); | 164 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); |
154 }; | 165 }; |
155 | 166 |
156 } // namespace ash | 167 } // namespace ash |
157 | 168 |
158 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ | 169 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ |
OLD | NEW |