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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/keyboard_lock/key_hook_thread_wrapper.cc
diff --git a/components/keyboard_lock/key_hook_thread_wrapper.cc b/components/keyboard_lock/key_hook_thread_wrapper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c3cf0954e4cf9e85c3d670968b2531b6517801d5
--- /dev/null
+++ b/components/keyboard_lock/key_hook_thread_wrapper.cc
@@ -0,0 +1,71 @@
+// 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.
+
+#include "components/keyboard_lock/key_hook_thread_wrapper.h"
+
+#include <memory>
+#include <utility>
+
+#include "base/location.h"
+#include "base/logging.h"
+#include "base/memory/ptr_util.h"
+#include "components/keyboard_lock/key_event_filter_share_wrapper.h"
+#include "components/keyboard_lock/key_hook_state_keeper.h"
+
+namespace keyboard_lock {
+
+KeyHookThreadWrapper::KeyHookThreadWrapper(
+ std::unique_ptr<KeyEventFilter> filter,
+ std::unique_ptr<KeyHookActivator> key_hook)
+ : filter_(std::move(filter)),
+ key_hook_(std::move(key_hook)) {
+ DCHECK(filter_);
+ DCHECK(key_hook_);
+}
+
+KeyHookThreadWrapper::KeyHookThreadWrapper(
+ std::unique_ptr<KeyHookStateKeeper> state_keeper)
+ : KeyHookThreadWrapper(
+ base::MakeUnique<KeyEventFilterShareWrapper>(state_keeper.get()),
+ std::move(state_keeper)) {}
+
+KeyHookThreadWrapper::~KeyHookThreadWrapper() = default;
+
+bool KeyHookThreadWrapper::OnKeyDown(ui::KeyboardCode code, int flags) {
+ base::AutoLock lock(lock_);
+ return filter_->OnKeyDown(code, flags);
+}
+
+bool KeyHookThreadWrapper::OnKeyUp(ui::KeyboardCode code, int flags) {
+ base::AutoLock lock(lock_);
+ return filter_->OnKeyUp(code, flags);
+}
+
+void KeyHookThreadWrapper::RegisterKey(
+ const std::vector<ui::KeyboardCode>& codes,
+ base::Callback<void(bool)> on_result) {
+ base::AutoLock lock(lock_);
+ key_hook_->RegisterKey(codes, on_result);
+}
+
+void KeyHookThreadWrapper::UnregisterKey(
+ const std::vector<ui::KeyboardCode>& codes,
+ base::Callback<void(bool)> on_result) {
+ base::AutoLock lock(lock_);
+ key_hook_->UnregisterKey(codes, on_result);
+}
+
+void KeyHookThreadWrapper::Activate(
+ base::Callback<void(bool)> on_result) {
+ base::AutoLock lock(lock_);
+ key_hook_->Activate(on_result);
+}
+
+void KeyHookThreadWrapper::Deactivate(
+ base::Callback<void(bool)> on_result) {
+ base::AutoLock lock(lock_);
+ key_hook_->Deactivate(on_result);
+}
+
+} // namespace keyboard_lock
« 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