| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ash/common/key_event_watcher.h" | |
| 6 | |
| 7 namespace ash { | |
| 8 | |
| 9 KeyEventWatcher::KeyEventWatcher() {} | |
| 10 | |
| 11 KeyEventWatcher::~KeyEventWatcher() {} | |
| 12 | |
| 13 void KeyEventWatcher::AddKeyEventCallback(const ui::Accelerator& key, | |
| 14 const KeyEventCallback& callback) { | |
| 15 callback_map_.insert(std::make_pair(key, callback)); | |
| 16 } | |
| 17 | |
| 18 bool KeyEventWatcher::HandleKeyEvent(const ui::KeyEvent& event) { | |
| 19 auto iter = callback_map_.find(ui::Accelerator(event)); | |
| 20 if (iter != callback_map_.end()) { | |
| 21 iter->second.Run(event); | |
| 22 return true; | |
| 23 } | |
| 24 return false; | |
| 25 } | |
| 26 | |
| 27 } // namespace ash | |
| OLD | NEW |