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..10662d418ef267240c83a7c94321fd5d611df584 100644 |
| --- a/ash/wm/power_button_controller.cc |
| +++ b/ash/wm/power_button_controller.cc |
| @@ -13,6 +13,7 @@ |
| #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,6 +22,7 @@ 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_( |
| @@ -29,12 +31,14 @@ PowerButtonController::PowerButtonController( |
| 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 +59,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_) { |
| @@ -78,7 +88,7 @@ void PowerButtonController::OnPowerButtonEvent( |
| if (session_state_delegate->CanLockScreen() && |
| !session_state_delegate->IsScreenLocked()) { |
| - controller_->StartLockAnimation(true); |
| + controller_->StartLockAnimationAndLockImmediately(); |
|
flackr
2014/06/10 17:34:42
Won't this affect the regular power button on a ch
|
| } else { |
| controller_->StartShutdownAnimation(); |
| } |
| @@ -116,6 +126,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) { |