Chromium Code Reviews| Index: components/keyboard_lock/key_event_interceptor.h |
| diff --git a/components/keyboard_lock/key_event_interceptor.h b/components/keyboard_lock/key_event_interceptor.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4106c587aaa958ead4f774a0857e8a7743751032 |
| --- /dev/null |
| +++ b/components/keyboard_lock/key_event_interceptor.h |
| @@ -0,0 +1,38 @@ |
| +// Copyright 2017 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. |
| + |
| +#ifndef COMPONENTS_KEYBOARD_LOCK_KEY_EVENT_INTERCEPTOR_H_ |
| +#define COMPONENTS_KEYBOARD_LOCK_KEY_EVENT_INTERCEPTOR_H_ |
| + |
| +#include "ui/events/keycodes/keyboard_codes.h" |
| + |
| +namespace keyboard_lock { |
| + |
| +// An interface to receive and process a key event. The implementation needs to |
| +// guarantee the thread-safety of OnKeyDown() and OnKeyUp() functions, which may |
| +// be executed in a unpredictable thread. |
| +class KeyEventInterceptor { |
|
Wez
2017/04/28 00:22:44
"interceptor" sounds like this is the thing that i
Hzj_jie
2017/04/28 20:02:03
Yes, it does intercept the events, it controls whe
|
| + public: |
| + KeyEventInterceptor() = default; |
| + virtual ~KeyEventInterceptor() = default; |
| + |
| + virtual bool OnKeyDown(ui::KeyboardCode code) = 0; |
| + virtual bool OnKeyUp(ui::KeyboardCode code) = 0; |
|
Wez
2017/04/28 00:22:44
ui::KeyboardCode is evil and deprecated. :P
Is it
Hzj_jie
2017/04/28 20:02:03
That's too bad. I suppose there is always a replac
|
| + |
| + // An interface to retrieve a KeyEventInterceptor instance. This class is used |
| + // to avoid the dependency of the singleton object of KeyboardLockHost, and to |
| + // ensure late installed KeyEventInterceptor can be retrieved. |
| + class Retriever { |
| + public: |
| + Retriever() = default; |
| + virtual ~Retriever() = default; |
| + |
| + // May return nullptr. |
| + virtual KeyEventInterceptor* Get() = 0; |
| + }; |
| +}; |
| + |
| +} // namespace keyboard_lock |
| + |
| +#endif // COMPONENTS_KEYBOARD_LOCK_KEY_EVENT_INTERCEPTOR_H_ |