OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_ANDROID_IME_ADAPTER_ANDROID_H_ | 5 #ifndef CONTENT_BROWSER_ANDROID_IME_ADAPTER_ANDROID_H_ |
6 #define CONTENT_BROWSER_ANDROID_IME_ADAPTER_ANDROID_H_ | 6 #define CONTENT_BROWSER_ANDROID_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 "content/browser/android/render_widget_host_connector.h" | 13 #include "content/browser/android/render_widget_host_connector.h" |
| 14 #include "content/browser/renderer_host/input/timeout_monitor.h" |
14 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "third_party/WebKit/public/platform/input_host.mojom.h" |
| 17 #include "third_party/WebKit/public/platform/input_messages.mojom.h" |
15 #include "ui/gfx/geometry/rect_f.h" | 18 #include "ui/gfx/geometry/rect_f.h" |
16 | 19 |
17 namespace blink { | 20 namespace blink { |
18 | 21 |
19 struct WebCompositionUnderline; | 22 struct WebCompositionUnderline; |
20 | 23 |
21 } // namespace blink | 24 } // namespace blink |
22 | 25 |
23 namespace content { | 26 namespace content { |
24 | 27 |
25 class RenderFrameHost; | 28 class RenderFrameHost; |
26 class RenderWidgetHostImpl; | 29 class RenderWidgetHostImpl; |
27 class RenderWidgetHostViewAndroid; | 30 class RenderWidgetHostViewAndroid; |
| 31 class TimeoutMonitor; |
28 struct TextInputState; | 32 struct TextInputState; |
29 | 33 |
30 // This class is in charge of dispatching key events from the java side | 34 // This class is in charge of dispatching key events from the java side |
31 // and forward to renderer along with input method results via | 35 // and forward to renderer along with input method results via |
32 // corresponding host view. | 36 // corresponding host view. |
33 class CONTENT_EXPORT ImeAdapterAndroid : public RenderWidgetHostConnector { | 37 class CONTENT_EXPORT ImeAdapterAndroid : public RenderWidgetHostConnector { |
34 public: | 38 public: |
35 ImeAdapterAndroid(JNIEnv* env, | 39 ImeAdapterAndroid(JNIEnv* env, |
36 const base::android::JavaParamRef<jobject>& obj, | 40 const base::android::JavaParamRef<jobject>& obj, |
37 WebContents* web_contents); | 41 WebContents* web_contents); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 JNIEnv*, | 81 JNIEnv*, |
78 const base::android::JavaParamRef<jobject>&, | 82 const base::android::JavaParamRef<jobject>&, |
79 int before, | 83 int before, |
80 int after); | 84 int after); |
81 void RequestCursorUpdate(JNIEnv*, | 85 void RequestCursorUpdate(JNIEnv*, |
82 const base::android::JavaParamRef<jobject>&, | 86 const base::android::JavaParamRef<jobject>&, |
83 bool immediateRequest, | 87 bool immediateRequest, |
84 bool monitorRequest); | 88 bool monitorRequest); |
85 bool RequestTextInputStateUpdate(JNIEnv*, | 89 bool RequestTextInputStateUpdate(JNIEnv*, |
86 const base::android::JavaParamRef<jobject>&); | 90 const base::android::JavaParamRef<jobject>&); |
| 91 void ApplySpellCheckSuggestion( |
| 92 JNIEnv*, |
| 93 const base::android::JavaParamRef<jobject>&, |
| 94 const base::android::JavaParamRef<jstring>& replacement); |
| 95 void DeleteActiveSuggestionRange(JNIEnv*, |
| 96 const base::android::JavaParamRef<jobject>&); |
| 97 void NewWordAddedToDictionary( |
| 98 JNIEnv*, |
| 99 const base::android::JavaParamRef<jobject>&, |
| 100 const base::android::JavaParamRef<jstring>& word); |
| 101 void SuggestionMenuClosed(JNIEnv*, |
| 102 const base::android::JavaParamRef<jobject>&); |
87 | 103 |
88 // RendetWidgetHostConnector implementation. | 104 // RendetWidgetHostConnector implementation. |
89 void UpdateRenderProcessConnection( | 105 void UpdateRenderProcessConnection( |
90 RenderWidgetHostViewAndroid* old_rwhva, | 106 RenderWidgetHostViewAndroid* old_rwhva, |
91 RenderWidgetHostViewAndroid* new_rhwva) override; | 107 RenderWidgetHostViewAndroid* new_rhwva) override; |
92 | 108 |
93 void UpdateFrameInfo(const gfx::SelectionBound& selection_start, | 109 void UpdateFrameInfo(const gfx::SelectionBound& selection_start, |
94 float dip_scale, | 110 float dip_scale, |
95 float content_offset_ypix); | 111 float content_offset_ypix); |
96 | 112 |
97 // Called from native -> java | 113 // Called from native -> java |
98 void CancelComposition(); | 114 void CancelComposition(); |
99 void FocusedNodeChanged(bool is_editable_node); | 115 void FocusedNodeChanged(bool is_editable_node); |
100 void SetCharacterBounds(const std::vector<gfx::RectF>& rects); | 116 void SetCharacterBounds(const std::vector<gfx::RectF>& rects); |
| 117 void StartSpellCheckMenuTimer(); |
| 118 void StopSpellCheckMenuTimer(); |
| 119 void ShowSpellCheckSuggestionMenu( |
| 120 double caret_x, |
| 121 double caret_y, |
| 122 const std::string& marked_text, |
| 123 const std::vector<blink::mojom::SpellCheckSuggestionPtr>& suggestions); |
101 | 124 |
102 base::android::ScopedJavaLocalRef<jobject> java_ime_adapter_for_testing( | 125 base::android::ScopedJavaLocalRef<jobject> java_ime_adapter_for_testing( |
103 JNIEnv* env) { | 126 JNIEnv* env) { |
104 return java_ime_adapter_.get(env); | 127 return java_ime_adapter_.get(env); |
105 } | 128 } |
106 | 129 |
107 void UpdateState(const TextInputState& state); | 130 void UpdateState(const TextInputState& state); |
108 | 131 |
109 private: | 132 private: |
110 RenderWidgetHostImpl* GetFocusedWidget(); | 133 RenderWidgetHostImpl* GetFocusedWidget(); |
111 RenderFrameHost* GetFocusedFrame(); | 134 RenderFrameHost* GetFocusedFrame(); |
| 135 const blink::mojom::TextSuggestionBackendPtr& GetTextSuggestionBackend(); |
112 std::vector<blink::WebCompositionUnderline> GetUnderlinesFromSpans( | 136 std::vector<blink::WebCompositionUnderline> GetUnderlinesFromSpans( |
113 JNIEnv* env, | 137 JNIEnv* env, |
114 const base::android::JavaParamRef<jobject>& obj, | 138 const base::android::JavaParamRef<jobject>& obj, |
115 const base::android::JavaParamRef<jobject>& text, | 139 const base::android::JavaParamRef<jobject>& text, |
116 const base::string16& text16); | 140 const base::string16& text16); |
| 141 void OnSpellCheckMenuTimeout(); |
117 | 142 |
118 // Current RenderWidgetHostView connected to this instance. Can be null. | 143 // Current RenderWidgetHostView connected to this instance. Can be null. |
119 RenderWidgetHostViewAndroid* rwhva_; | 144 RenderWidgetHostViewAndroid* rwhva_; |
120 JavaObjectWeakGlobalRef java_ime_adapter_; | 145 JavaObjectWeakGlobalRef java_ime_adapter_; |
| 146 blink::mojom::TextSuggestionBackendPtr text_suggestion_backend_; |
| 147 TimeoutMonitor spellcheck_menu_timeout_; |
121 }; | 148 }; |
122 | 149 |
123 bool RegisterImeAdapter(JNIEnv* env); | 150 bool RegisterImeAdapter(JNIEnv* env); |
124 | 151 |
125 } // namespace content | 152 } // namespace content |
126 | 153 |
127 #endif // CONTENT_BROWSER_ANDROID_IME_ADAPTER_ANDROID_H_ | 154 #endif // CONTENT_BROWSER_ANDROID_IME_ADAPTER_ANDROID_H_ |
OLD | NEW |