Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: components/keyboard_lock/key_hook_thread_wrapper.cc

Issue 2879033002: Keyboard Lock Host implementation
Patch Set: Remove useless files Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #include "components/keyboard_lock/key_hook_thread_wrapper.h"
6
7 #include <memory>
8 #include <utility>
9
10 #include "base/location.h"
11 #include "base/logging.h"
12 #include "base/memory/ptr_util.h"
13 #include "components/keyboard_lock/key_event_filter_share_wrapper.h"
14 #include "components/keyboard_lock/key_hook_state_keeper.h"
15
16 namespace keyboard_lock {
17
18 KeyHookThreadWrapper::KeyHookThreadWrapper(
19 std::unique_ptr<KeyEventFilter> filter,
20 std::unique_ptr<KeyHookActivator> key_hook)
21 : filter_(std::move(filter)),
22 key_hook_(std::move(key_hook)) {
23 DCHECK(filter_);
24 DCHECK(key_hook_);
25 }
26
27 KeyHookThreadWrapper::KeyHookThreadWrapper(
28 std::unique_ptr<KeyHookStateKeeper> state_keeper)
29 : KeyHookThreadWrapper(
30 base::MakeUnique<KeyEventFilterShareWrapper>(state_keeper.get()),
31 std::move(state_keeper)) {}
32
33 KeyHookThreadWrapper::~KeyHookThreadWrapper() = default;
34
35 bool KeyHookThreadWrapper::OnKeyDown(ui::KeyboardCode code, int flags) {
36 base::AutoLock lock(lock_);
37 return filter_->OnKeyDown(code, flags);
38 }
39
40 bool KeyHookThreadWrapper::OnKeyUp(ui::KeyboardCode code, int flags) {
41 base::AutoLock lock(lock_);
42 return filter_->OnKeyUp(code, flags);
43 }
44
45 void KeyHookThreadWrapper::RegisterKey(
46 const std::vector<ui::KeyboardCode>& codes,
47 base::Callback<void(bool)> on_result) {
48 base::AutoLock lock(lock_);
49 key_hook_->RegisterKey(codes, on_result);
50 }
51
52 void KeyHookThreadWrapper::UnregisterKey(
53 const std::vector<ui::KeyboardCode>& codes,
54 base::Callback<void(bool)> on_result) {
55 base::AutoLock lock(lock_);
56 key_hook_->UnregisterKey(codes, on_result);
57 }
58
59 void KeyHookThreadWrapper::Activate(
60 base::Callback<void(bool)> on_result) {
61 base::AutoLock lock(lock_);
62 key_hook_->Activate(on_result);
63 }
64
65 void KeyHookThreadWrapper::Deactivate(
66 base::Callback<void(bool)> on_result) {
67 base::AutoLock lock(lock_);
68 key_hook_->Deactivate(on_result);
69 }
70
71 } // namespace keyboard_lock
OLDNEW
« no previous file with comments | « components/keyboard_lock/key_hook_thread_wrapper.h ('k') | components/keyboard_lock/keyboard_lock_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698