1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_
#define CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_
#include <jni.h>
#include "base/android/jni_helper.h"
namespace content {
class RenderWidgetHostImpl;
class RenderWidgetHostViewAndroid;
struct NativeWebKeyboardEvent;
// This class is in charge of dispatching key events from the java side
// and forward to renderer along with input method results via
// corresponding host view.
// Ownership of these objects remains on the native side (see
// RenderWidgetHostViewAndroid).
class ImeAdapterAndroid {
public:
explicit ImeAdapterAndroid(RenderWidgetHostViewAndroid* rwhva);
~ImeAdapterAndroid();
// Called from java -> native
// The java side is responsible to translate android KeyEvent various enums
// and values into the corresponding WebKit::WebInputEvent.
bool SendKeyEvent(JNIEnv* env, jobject,
jobject original_key_event,
int action, int meta_state,
long event_time, int key_code,
bool is_system_key, int unicode_text);
// |event_type| is a value of WebInputEvent::Type.
bool SendSyntheticKeyEvent(JNIEnv*,
jobject,
int event_type,
long timestamp_ms,
int native_key_code,
int unicode_char);
void SetComposingText(JNIEnv*, jobject, jstring text, int new_cursor_pos);
void ImeBatchStateChanged(JNIEnv*, jobject, jboolean is_begin);
void CommitText(JNIEnv*, jobject, jstring text);
void FinishComposingText(JNIEnv* env, jobject);
void AttachImeAdapter(JNIEnv*, jobject java_object);
void SetEditableSelectionOffsets(JNIEnv*, jobject, int start, int end);
void SetComposingRegion(JNIEnv*, jobject, int start, int end);
void DeleteSurroundingText(JNIEnv*, jobject, int before, int after);
void Unselect(JNIEnv*, jobject);
void SelectAll(JNIEnv*, jobject);
void Cut(JNIEnv*, jobject);
void Copy(JNIEnv*, jobject);
void Paste(JNIEnv*, jobject);
void ResetImeAdapter(JNIEnv*, jobject);
// Called from native -> java
void CancelComposition();
private:
RenderWidgetHostImpl* GetRenderWidgetHostImpl();
RenderWidgetHostViewAndroid* rwhva_;
JavaObjectWeakGlobalRef java_ime_adapter_;
};
bool RegisterImeAdapter(JNIEnv* env);
} // namespace content
#endif // CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_
|