1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "athena/input/public/accelerator_manager.h"
6 #include "athena/input/public/input_manager.h"
7 #include "athena/screen_lock/screen_lock_manager_base.h"
8 #include "base/logging.h"
9 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
18 const AcceleratorData accelerator_data
[] = {
19 { TRIGGER_ON_PRESS
, ui::VKEY_L
, ui::EF_SHIFT_DOWN
| ui::EF_CONTROL_DOWN
,
20 CMD_LOCK_SCREEN
, AF_NONE
}};
22 class ChromeScreenLockManager
: public ScreenLockManagerBase
,
23 public AcceleratorHandler
,
24 public PowerButtonObserver
{
26 ChromeScreenLockManager() {}
31 ~ChromeScreenLockManager() override
;
35 void LockScreen() override
;
37 // AcceleratorHandler:
38 bool IsCommandEnabled(int command_id
) const override
;
39 bool OnAcceleratorFired(int command_id
,
40 const ui::Accelerator
& accelerator
) override
;
42 // PowerButtonObserver:
43 void OnPowerButtonStateChanged(State state
) override
;
45 DISALLOW_COPY_AND_ASSIGN(ChromeScreenLockManager
);
48 ChromeScreenLockManager::~ChromeScreenLockManager() {
49 InputManager::Get()->RemovePowerButtonObserver(this);
52 void ChromeScreenLockManager::Init() {
53 AcceleratorManager::Get()->RegisterAccelerators(
54 accelerator_data
, arraysize(accelerator_data
), this);
55 InputManager::Get()->AddPowerButtonObserver(this);
58 void ChromeScreenLockManager::LockScreen() {
59 chromeos::ScreenLocker::HandleLockScreenRequest();
62 bool ChromeScreenLockManager::IsCommandEnabled(int command_id
) const {
66 bool ChromeScreenLockManager::OnAcceleratorFired(
68 const ui::Accelerator
& accelerator
) {
80 void ChromeScreenLockManager::OnPowerButtonStateChanged(State state
) {
88 ScreenLockManager
* ScreenLockManager::Create() {
89 ChromeScreenLockManager
* instance
= new ChromeScreenLockManager();