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

Side by Side Diff: content/browser/renderer_host/native_web_keyboard_event_android.cc

Issue 2206053002: Use KeyDown instead of RawKeyDown for Android key events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review comments and disable test Created 4 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/public/browser/native_web_keyboard_event.h" 5 #include "content/public/browser/native_web_keyboard_event.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "content/browser/renderer_host/input/web_input_event_builders_android.h " 8 #include "content/browser/renderer_host/input/web_input_event_builders_android.h "
9 #include "ui/gfx/native_widget_types.h" 9 #include "ui/gfx/native_widget_types.h"
10 10
11 namespace { 11 namespace {
12 12
13 jobject NewGlobalRefForKeyEvent(jobject key_event) { 13 jobject NewGlobalRefForKeyEvent(jobject key_event) {
14 if (key_event == NULL) return NULL; 14 if (key_event == nullptr) return nullptr;
15 return base::android::AttachCurrentThread()->NewGlobalRef(key_event); 15 return base::android::AttachCurrentThread()->NewGlobalRef(key_event);
16 } 16 }
17 17
18 void DeleteGlobalRefForKeyEvent(jobject key_event) { 18 void DeleteGlobalRefForKeyEvent(jobject key_event) {
19 if (key_event != NULL) 19 if (key_event != nullptr)
20 base::android::AttachCurrentThread()->DeleteGlobalRef(key_event); 20 base::android::AttachCurrentThread()->DeleteGlobalRef(key_event);
21 } 21 }
22 22
23 } 23 }
24 24
25 namespace content { 25 namespace content {
26 26
27 NativeWebKeyboardEvent::NativeWebKeyboardEvent() 27 NativeWebKeyboardEvent::NativeWebKeyboardEvent()
28 : os_event(NULL), 28 : os_event(nullptr),
29 skip_in_browser(false) { 29 skip_in_browser(false) {
30 } 30 }
31 31
32 NativeWebKeyboardEvent::NativeWebKeyboardEvent(blink::WebInputEvent::Type type,
33 int modifiers,
34 double time_secs,
35 int keycode,
36 int scancode,
37 int unicode_character,
38 bool is_system_key)
39 : WebKeyboardEvent(WebKeyboardEventBuilder::Build(nullptr,
40 nullptr,
41 type,
42 modifiers,
43 time_secs,
44 keycode,
45 scancode,
46 unicode_character,
47 is_system_key)) {
48 os_event = NULL;
49 skip_in_browser = false;
50 }
51
52 NativeWebKeyboardEvent::NativeWebKeyboardEvent( 32 NativeWebKeyboardEvent::NativeWebKeyboardEvent(
53 JNIEnv* env, 33 JNIEnv* env,
54 const base::android::JavaRef<jobject>& android_key_event, 34 const base::android::JavaRef<jobject>& android_key_event,
55 blink::WebInputEvent::Type type, 35 blink::WebInputEvent::Type type,
56 int modifiers, 36 int modifiers,
57 double time_secs, 37 double time_secs,
58 int keycode, 38 int keycode,
59 int scancode, 39 int scancode,
60 int unicode_character, 40 int unicode_character,
61 bool is_system_key) 41 bool is_system_key)
62 : WebKeyboardEvent(WebKeyboardEventBuilder::Build(env, 42 : WebKeyboardEvent(WebKeyboardEventBuilder::Build(env,
63 android_key_event, 43 android_key_event,
64 type, 44 type,
65 modifiers, 45 modifiers,
66 time_secs, 46 time_secs,
67 keycode, 47 keycode,
68 scancode, 48 scancode,
69 unicode_character, 49 unicode_character,
70 is_system_key)) { 50 is_system_key)),
71 os_event = NewGlobalRefForKeyEvent(android_key_event.obj()); 51 os_event(nullptr),
72 skip_in_browser = false; 52 skip_in_browser(false) {
53 if (!android_key_event.is_null())
54 os_event = NewGlobalRefForKeyEvent(android_key_event.obj());
73 } 55 }
74 56
75 NativeWebKeyboardEvent::NativeWebKeyboardEvent( 57 NativeWebKeyboardEvent::NativeWebKeyboardEvent(
76 const NativeWebKeyboardEvent& other) 58 const NativeWebKeyboardEvent& other)
77 : WebKeyboardEvent(other), 59 : WebKeyboardEvent(other),
78 os_event(NewGlobalRefForKeyEvent(other.os_event)), 60 os_event(NewGlobalRefForKeyEvent(other.os_event)),
79 skip_in_browser(other.skip_in_browser) { 61 skip_in_browser(other.skip_in_browser) {
80 } 62 }
81 63
82 NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=( 64 NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=(
83 const NativeWebKeyboardEvent& other) { 65 const NativeWebKeyboardEvent& other) {
84 WebKeyboardEvent::operator=(other); 66 WebKeyboardEvent::operator=(other);
85 67
86 os_event = NewGlobalRefForKeyEvent(other.os_event); 68 os_event = NewGlobalRefForKeyEvent(other.os_event);
87 skip_in_browser = other.skip_in_browser; 69 skip_in_browser = other.skip_in_browser;
88 70
89 return *this; 71 return *this;
90 } 72 }
91 73
92 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() { 74 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() {
93 DeleteGlobalRefForKeyEvent(os_event); 75 DeleteGlobalRefForKeyEvent(os_event);
94 } 76 }
95 77
96 } // namespace content 78 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698