Index: ash/wm/power_button_controller.cc |
diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc |
index 9daa3df0ef896512a112d92b0c62437655185a6a..07a2d13daff9eb034f56d86464d26728f2784d69 100644 |
--- a/ash/wm/power_button_controller.cc |
+++ b/ash/wm/power_button_controller.cc |
@@ -17,11 +17,11 @@ |
#include "base/command_line.h" |
#include "ui/aura/window_event_dispatcher.h" |
#include "ui/display/types/display_snapshot.h" |
+#include "ui/events/event_handler.h" |
#include "ui/wm/core/compound_event_filter.h" |
#if defined(OS_CHROMEOS) |
#include "ash/common/system/chromeos/audio/tray_audio.h" |
-#include "ash/system/chromeos/power/tablet_power_button_controller.h" |
#include "chromeos/audio/cras_audio_handler.h" |
#include "chromeos/dbus/dbus_thread_manager.h" |
#endif |
@@ -40,12 +40,16 @@ |
has_legacy_power_button_( |
base::CommandLine::ForCurrentProcess()->HasSwitch( |
switches::kAuraLegacyPowerButton)), |
- lock_state_controller_(controller) { |
+#if defined(OS_CHROMEOS) |
+ enable_quick_lock_(base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kAshEnableTouchView)), |
+#else |
+ enable_quick_lock_(false), |
+#endif |
+ controller_(controller) { |
#if defined(OS_CHROMEOS) |
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( |
this); |
- tablet_controller_.reset( |
- new TabletPowerButtonController(lock_state_controller_)); |
Shell::GetInstance()->display_configurator()->AddObserver(this); |
#endif |
Shell::GetInstance()->PrependPreTargetHandler(this); |
@@ -55,7 +59,6 @@ |
Shell::GetInstance()->RemovePreTargetHandler(this); |
#if defined(OS_CHROMEOS) |
Shell::GetInstance()->display_configurator()->RemoveObserver(this); |
- tablet_controller_.reset(); |
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( |
this); |
#endif |
@@ -70,21 +73,8 @@ |
const base::TimeTicks& timestamp) { |
power_button_down_ = down; |
- if (lock_state_controller_->ShutdownRequested()) |
- return; |
- |
-#if defined(OS_CHROMEOS) |
- bool should_take_screenshot = down && volume_down_pressed_ && |
- WmShell::Get() |
- ->maximize_mode_controller() |
- ->IsMaximizeModeWindowManagerEnabled(); |
- |
- if (!has_legacy_power_button_ && !should_take_screenshot && |
- tablet_controller_->ShouldHandlePowerButtonEvents()) { |
- tablet_controller_->OnPowerButtonEvent(down, timestamp); |
- return; |
- } |
-#endif |
+ if (controller_->ShutdownRequested()) |
+ return; |
// Avoid starting the lock/shutdown sequence if the power button is pressed |
// while the screen is off (http://crbug.com/128451), unless an external |
@@ -94,7 +84,10 @@ |
#if defined(OS_CHROMEOS) |
// Take screenshot on power button down plus volume down when in touch view. |
- if (should_take_screenshot) { |
+ if (volume_down_pressed_ && down && |
+ WmShell::Get() |
+ ->maximize_mode_controller() |
+ ->IsMaximizeModeWindowManagerEnabled()) { |
SystemTray* system_tray = Shell::GetInstance()->GetPrimarySystemTray(); |
if (system_tray && system_tray->GetTrayAudio()) |
system_tray->GetTrayAudio()->HideDetailedView(false); |
@@ -121,29 +114,35 @@ |
if (down) { |
if (session_state_delegate->CanLockScreen() && |
!session_state_delegate->IsUserSessionBlocked() && |
- !lock_state_controller_->LockRequested()) { |
- lock_state_controller_->StartLockAnimationAndLockImmediately(false); |
+ !controller_->LockRequested()) { |
+ controller_->StartLockAnimationAndLockImmediately(false); |
} else { |
- lock_state_controller_->RequestShutdown(); |
+ controller_->RequestShutdown(); |
} |
} |
} else { // !has_legacy_power_button_ |
if (down) { |
// If we already have a pending request to lock the screen, wait. |
- if (lock_state_controller_->LockRequested()) |
+ if (controller_->LockRequested()) |
return; |
if (session_state_delegate->CanLockScreen() && |
!session_state_delegate->IsUserSessionBlocked()) { |
- lock_state_controller_->StartLockAnimation(true); |
+ if (WmShell::Get() |
+ ->maximize_mode_controller() |
+ ->IsMaximizeModeWindowManagerEnabled() && |
+ enable_quick_lock_) |
+ controller_->StartLockAnimationAndLockImmediately(true); |
+ else |
+ controller_->StartLockAnimation(true); |
} else { |
- lock_state_controller_->StartShutdownAnimation(); |
+ controller_->StartShutdownAnimation(); |
} |
} else { // Button is up. |
- if (lock_state_controller_->CanCancelLockAnimation()) |
- lock_state_controller_->CancelLockAnimation(); |
- else if (lock_state_controller_->CanCancelShutdownAnimation()) |
- lock_state_controller_->CancelShutdownAnimation(); |
+ if (controller_->CanCancelLockAnimation()) |
+ controller_->CancelLockAnimation(); |
+ else if (controller_->CanCancelShutdownAnimation()) |
+ controller_->CancelShutdownAnimation(); |
} |
} |
} |
@@ -157,8 +156,7 @@ |
WmShell::Get()->GetSessionStateDelegate(); |
if (!session_state_delegate->CanLockScreen() || |
session_state_delegate->IsScreenLocked() || |
- lock_state_controller_->LockRequested() || |
- lock_state_controller_->ShutdownRequested()) { |
+ controller_->LockRequested() || controller_->ShutdownRequested()) { |
return; |
} |
@@ -167,9 +165,9 @@ |
return; |
if (down) |
- lock_state_controller_->StartLockAnimation(false); |
+ controller_->StartLockAnimation(false); |
else |
- lock_state_controller_->CancelLockAnimation(); |
+ controller_->CancelLockAnimation(); |
} |
void PowerButtonController::OnKeyEvent(ui::KeyEvent* event) { |