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 #ifndef CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_
10 #include "base/android/jni_weak_ref.h"
14 class RenderFrameHost
;
15 class RenderWidgetHostImpl
;
16 class RenderWidgetHostViewAndroid
;
18 struct NativeWebKeyboardEvent
;
20 // This class is in charge of dispatching key events from the java side
21 // and forward to renderer along with input method results via
22 // corresponding host view.
23 // Ownership of these objects remains on the native side (see
24 // RenderWidgetHostViewAndroid).
25 class ImeAdapterAndroid
{
27 explicit ImeAdapterAndroid(RenderWidgetHostViewAndroid
* rwhva
);
30 // Called from java -> native
31 // The java side is responsible to translate android KeyEvent various enums
32 // and values into the corresponding blink::WebInputEvent.
33 bool SendKeyEvent(JNIEnv
* env
, jobject
,
34 jobject original_key_event
,
35 int action
, int meta_state
,
36 long event_time
, int key_code
,
37 int scan_code
, bool is_system_key
,
39 // |event_type| is a value of WebInputEvent::Type.
40 bool SendSyntheticKeyEvent(JNIEnv
*,
47 void SetComposingText(JNIEnv
*,
52 void CommitText(JNIEnv
*, jobject
, jstring text_str
);
53 void FinishComposingText(JNIEnv
* env
, jobject
);
54 void AttachImeAdapter(JNIEnv
*, jobject java_object
);
55 void SetEditableSelectionOffsets(JNIEnv
*, jobject
, int start
, int end
);
56 void SetComposingRegion(JNIEnv
*, jobject
, int start
, int end
);
57 void DeleteSurroundingText(JNIEnv
*, jobject
, int before
, int after
);
58 void ResetImeAdapter(JNIEnv
*, jobject
);
60 // Called from native -> java
61 void CancelComposition();
62 void FocusedNodeChanged(bool is_editable_node
);
65 RenderWidgetHostImpl
* GetRenderWidgetHostImpl();
66 RenderFrameHost
* GetFocusedFrame();
67 WebContents
* GetWebContents();
69 RenderWidgetHostViewAndroid
* rwhva_
;
70 JavaObjectWeakGlobalRef java_ime_adapter_
;
73 bool RegisterImeAdapter(JNIEnv
* env
);
75 } // namespace content
77 #endif // CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_