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

Unified Diff: components/keyboard_lock/platform_key_event_filter.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/platform_key_event_filter.h ('k') | components/keyboard_lock/platform_key_hook.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/keyboard_lock/platform_key_event_filter.cc
diff --git a/components/keyboard_lock/platform_key_event_filter.cc b/components/keyboard_lock/platform_key_event_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fe7fe62edb32db8c5a2a3ba5891bfccb8c041012
--- /dev/null
+++ b/components/keyboard_lock/platform_key_event_filter.cc
@@ -0,0 +1,33 @@
+// 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/platform_key_event_filter.h"
+
+#include "base/logging.h"
+#include "components/keyboard_lock/key_event_filter.h"
+#include "ui/events/event_utils.h"
+
+namespace keyboard_lock {
+
+PlatformKeyEventFilter::PlatformKeyEventFilter(KeyEventFilter* filter)
+ : filter_(filter) {
+ DCHECK(filter_);
+}
+PlatformKeyEventFilter::~PlatformKeyEventFilter() = default;
+
+bool PlatformKeyEventFilter::OnPlatformEvent(const ui::PlatformEvent& event) {
+ ui::EventType event_type = ui::EventTypeFromNative(event);
+ if (event_type != ui::ET_KEY_PRESSED && event_type != ui::ET_KEY_RELEASED) {
+ return false;
+ }
+
+ ui::KeyboardCode code = ui::KeyboardCodeFromNative(event);
+ int flags = ui::EventFlagsFromNative(event);
+ bool result = (event_type == ui::ET_KEY_PRESSED ?
+ filter_->OnKeyDown(code, flags) :
+ filter_->OnKeyUp(code, flags));
+ return result;
+}
+
+} // namespace keyboard_lock
« no previous file with comments | « components/keyboard_lock/platform_key_event_filter.h ('k') | components/keyboard_lock/platform_key_hook.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698