OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "ash/system/power/tablet_power_button_controller.h" | 5 #include "ash/system/power/tablet_power_button_controller.h" |
6 | 6 |
7 #include "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
8 #include "ash/session/session_controller.h" | 8 #include "ash/session/session_controller.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_delegate.h" | 10 #include "ash/shell_delegate.h" |
11 #include "ash/wm/lock_state_controller.h" | 11 #include "ash/wm/lock_state_controller.h" |
12 #include "ash/wm/tablet_mode/tablet_mode_controller.h" | 12 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
13 #include "base/time/default_tick_clock.h" | 13 #include "base/time/default_tick_clock.h" |
14 #include "chromeos/dbus/dbus_thread_manager.h" | 14 #include "chromeos/dbus/dbus_thread_manager.h" |
15 #include "ui/events/devices/input_device_manager.h" | 15 #include "ui/events/devices/input_device_manager.h" |
16 #include "ui/events/devices/stylus_state.h" | 16 #include "ui/events/devices/stylus_state.h" |
17 #include "ui/events/event.h" | 17 #include "ui/events/event.h" |
18 | 18 |
19 namespace ash { | 19 namespace ash { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
(...skipping 11 matching lines...) Expand all Loading... |
34 // ignored. | 34 // ignored. |
35 constexpr int kIgnorePowerButtonAfterResumeMs = 2000; | 35 constexpr int kIgnorePowerButtonAfterResumeMs = 2000; |
36 | 36 |
37 // Ignore button-up events occurring within this many milliseconds of the | 37 // Ignore button-up events occurring within this many milliseconds of the |
38 // previous button-up event. This prevents us from falling behind if the power | 38 // previous button-up event. This prevents us from falling behind if the power |
39 // button is pressed repeatedly. | 39 // button is pressed repeatedly. |
40 constexpr int kIgnoreRepeatedButtonUpMs = 500; | 40 constexpr int kIgnoreRepeatedButtonUpMs = 500; |
41 | 41 |
42 // Returns true if device is a convertible/tablet device, otherwise false. | 42 // Returns true if device is a convertible/tablet device, otherwise false. |
43 bool IsTabletModeSupported() { | 43 bool IsTabletModeSupported() { |
44 TabletModeController* tablet_mode_controller = | 44 MaximizeModeController* maximize_mode_controller = |
45 Shell::Get()->tablet_mode_controller(); | 45 Shell::Get()->maximize_mode_controller(); |
46 return tablet_mode_controller && tablet_mode_controller->CanEnterTabletMode(); | 46 return maximize_mode_controller && |
| 47 maximize_mode_controller->CanEnterMaximizeMode(); |
47 } | 48 } |
48 | 49 |
49 // Returns true if device is currently in tablet/tablet mode, otherwise false. | 50 // Returns true if device is currently in tablet/maximize mode, otherwise false. |
50 bool IsTabletModeActive() { | 51 bool IsTabletModeActive() { |
51 TabletModeController* tablet_mode_controller = | 52 MaximizeModeController* maximize_mode_controller = |
52 Shell::Get()->tablet_mode_controller(); | 53 Shell::Get()->maximize_mode_controller(); |
53 return tablet_mode_controller && | 54 return maximize_mode_controller && |
54 tablet_mode_controller->IsTabletModeWindowManagerEnabled(); | 55 maximize_mode_controller->IsMaximizeModeWindowManagerEnabled(); |
55 } | 56 } |
56 | 57 |
57 } // namespace | 58 } // namespace |
58 | 59 |
59 TabletPowerButtonController::TestApi::TestApi( | 60 TabletPowerButtonController::TestApi::TestApi( |
60 TabletPowerButtonController* controller) | 61 TabletPowerButtonController* controller) |
61 : controller_(controller) {} | 62 : controller_(controller) {} |
62 | 63 |
63 TabletPowerButtonController::TestApi::~TestApi() {} | 64 TabletPowerButtonController::TestApi::~TestApi() {} |
64 | 65 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 const base::TimeDelta& sleep_duration) { | 160 const base::TimeDelta& sleep_duration) { |
160 last_resume_time_ = tick_clock_->NowTicks(); | 161 last_resume_time_ = tick_clock_->NowTicks(); |
161 } | 162 } |
162 | 163 |
163 void TabletPowerButtonController::LidEventReceived( | 164 void TabletPowerButtonController::LidEventReceived( |
164 chromeos::PowerManagerClient::LidState state, | 165 chromeos::PowerManagerClient::LidState state, |
165 const base::TimeTicks& timestamp) { | 166 const base::TimeTicks& timestamp) { |
166 SetDisplayForcedOff(false); | 167 SetDisplayForcedOff(false); |
167 } | 168 } |
168 | 169 |
169 void TabletPowerButtonController::OnTabletModeStarted() { | 170 void TabletPowerButtonController::OnMaximizeModeStarted() { |
170 shutdown_timer_.Stop(); | 171 shutdown_timer_.Stop(); |
171 if (controller_->CanCancelShutdownAnimation()) | 172 if (controller_->CanCancelShutdownAnimation()) |
172 controller_->CancelShutdownAnimation(); | 173 controller_->CancelShutdownAnimation(); |
173 } | 174 } |
174 | 175 |
175 void TabletPowerButtonController::OnTabletModeEnded() { | 176 void TabletPowerButtonController::OnMaximizeModeEnded() { |
176 shutdown_timer_.Stop(); | 177 shutdown_timer_.Stop(); |
177 if (controller_->CanCancelShutdownAnimation()) | 178 if (controller_->CanCancelShutdownAnimation()) |
178 controller_->CancelShutdownAnimation(); | 179 controller_->CancelShutdownAnimation(); |
179 } | 180 } |
180 | 181 |
181 void TabletPowerButtonController::OnKeyEvent(ui::KeyEvent* event) { | 182 void TabletPowerButtonController::OnKeyEvent(ui::KeyEvent* event) { |
182 // Ignore key events generated by the power button since power button activity | 183 // Ignore key events generated by the power button since power button activity |
183 // is already handled by OnPowerButtonEvent(). | 184 // is already handled by OnPowerButtonEvent(). |
184 if (event->key_code() == ui::VKEY_POWER) | 185 if (event->key_code() == ui::VKEY_POWER) |
185 return; | 186 return; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 SessionController* session_controller = Shell::Get()->session_controller(); | 263 SessionController* session_controller = Shell::Get()->session_controller(); |
263 if (session_controller->ShouldLockScreenAutomatically() && | 264 if (session_controller->ShouldLockScreenAutomatically() && |
264 session_controller->CanLockScreen() && | 265 session_controller->CanLockScreen() && |
265 !session_controller->IsUserSessionBlocked() && | 266 !session_controller->IsUserSessionBlocked() && |
266 !controller_->LockRequested()) { | 267 !controller_->LockRequested()) { |
267 session_controller->LockScreen(); | 268 session_controller->LockScreen(); |
268 } | 269 } |
269 } | 270 } |
270 | 271 |
271 } // namespace ash | 272 } // namespace ash |
OLD | NEW |