Chromium Code Reviews| Index: ash/common/key_event_watcher.cc |
| diff --git a/ash/common/key_event_watcher.cc b/ash/common/key_event_watcher.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fab5ee64ad08e784606ac2d5f2d1571ead43c995 |
| --- /dev/null |
| +++ b/ash/common/key_event_watcher.cc |
| @@ -0,0 +1,26 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ash/common/key_event_watcher.h" |
| + |
| +namespace ash { |
| + |
| +KeyEventWatcher::KeyEventWatcher() {} |
| +KeyEventWatcher::~KeyEventWatcher() {} |
|
James Cook
2016/09/22 21:17:16
nit: blank line above
oshima
2016/09/23 09:37:19
Done.
|
| + |
| +void KeyEventWatcher::AddKeyEventCallback(const ui::Accelerator& key, |
| + const KeyEventCallback& callback) { |
| + callback_map_.insert(std::make_pair(key, callback)); |
| +} |
| + |
| +bool KeyEventWatcher::HandleKeyEvent(const ui::KeyEvent& event) { |
| + auto iter = callback_map_.find(ui::Accelerator(event)); |
| + if (iter != callback_map_.end()) { |
| + iter->second.Run(event); |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| +} // namespace ash |