Index: content/browser/android/text_suggestion_host_android.h |
diff --git a/content/browser/android/text_suggestion_host_android.h b/content/browser/android/text_suggestion_host_android.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c5bf1c7a325e4c90321a0aaf1d660fc70ca75dd1 |
--- /dev/null |
+++ b/content/browser/android/text_suggestion_host_android.h |
@@ -0,0 +1,70 @@ |
+// Copyright 2017 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_ANDROID_TEXT_SUGGESTION_HOST_ANDROID_H_ |
+#define CONTENT_BROWSER_ANDROID_TEXT_SUGGESTION_HOST_ANDROID_H_ |
+ |
+#include "content/browser/android/render_widget_host_connector.h" |
+#include "content/browser/renderer_host/input/timeout_monitor.h" |
+#include "third_party/WebKit/public/platform/input_host.mojom.h" |
+#include "third_party/WebKit/public/platform/input_messages.mojom.h" |
+ |
+namespace content { |
+ |
+class TextSuggestionHostAndroid : public RenderWidgetHostConnector { |
+ public: |
+ TextSuggestionHostAndroid(JNIEnv* env, |
+ const base::android::JavaParamRef<jobject>& obj, |
+ WebContents* web_contents); |
+ ~TextSuggestionHostAndroid() override; |
+ |
+ // RenderWidgetHostConnector implementation. |
+ void UpdateRenderProcessConnection( |
+ RenderWidgetHostViewAndroid* old_rwhva, |
+ RenderWidgetHostViewAndroid* new_rhwva) override; |
+ |
+ // Called from Java -> native |
+ void ApplySpellCheckSuggestion( |
+ JNIEnv*, |
+ const base::android::JavaParamRef<jobject>&, |
+ const base::android::JavaParamRef<jstring>& replacement); |
+ void DeleteActiveSuggestionRange(JNIEnv*, |
+ const base::android::JavaParamRef<jobject>&); |
+ void NewWordAddedToDictionary( |
+ JNIEnv*, |
+ const base::android::JavaParamRef<jobject>&, |
+ const base::android::JavaParamRef<jstring>& word); |
+ void SuggestionMenuClosed(JNIEnv*, |
+ const base::android::JavaParamRef<jobject>&); |
+ |
+ // Called from native -> Java |
+ void ShowSpellCheckSuggestionMenu( |
+ double caret_x, |
+ double caret_y, |
+ const std::string& marked_text, |
+ const std::vector<blink::mojom::SpellCheckSuggestionPtr>& suggestions); |
+ |
+ // Other methods |
+ void FocusedNodeChanged(); |
+ |
+ void StartSpellCheckMenuTimer(); |
+ void StopSpellCheckMenuTimer(); |
+ |
+ private: |
+ RenderFrameHost* GetFocusedFrame(); |
+ const blink::mojom::TextSuggestionBackendPtr& GetTextSuggestionBackend(); |
+ void OnSpellCheckMenuTimeout(); |
+ |
+ // Current RenderWidgetHostView connected to this instance. Can be null. |
+ RenderWidgetHostViewAndroid* rwhva_; |
+ JavaObjectWeakGlobalRef java_text_suggestion_host_; |
+ blink::mojom::TextSuggestionBackendPtr text_suggestion_backend_; |
+ TimeoutMonitor spellcheck_menu_timeout_; |
+}; |
+ |
+bool RegisterTextSuggestionHost(JNIEnv* env); |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_ANDROID_TEXT_SUGGESTION_HOST_ANDROID_H_ |