Chromium Code Reviews| 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/events/base_event_utils.h" | |
| 9 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| 10 | 11 |
| 11 namespace { | 12 namespace { |
| 12 | 13 |
| 13 jobject NewGlobalRefForKeyEvent(jobject key_event) { | 14 jobject NewGlobalRefForKeyEvent(jobject key_event) { |
| 14 if (key_event == nullptr) return nullptr; | 15 if (key_event == nullptr) return nullptr; |
| 15 return base::android::AttachCurrentThread()->NewGlobalRef(key_event); | 16 return base::android::AttachCurrentThread()->NewGlobalRef(key_event); |
| 16 } | 17 } |
| 17 | 18 |
| 18 void DeleteGlobalRefForKeyEvent(jobject key_event) { | 19 void DeleteGlobalRefForKeyEvent(jobject key_event) { |
| 19 if (key_event != nullptr) | 20 if (key_event != nullptr) |
| 20 base::android::AttachCurrentThread()->DeleteGlobalRef(key_event); | 21 base::android::AttachCurrentThread()->DeleteGlobalRef(key_event); |
| 21 } | 22 } |
| 22 | 23 |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 | 27 |
| 27 NativeWebKeyboardEvent::NativeWebKeyboardEvent() | 28 NativeWebKeyboardEvent::NativeWebKeyboardEvent(blink::WebInputEvent::Type type, |
| 28 : os_event(nullptr), | 29 int modifiers, |
| 29 skip_in_browser(false) { | 30 base::TimeTicks timestamp) |
| 30 } | 31 : NativeWebKeyboardEvent(type, |
| 32 modifiers, | |
| 33 ui::EventTimeStampToSeconds(timestamp)) {} | |
| 34 | |
| 35 NativeWebKeyboardEvent::NativeWebKeyboardEvent(blink::WebInputEvent::Type type, | |
| 36 int modifiers, | |
| 37 double timestampSeconds) | |
| 38 : WebKeyboardEvent(type, modifiers, timestampSeconds), | |
| 39 os_event(NULL), | |
|
majidvp
2016/12/19 20:09:52
s/NULL/nullptr/
dtapuska
2016/12/20 19:49:21
Done.
| |
| 40 skip_in_browser(false) {} | |
| 31 | 41 |
| 32 NativeWebKeyboardEvent::NativeWebKeyboardEvent( | 42 NativeWebKeyboardEvent::NativeWebKeyboardEvent( |
| 33 JNIEnv* env, | 43 JNIEnv* env, |
| 34 const base::android::JavaRef<jobject>& android_key_event, | 44 const base::android::JavaRef<jobject>& android_key_event, |
| 35 blink::WebInputEvent::Type type, | 45 blink::WebInputEvent::Type type, |
| 36 int modifiers, | 46 int modifiers, |
| 37 double time_secs, | 47 double time_secs, |
| 38 int keycode, | 48 int keycode, |
| 39 int scancode, | 49 int scancode, |
| 40 int unicode_character, | 50 int unicode_character, |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 69 skip_in_browser = other.skip_in_browser; | 79 skip_in_browser = other.skip_in_browser; |
| 70 | 80 |
| 71 return *this; | 81 return *this; |
| 72 } | 82 } |
| 73 | 83 |
| 74 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() { | 84 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() { |
| 75 DeleteGlobalRefForKeyEvent(os_event); | 85 DeleteGlobalRefForKeyEvent(os_event); |
| 76 } | 86 } |
| 77 | 87 |
| 78 } // namespace content | 88 } // namespace content |
| OLD | NEW |