Chromium Code Reviews| Index: ash/wm/power_button_controller.cc |
| diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc |
| index 6e96c651dc5ba2ea47d4f44015dd3d9b3559fe74..4045638bf74b4ca89a36b15ea50a0a28d48c8e48 100644 |
| --- a/ash/wm/power_button_controller.cc |
| +++ b/ash/wm/power_button_controller.cc |
| @@ -9,10 +9,12 @@ |
| #include "ash/shell.h" |
| #include "ash/shell_window_ids.h" |
| #include "ash/wm/lock_state_controller.h" |
| +#include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| #include "ash/wm/session_state_animator.h" |
| #include "base/command_line.h" |
| #include "ui/aura/window_event_dispatcher.h" |
| #include "ui/display/types/chromeos/display_snapshot.h" |
| +#include "ui/events/event_handler.h" |
| #include "ui/wm/core/compound_event_filter.h" |
| namespace ash { |
| @@ -21,20 +23,25 @@ PowerButtonController::PowerButtonController( |
| LockStateController* controller) |
| : power_button_down_(false), |
| lock_button_down_(false), |
| + volume_down_pressed_(false), |
| brightness_is_zero_(false), |
| internal_display_off_and_external_display_on_(false), |
| has_legacy_power_button_( |
| CommandLine::ForCurrentProcess()->HasSwitch( |
| switches::kAuraLegacyPowerButton)), |
| + enable_quick_lock_(CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kAshEnablePowerQuickLock)), |
|
Daniel Erat
2014/08/29 14:58:26
nit: just indent this four spaces beyond the previ
bruthig
2014/09/02 13:53:47
Done.
|
| controller_(controller) { |
| #if defined(OS_CHROMEOS) |
| Shell::GetInstance()->display_configurator()->AddObserver(this); |
| + Shell::GetInstance()->PrependPreTargetHandler(this); |
| #endif |
| } |
| PowerButtonController::~PowerButtonController() { |
| #if defined(OS_CHROMEOS) |
| Shell::GetInstance()->display_configurator()->RemoveObserver(this); |
| + Shell::GetInstance()->RemovePreTargetHandler(this); |
| #endif |
| } |
| @@ -55,6 +62,12 @@ void PowerButtonController::OnPowerButtonEvent( |
| if (brightness_is_zero_ && !internal_display_off_and_external_display_on_) |
| return; |
| + if (volume_down_pressed_ && down) { |
| + Shell::GetInstance()->accelerator_controller()->PerformAction( |
| + ash::TAKE_SCREENSHOT, ui::Accelerator()); |
| + return; |
| + } |
| + |
| const SessionStateDelegate* session_state_delegate = |
| Shell::GetInstance()->session_state_delegate(); |
| if (has_legacy_power_button_) { |
| @@ -65,7 +78,7 @@ void PowerButtonController::OnPowerButtonEvent( |
| if (session_state_delegate->CanLockScreen() && |
| !session_state_delegate->IsScreenLocked() && |
| !controller_->LockRequested()) { |
| - controller_->StartLockAnimationAndLockImmediately(); |
| + controller_->StartLockAnimationAndLockImmediately(false); |
| } else { |
| controller_->RequestShutdown(); |
| } |
| @@ -78,7 +91,11 @@ void PowerButtonController::OnPowerButtonEvent( |
| if (session_state_delegate->CanLockScreen() && |
| !session_state_delegate->IsScreenLocked()) { |
| - controller_->StartLockAnimation(true); |
| + if (Shell::GetInstance()->maximize_mode_controller()-> |
| + IsMaximizeModeWindowManagerEnabled() && enable_quick_lock_) |
| + controller_->StartLockAnimationAndLockImmediately(true); |
| + else |
| + controller_->StartLockAnimation(true); |
| } else { |
| controller_->StartShutdownAnimation(); |
| } |
| @@ -116,6 +133,13 @@ void PowerButtonController::OnLockButtonEvent( |
| controller_->CancelLockAnimation(); |
| } |
| +void PowerButtonController::OnKeyEvent(ui::KeyEvent* event) { |
| + if (event->key_code() == ui::VKEY_VOLUME_DOWN) { |
| + volume_down_pressed_ = event->type() == ui::ET_KEY_PRESSED || |
| + event->type() == ui::ET_TRANSLATED_KEY_PRESS; |
| + } |
| +} |
| + |
| #if defined(OS_CHROMEOS) |
| void PowerButtonController::OnDisplayModeChanged( |
| const ui::DisplayConfigurator::DisplayStateList& display_states) { |