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 #ifndef CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/android/jni_weak_ref.h" | 12 #include "base/android/jni_weak_ref.h" |
| 13 #include "base/strings/string16.h" |
13 #include "ui/gfx/geometry/rect_f.h" | 14 #include "ui/gfx/geometry/rect_f.h" |
14 | 15 |
| 16 namespace blink { |
| 17 |
| 18 struct WebCompositionUnderline; |
| 19 |
| 20 } // namespace blink |
| 21 |
15 namespace content { | 22 namespace content { |
16 | 23 |
17 class RenderFrameHost; | 24 class RenderFrameHost; |
18 class RenderWidgetHostImpl; | 25 class RenderWidgetHostImpl; |
19 class RenderWidgetHostViewAndroid; | 26 class RenderWidgetHostViewAndroid; |
20 class WebContents; | 27 class WebContents; |
21 | 28 |
22 // This class is in charge of dispatching key events from the java side | 29 // This class is in charge of dispatching key events from the java side |
23 // and forward to renderer along with input method results via | 30 // and forward to renderer along with input method results via |
24 // corresponding host view. | 31 // corresponding host view. |
25 // Ownership of these objects remains on the native side (see | 32 // Ownership of these objects remains on the native side (see |
26 // RenderWidgetHostViewAndroid). | 33 // RenderWidgetHostViewAndroid). |
27 class ImeAdapterAndroid { | 34 class ImeAdapterAndroid { |
28 public: | 35 public: |
29 explicit ImeAdapterAndroid(RenderWidgetHostViewAndroid* rwhva); | 36 explicit ImeAdapterAndroid(RenderWidgetHostViewAndroid* rwhva); |
30 ~ImeAdapterAndroid(); | 37 ~ImeAdapterAndroid(); |
31 | 38 |
32 // Called from java -> native | 39 // Called from java -> native |
33 bool SendKeyEvent( | 40 bool SendKeyEvent( |
34 JNIEnv* env, | 41 JNIEnv* env, |
35 const base::android::JavaParamRef<jobject>&, | 42 const base::android::JavaParamRef<jobject>&, |
36 const base::android::JavaParamRef<jobject>& original_key_event, | 43 const base::android::JavaParamRef<jobject>& original_key_event, |
37 int type, | 44 int type, |
38 int modifiers, | 45 int modifiers, |
39 long event_time, | 46 long event_time, |
40 int key_code, | 47 int key_code, |
41 int scan_code, | 48 int scan_code, |
42 bool is_system_key, | 49 bool is_system_key, |
43 int unicode_text); | 50 int unicode_text); |
44 void SetComposingText(JNIEnv*, | 51 void SetComposingText(JNIEnv* env, |
45 const base::android::JavaParamRef<jobject>& obj, | 52 const base::android::JavaParamRef<jobject>& obj, |
46 const base::android::JavaParamRef<jobject>& text, | 53 const base::android::JavaParamRef<jobject>& text, |
47 const base::android::JavaParamRef<jstring>& text_str, | 54 const base::android::JavaParamRef<jstring>& text_str, |
48 int relative_cursor_pos); | 55 int relative_cursor_pos); |
49 void CommitText(JNIEnv*, | 56 void CommitText(JNIEnv* env, |
50 const base::android::JavaParamRef<jobject>&, | 57 const base::android::JavaParamRef<jobject>& obj, |
| 58 const base::android::JavaParamRef<jobject>& text, |
51 const base::android::JavaParamRef<jstring>& text_str, | 59 const base::android::JavaParamRef<jstring>& text_str, |
52 int relative_cursor_pos); | 60 int relative_cursor_pos); |
53 void FinishComposingText(JNIEnv* env, | 61 void FinishComposingText(JNIEnv* env, |
54 const base::android::JavaParamRef<jobject>&); | 62 const base::android::JavaParamRef<jobject>&); |
55 void AttachImeAdapter( | 63 void AttachImeAdapter( |
56 JNIEnv*, | 64 JNIEnv*, |
57 const base::android::JavaParamRef<jobject>& java_object); | 65 const base::android::JavaParamRef<jobject>& java_object); |
58 void SetEditableSelectionOffsets(JNIEnv*, | 66 void SetEditableSelectionOffsets(JNIEnv*, |
59 const base::android::JavaParamRef<jobject>&, | 67 const base::android::JavaParamRef<jobject>&, |
60 int start, | 68 int start, |
(...skipping 14 matching lines...) Expand all Loading... |
75 | 83 |
76 // Called from native -> java | 84 // Called from native -> java |
77 void CancelComposition(); | 85 void CancelComposition(); |
78 void FocusedNodeChanged(bool is_editable_node); | 86 void FocusedNodeChanged(bool is_editable_node); |
79 void SetCharacterBounds(const std::vector<gfx::RectF>& rects); | 87 void SetCharacterBounds(const std::vector<gfx::RectF>& rects); |
80 | 88 |
81 private: | 89 private: |
82 RenderWidgetHostImpl* GetRenderWidgetHostImpl(); | 90 RenderWidgetHostImpl* GetRenderWidgetHostImpl(); |
83 RenderFrameHost* GetFocusedFrame(); | 91 RenderFrameHost* GetFocusedFrame(); |
84 WebContents* GetWebContents(); | 92 WebContents* GetWebContents(); |
| 93 std::vector<blink::WebCompositionUnderline> GetUnderlinesFromSpans( |
| 94 JNIEnv* env, |
| 95 const base::android::JavaParamRef<jobject>& obj, |
| 96 const base::android::JavaParamRef<jobject>& text, |
| 97 const base::string16& text16); |
85 | 98 |
86 RenderWidgetHostViewAndroid* rwhva_; | 99 RenderWidgetHostViewAndroid* rwhva_; |
87 JavaObjectWeakGlobalRef java_ime_adapter_; | 100 JavaObjectWeakGlobalRef java_ime_adapter_; |
88 }; | 101 }; |
89 | 102 |
90 bool RegisterImeAdapter(JNIEnv* env); | 103 bool RegisterImeAdapter(JNIEnv* env); |
91 | 104 |
92 } // namespace content | 105 } // namespace content |
93 | 106 |
94 #endif // CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_ | 107 #endif // CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_ |
OLD | NEW |