OLD | NEW |
---|---|
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 |
(...skipping 11 matching lines...) Expand all Loading... | |
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(NULL), |
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(NULL), |
no sievers
2016/08/08 23:08:51
nit: nullptr here and elsewhere, while you're in h
| |
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 |
OLD | NEW |