Add ICU message format support
[chromium-blink-merge.git] / content / browser / renderer_host / native_web_keyboard_event_android.cc
blobd2029180f54e038f86feafb4a7ede0c4803aa4ff
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
3 // found in the LICENSE file.
5 #include "content/public/browser/native_web_keyboard_event.h"
7 #include "base/android/jni_android.h"
8 #include "content/browser/renderer_host/input/web_input_event_builders_android.h"
9 #include "ui/gfx/native_widget_types.h"
11 namespace {
13 jobject NewGlobalRefForKeyEvent(jobject key_event) {
14 if (key_event == NULL) return NULL;
15 return base::android::AttachCurrentThread()->NewGlobalRef(key_event);
18 void DeleteGlobalRefForKeyEvent(jobject key_event) {
19 if (key_event != NULL)
20 base::android::AttachCurrentThread()->DeleteGlobalRef(key_event);
25 namespace content {
27 NativeWebKeyboardEvent::NativeWebKeyboardEvent()
28 : os_event(NULL),
29 skip_in_browser(false) {
32 NativeWebKeyboardEvent::NativeWebKeyboardEvent(
33 blink::WebInputEvent::Type type,
34 int modifiers, double time_secs, int keycode, int unicode_character,
35 bool is_system_key)
36 : WebKeyboardEvent(WebKeyboardEventBuilder::Build(
37 type, modifiers, time_secs, keycode, unicode_character,
38 is_system_key)) {
39 os_event = NULL;
40 skip_in_browser = false;
43 NativeWebKeyboardEvent::NativeWebKeyboardEvent(
44 jobject android_key_event, blink::WebInputEvent::Type type,
45 int modifiers, double time_secs, int keycode, int unicode_character,
46 bool is_system_key)
47 : WebKeyboardEvent(WebKeyboardEventBuilder::Build(
48 type, modifiers, time_secs, keycode, unicode_character,
49 is_system_key)) {
50 os_event = NewGlobalRefForKeyEvent(android_key_event);
51 skip_in_browser = false;
54 NativeWebKeyboardEvent::NativeWebKeyboardEvent(
55 const NativeWebKeyboardEvent& other)
56 : WebKeyboardEvent(other),
57 os_event(NewGlobalRefForKeyEvent(other.os_event)),
58 skip_in_browser(other.skip_in_browser) {
61 NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=(
62 const NativeWebKeyboardEvent& other) {
63 WebKeyboardEvent::operator=(other);
65 os_event = NewGlobalRefForKeyEvent(other.os_event);
66 skip_in_browser = other.skip_in_browser;
68 return *this;
71 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() {
72 DeleteGlobalRefForKeyEvent(os_event);
75 } // namespace content