OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 #ifndef COMPONENTS_KEYBOARD_LOCK_ACTIVE_KEY_EVENT_FILTER_REGISTRAR_H_ |
| 6 #define COMPONENTS_KEYBOARD_LOCK_ACTIVE_KEY_EVENT_FILTER_REGISTRAR_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "components/keyboard_lock/key_event_filter.h" |
| 11 #include "components/keyboard_lock/key_hook_activator.h" |
| 12 |
| 13 namespace keyboard_lock { |
| 14 |
| 15 class ActiveKeyEventFilterTracker; |
| 16 |
| 17 // An implementation of KeyHookActivator to forward requests to |key_hook| and |
| 18 // register / unregister cooresponding key event filter |filter| to |tracker|. |
| 19 class ActiveKeyEventFilterRegistrar final : public KeyHookActivator { |
| 20 public: |
| 21 // |tracker| should outlive |this|. |
| 22 ActiveKeyEventFilterRegistrar(ActiveKeyEventFilterTracker* tracker, |
| 23 std::unique_ptr<KeyHookActivator> key_hook, |
| 24 KeyEventFilter* filter); |
| 25 ~ActiveKeyEventFilterRegistrar() override; |
| 26 |
| 27 private: |
| 28 // KeyHookActivator implementations |
| 29 void RegisterKey(const std::vector<ui::KeyboardCode>& codes, |
| 30 base::Callback<void(bool)> on_result) override; |
| 31 void UnregisterKey(const std::vector<ui::KeyboardCode>& codes, |
| 32 base::Callback<void(bool)> on_result) override; |
| 33 void Activate(base::Callback<void(bool)> on_result) override; |
| 34 void Deactivate(base::Callback<void(bool)> on_result) override; |
| 35 |
| 36 ActiveKeyEventFilterTracker* const tracker_; |
| 37 std::unique_ptr<KeyHookActivator> key_hook_; |
| 38 KeyEventFilter* const filter_; |
| 39 }; |
| 40 |
| 41 } // namespace keyboard_lock |
| 42 |
| 43 #endif // COMPONENTS_KEYBOARD_LOCK_ACTIVE_KEY_EVENT_FILTER_REGISTRAR_H_ |
OLD | NEW |