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

Side by Side Diff: components/keyboard_lock/widget_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
« no previous file with comments | « components/keyboard_lock/widget_key_event_filter.h ('k') | content/browser/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/widget_key_event_filter.h"
6
7 #include "base/logging.h"
8 #include "content/public/browser/native_web_keyboard_event.h"
9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/render_widget_host.h"
11 #include "content/public/browser/web_contents.h"
12 #include "ui/events/event.h"
13
14 namespace keyboard_lock {
15
16 namespace {
17
18 content::NativeWebKeyboardEvent CreateNativeEvent(ui::EventType type,
19 ui::KeyboardCode code,
20 int flags) {
21 content::NativeWebKeyboardEvent event(ui::KeyEvent(type, code, flags));
22 event.skip_in_browser = true;
23 return event;
24 }
25
26 } // namespace
27
28 WidgetKeyEventFilter::WidgetKeyEventFilter(const content::WebContents* contents)
29 : host_(contents->GetRenderViewHost()->GetWidget()) {
30 DCHECK(host_);
31 }
32
33 WidgetKeyEventFilter::~WidgetKeyEventFilter() = default;
34
35 bool WidgetKeyEventFilter::OnKeyDown(ui::KeyboardCode code, int flags) {
36 LOG(ERROR) << "Forwarding OnKeyDown " << code << " with flags " << flags;
37 host_->ForwardKeyboardEvent(CreateNativeEvent(
38 ui::ET_KEY_PRESSED, code, flags));
39 return true;
40 }
41
42 bool WidgetKeyEventFilter::OnKeyUp(ui::KeyboardCode code, int flags) {
43 LOG(ERROR) << "Forwarding OnKeyUp " << code << " with flags " << flags;
44 host_->ForwardKeyboardEvent(CreateNativeEvent(
45 ui::ET_KEY_RELEASED, code, flags));
46 return true;
47 }
48
49 } // namespace keyboard_lock
OLDNEW
« no previous file with comments | « components/keyboard_lock/widget_key_event_filter.h ('k') | content/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698