Commit a2195917 authored by Qiang Xu's avatar Qiang Xu Committed by Commit Bot

cros: remove TabletPowerButtonController::ShouldHandlePowerButtonEvents

changes:
(1) Since |tablet_controller_| is created OnAccelerometerUpdate, itself
is enough to represent ShouldHandlePowerButtonEvents().
(2) Remove IsTabletModeSupported() in PowerButtonDisplayController. It
is used on stylus removed. Nowadays, stylus is configured on convertible
only. Even for clamshell device with stylus, SetDisplayForcedOff(false)
should be OK since it will be a no-op because of early return.

TEST=covered by tests

Bug: none
Change-Id: I0dd883d9bf97e1c24c1b9acd5e1856b630f97fec
Reviewed-on: https://chromium-review.googlesource.com/702919Reviewed-by: default avatarDan Erat <derat@chromium.org>
Commit-Queue: Qiang(Joe) Xu <warx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506942}
parent 576ab877
...@@ -20,13 +20,6 @@ namespace ash { ...@@ -20,13 +20,6 @@ namespace ash {
namespace { namespace {
// Returns true if device is a convertible/tablet device, otherwise false.
bool IsTabletModeSupported() {
TabletModeController* tablet_mode_controller =
Shell::Get()->tablet_mode_controller();
return tablet_mode_controller && tablet_mode_controller->CanEnterTabletMode();
}
// Returns true if device is currently in tablet/tablet mode, otherwise false. // Returns true if device is currently in tablet/tablet mode, otherwise false.
bool IsTabletModeActive() { bool IsTabletModeActive() {
TabletModeController* tablet_mode_controller = TabletModeController* tablet_mode_controller =
...@@ -121,7 +114,7 @@ void PowerButtonDisplayController::OnKeyEvent(ui::KeyEvent* event) { ...@@ -121,7 +114,7 @@ void PowerButtonDisplayController::OnKeyEvent(ui::KeyEvent* event) {
if (event->key_code() == ui::VKEY_POWER) if (event->key_code() == ui::VKEY_POWER)
return; return;
if (!IsTabletModeActive() && backlights_forced_off_) if (!IsTabletModeActive())
SetDisplayForcedOff(false); SetDisplayForcedOff(false);
} }
...@@ -129,15 +122,13 @@ void PowerButtonDisplayController::OnMouseEvent(ui::MouseEvent* event) { ...@@ -129,15 +122,13 @@ void PowerButtonDisplayController::OnMouseEvent(ui::MouseEvent* event) {
if (event->flags() & ui::EF_IS_SYNTHESIZED) if (event->flags() & ui::EF_IS_SYNTHESIZED)
return; return;
if (!IsTabletModeActive() && backlights_forced_off_) if (!IsTabletModeActive())
SetDisplayForcedOff(false); SetDisplayForcedOff(false);
} }
void PowerButtonDisplayController::OnStylusStateChanged(ui::StylusState state) { void PowerButtonDisplayController::OnStylusStateChanged(ui::StylusState state) {
if (IsTabletModeSupported() && state == ui::StylusState::REMOVED && if (state == ui::StylusState::REMOVED)
backlights_forced_off_) {
SetDisplayForcedOff(false); SetDisplayForcedOff(false);
}
} }
void PowerButtonDisplayController::GetInitialBacklightsForcedOff() { void PowerButtonDisplayController::GetInitialBacklightsForcedOff() {
......
...@@ -45,13 +45,6 @@ constexpr base::TimeDelta kShutdownWhenScreenOffTimeout = ...@@ -45,13 +45,6 @@ constexpr base::TimeDelta kShutdownWhenScreenOffTimeout =
constexpr base::TimeDelta kIgnorePowerButtonAfterResumeDelay = constexpr base::TimeDelta kIgnorePowerButtonAfterResumeDelay =
base::TimeDelta::FromSeconds(2); base::TimeDelta::FromSeconds(2);
// Returns true if device is a convertible/tablet device, otherwise false.
bool IsTabletModeSupported() {
TabletModeController* tablet_mode_controller =
Shell::Get()->tablet_mode_controller();
return tablet_mode_controller && tablet_mode_controller->CanEnterTabletMode();
}
// Returns the value for the command-line switch identified by |name|. Returns 0 // Returns the value for the command-line switch identified by |name|. Returns 0
// if the switch was unset or contained a non-float value. // if the switch was unset or contained a non-float value.
double GetNumSwitch(const base::CommandLine& command_line, double GetNumSwitch(const base::CommandLine& command_line,
...@@ -145,10 +138,6 @@ TabletPowerButtonController::~TabletPowerButtonController() { ...@@ -145,10 +138,6 @@ TabletPowerButtonController::~TabletPowerButtonController() {
this); this);
} }
bool TabletPowerButtonController::ShouldHandlePowerButtonEvents() const {
return IsTabletModeSupported();
}
void TabletPowerButtonController::OnPowerButtonEvent( void TabletPowerButtonController::OnPowerButtonEvent(
bool down, bool down,
const base::TimeTicks& timestamp) { const base::TimeTicks& timestamp) {
......
...@@ -88,10 +88,6 @@ class ASH_EXPORT TabletPowerButtonController ...@@ -88,10 +88,6 @@ class ASH_EXPORT TabletPowerButtonController
base::TickClock* tick_clock); base::TickClock* tick_clock);
~TabletPowerButtonController() override; ~TabletPowerButtonController() override;
// Returns true if power button events should be handled by this class instead
// of PowerButtonController.
bool ShouldHandlePowerButtonEvents() const;
// Handles a power button event. // Handles a power button event.
void OnPowerButtonEvent(bool down, const base::TimeTicks& timestamp); void OnPowerButtonEvent(bool down, const base::TimeTicks& timestamp);
......
...@@ -72,8 +72,7 @@ void PowerButtonController::OnPowerButtonEvent( ...@@ -72,8 +72,7 @@ void PowerButtonController::OnPowerButtonEvent(
->IsTabletModeWindowManagerEnabled(); ->IsTabletModeWindowManagerEnabled();
if (!has_legacy_power_button_ && !should_take_screenshot && if (!has_legacy_power_button_ && !should_take_screenshot &&
tablet_controller_ && tablet_controller_) {
tablet_controller_->ShouldHandlePowerButtonEvents()) {
tablet_controller_->OnPowerButtonEvent(down, timestamp); tablet_controller_->OnPowerButtonEvent(down, timestamp);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment