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

Side by Side 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 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/platform_key_event_filter.h"
6
7 #include "base/logging.h"
8 #include "components/keyboard_lock/key_event_filter.h"
9 #include "ui/events/event_utils.h"
10
11 namespace keyboard_lock {
12
13 PlatformKeyEventFilter::PlatformKeyEventFilter(KeyEventFilter* filter)
14 : filter_(filter) {
15 DCHECK(filter_);
16 }
17 PlatformKeyEventFilter::~PlatformKeyEventFilter() = default;
18
19 bool PlatformKeyEventFilter::OnPlatformEvent(const ui::PlatformEvent& event) {
20 ui::EventType event_type = ui::EventTypeFromNative(event);
21 if (event_type != ui::ET_KEY_PRESSED && event_type != ui::ET_KEY_RELEASED) {
22 return false;
23 }
24
25 ui::KeyboardCode code = ui::KeyboardCodeFromNative(event);
26 int flags = ui::EventFlagsFromNative(event);
27 bool result = (event_type == ui::ET_KEY_PRESSED ?
28 filter_->OnKeyDown(code, flags) :
29 filter_->OnKeyUp(code, flags));
30 return result;
31 }
32
33 } // namespace keyboard_lock
OLDNEW
« 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