| 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/chromeos/power/tablet_power_button_controller.h" | 5 #include "ash/system/chromeos/power/tablet_power_button_controller.h" |
| 6 | 6 |
| 7 #include "ash/common/accessibility_delegate.h" | 7 #include "ash/common/accessibility_delegate.h" |
| 8 #include "ash/common/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
| 9 #include "ash/common/shell_delegate.h" | 9 #include "ash/common/shell_delegate.h" |
| 10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 TabletPowerButtonController::TabletPowerButtonController( | 80 TabletPowerButtonController::TabletPowerButtonController( |
| 81 LockStateController* controller) | 81 LockStateController* controller) |
| 82 : tick_clock_(new base::DefaultTickClock()), | 82 : tick_clock_(new base::DefaultTickClock()), |
| 83 last_resume_time_(base::TimeTicks()), | 83 last_resume_time_(base::TimeTicks()), |
| 84 force_off_on_button_up_(true), | 84 force_off_on_button_up_(true), |
| 85 controller_(controller), | 85 controller_(controller), |
| 86 weak_ptr_factory_(this) { | 86 weak_ptr_factory_(this) { |
| 87 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( | 87 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( |
| 88 this); | 88 this); |
| 89 WmShell::Get()->AddShellObserver(this); | 89 WmShell::Get()->AddShellObserver(this); |
| 90 ui::InputDeviceManager::GetInstance()->AddObserver(this); | 90 // TODO(mash): Provide a way for this class to observe stylus events: |
| 91 // http://crbug.com/682460 |
| 92 if (ui::InputDeviceManager::HasInstance()) |
| 93 ui::InputDeviceManager::GetInstance()->AddObserver(this); |
| 91 Shell::GetInstance()->PrependPreTargetHandler(this); | 94 Shell::GetInstance()->PrependPreTargetHandler(this); |
| 92 | 95 |
| 93 GetInitialBacklightsForcedOff(); | 96 GetInitialBacklightsForcedOff(); |
| 94 } | 97 } |
| 95 | 98 |
| 96 TabletPowerButtonController::~TabletPowerButtonController() { | 99 TabletPowerButtonController::~TabletPowerButtonController() { |
| 97 Shell::GetInstance()->RemovePreTargetHandler(this); | 100 Shell::GetInstance()->RemovePreTargetHandler(this); |
| 98 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); | 101 if (ui::InputDeviceManager::HasInstance()) |
| 102 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); |
| 99 WmShell::Get()->RemoveShellObserver(this); | 103 WmShell::Get()->RemoveShellObserver(this); |
| 100 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( | 104 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( |
| 101 this); | 105 this); |
| 102 } | 106 } |
| 103 | 107 |
| 104 bool TabletPowerButtonController::ShouldHandlePowerButtonEvents() const { | 108 bool TabletPowerButtonController::ShouldHandlePowerButtonEvents() const { |
| 105 return IsTabletModeSupported(); | 109 return IsTabletModeSupported(); |
| 106 } | 110 } |
| 107 | 111 |
| 108 void TabletPowerButtonController::OnPowerButtonEvent( | 112 void TabletPowerButtonController::OnPowerButtonEvent( |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 FROM_HERE, base::TimeDelta::FromMilliseconds(kLockScreenTimeoutMs), | 261 FROM_HERE, base::TimeDelta::FromMilliseconds(kLockScreenTimeoutMs), |
| 258 this, &TabletPowerButtonController::OnLockScreenTimeout); | 262 this, &TabletPowerButtonController::OnLockScreenTimeout); |
| 259 } | 263 } |
| 260 } | 264 } |
| 261 | 265 |
| 262 void TabletPowerButtonController::OnLockScreenTimeout() { | 266 void TabletPowerButtonController::OnLockScreenTimeout() { |
| 263 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); | 267 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); |
| 264 } | 268 } |
| 265 | 269 |
| 266 } // namespace ash | 270 } // namespace ash |
| OLD | NEW |