Commit d883302b authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Convert TextSuggestionBackend to new Mojo types

This CL converts TextSuggestionBackendPtr in content and
TextSuggestionBackendRequest in blink to the new Mojo types.

Bug: 955171, 978694
Change-Id: I481157d60666e08ed26196cf1c78b54b7fdb1fa1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1777447Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Cr-Commit-Position: refs/heads/master@{#692315}
parent d3cb4640
...@@ -63,7 +63,7 @@ TextSuggestionHostAndroid::~TextSuggestionHostAndroid() { ...@@ -63,7 +63,7 @@ TextSuggestionHostAndroid::~TextSuggestionHostAndroid() {
void TextSuggestionHostAndroid::UpdateRenderProcessConnection( void TextSuggestionHostAndroid::UpdateRenderProcessConnection(
RenderWidgetHostViewAndroid* old_rwhva, RenderWidgetHostViewAndroid* old_rwhva,
RenderWidgetHostViewAndroid* new_rwhva) { RenderWidgetHostViewAndroid* new_rwhva) {
text_suggestion_backend_ = nullptr; text_suggestion_backend_.reset();
if (old_rwhva) if (old_rwhva)
old_rwhva->set_text_suggestion_host(nullptr); old_rwhva->set_text_suggestion_host(nullptr);
if (new_rwhva) if (new_rwhva)
...@@ -75,8 +75,8 @@ void TextSuggestionHostAndroid::ApplySpellCheckSuggestion( ...@@ -75,8 +75,8 @@ void TextSuggestionHostAndroid::ApplySpellCheckSuggestion(
JNIEnv* env, JNIEnv* env,
const JavaParamRef<jobject>&, const JavaParamRef<jobject>&,
const base::android::JavaParamRef<jstring>& replacement) { const base::android::JavaParamRef<jstring>& replacement) {
const blink::mojom::TextSuggestionBackendPtr& text_suggestion_backend = const mojo::Remote<blink::mojom::TextSuggestionBackend>&
GetTextSuggestionBackend(); text_suggestion_backend = GetTextSuggestionBackend();
if (!text_suggestion_backend) if (!text_suggestion_backend)
return; return;
text_suggestion_backend->ApplySpellCheckSuggestion( text_suggestion_backend->ApplySpellCheckSuggestion(
...@@ -88,8 +88,8 @@ void TextSuggestionHostAndroid::ApplyTextSuggestion( ...@@ -88,8 +88,8 @@ void TextSuggestionHostAndroid::ApplyTextSuggestion(
const JavaParamRef<jobject>&, const JavaParamRef<jobject>&,
int marker_tag, int marker_tag,
int suggestion_index) { int suggestion_index) {
const blink::mojom::TextSuggestionBackendPtr& text_suggestion_backend = const mojo::Remote<blink::mojom::TextSuggestionBackend>&
GetTextSuggestionBackend(); text_suggestion_backend = GetTextSuggestionBackend();
if (!text_suggestion_backend) if (!text_suggestion_backend)
return; return;
text_suggestion_backend->ApplyTextSuggestion(marker_tag, suggestion_index); text_suggestion_backend->ApplyTextSuggestion(marker_tag, suggestion_index);
...@@ -98,8 +98,8 @@ void TextSuggestionHostAndroid::ApplyTextSuggestion( ...@@ -98,8 +98,8 @@ void TextSuggestionHostAndroid::ApplyTextSuggestion(
void TextSuggestionHostAndroid::DeleteActiveSuggestionRange( void TextSuggestionHostAndroid::DeleteActiveSuggestionRange(
JNIEnv*, JNIEnv*,
const JavaParamRef<jobject>&) { const JavaParamRef<jobject>&) {
const blink::mojom::TextSuggestionBackendPtr& text_suggestion_backend = const mojo::Remote<blink::mojom::TextSuggestionBackend>&
GetTextSuggestionBackend(); text_suggestion_backend = GetTextSuggestionBackend();
if (!text_suggestion_backend) if (!text_suggestion_backend)
return; return;
text_suggestion_backend->DeleteActiveSuggestionRange(); text_suggestion_backend->DeleteActiveSuggestionRange();
...@@ -109,8 +109,8 @@ void TextSuggestionHostAndroid::OnNewWordAddedToDictionary( ...@@ -109,8 +109,8 @@ void TextSuggestionHostAndroid::OnNewWordAddedToDictionary(
JNIEnv* env, JNIEnv* env,
const JavaParamRef<jobject>&, const JavaParamRef<jobject>&,
const base::android::JavaParamRef<jstring>& word) { const base::android::JavaParamRef<jstring>& word) {
const blink::mojom::TextSuggestionBackendPtr& text_suggestion_backend = const mojo::Remote<blink::mojom::TextSuggestionBackend>&
GetTextSuggestionBackend(); text_suggestion_backend = GetTextSuggestionBackend();
if (!text_suggestion_backend) if (!text_suggestion_backend)
return; return;
text_suggestion_backend->OnNewWordAddedToDictionary( text_suggestion_backend->OnNewWordAddedToDictionary(
...@@ -120,8 +120,8 @@ void TextSuggestionHostAndroid::OnNewWordAddedToDictionary( ...@@ -120,8 +120,8 @@ void TextSuggestionHostAndroid::OnNewWordAddedToDictionary(
void TextSuggestionHostAndroid::OnSuggestionMenuClosed( void TextSuggestionHostAndroid::OnSuggestionMenuClosed(
JNIEnv*, JNIEnv*,
const JavaParamRef<jobject>&) { const JavaParamRef<jobject>&) {
const blink::mojom::TextSuggestionBackendPtr& text_suggestion_backend = const mojo::Remote<blink::mojom::TextSuggestionBackend>&
GetTextSuggestionBackend(); text_suggestion_backend = GetTextSuggestionBackend();
if (!text_suggestion_backend) if (!text_suggestion_backend)
return; return;
text_suggestion_backend->OnSuggestionMenuClosed(); text_suggestion_backend->OnSuggestionMenuClosed();
...@@ -254,20 +254,20 @@ RenderFrameHost* TextSuggestionHostAndroid::GetFocusedFrame() { ...@@ -254,20 +254,20 @@ RenderFrameHost* TextSuggestionHostAndroid::GetFocusedFrame() {
return nullptr; return nullptr;
} }
const blink::mojom::TextSuggestionBackendPtr& const mojo::Remote<blink::mojom::TextSuggestionBackend>&
TextSuggestionHostAndroid::GetTextSuggestionBackend() { TextSuggestionHostAndroid::GetTextSuggestionBackend() {
if (!text_suggestion_backend_) { if (!text_suggestion_backend_) {
if (RenderFrameHost* rfh = GetFocusedFrame()) { if (RenderFrameHost* rfh = GetFocusedFrame()) {
rfh->GetRemoteInterfaces()->GetInterface( rfh->GetRemoteInterfaces()->GetInterface(
mojo::MakeRequest(&text_suggestion_backend_)); text_suggestion_backend_.BindNewPipeAndPassReceiver());
} }
} }
return text_suggestion_backend_; return text_suggestion_backend_;
} }
void TextSuggestionHostAndroid::OnSuggestionMenuTimeout() { void TextSuggestionHostAndroid::OnSuggestionMenuTimeout() {
const blink::mojom::TextSuggestionBackendPtr& text_suggestion_backend = const mojo::Remote<blink::mojom::TextSuggestionBackend>&
GetTextSuggestionBackend(); text_suggestion_backend = GetTextSuggestionBackend();
if (!text_suggestion_backend) if (!text_suggestion_backend)
return; return;
text_suggestion_backend->SuggestionMenuTimeoutCallback( text_suggestion_backend->SuggestionMenuTimeoutCallback(
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "content/browser/android/render_widget_host_connector.h" #include "content/browser/android/render_widget_host_connector.h"
#include "content/browser/renderer_host/input/timeout_monitor.h" #include "content/browser/renderer_host/input/timeout_monitor.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/service_manager/public/cpp/binder_registry.h" #include "services/service_manager/public/cpp/binder_registry.h"
#include "third_party/blink/public/mojom/input/input_host.mojom.h" #include "third_party/blink/public/mojom/input/input_host.mojom.h"
#include "third_party/blink/public/mojom/input/input_messages.mojom.h" #include "third_party/blink/public/mojom/input/input_messages.mojom.h"
...@@ -96,7 +97,8 @@ class TextSuggestionHostAndroid : public RenderWidgetHostConnector, ...@@ -96,7 +97,8 @@ class TextSuggestionHostAndroid : public RenderWidgetHostConnector,
private: private:
RenderFrameHost* GetFocusedFrame(); RenderFrameHost* GetFocusedFrame();
base::android::ScopedJavaLocalRef<jobject> GetJavaTextSuggestionHost(); base::android::ScopedJavaLocalRef<jobject> GetJavaTextSuggestionHost();
const blink::mojom::TextSuggestionBackendPtr& GetTextSuggestionBackend(); const mojo::Remote<blink::mojom::TextSuggestionBackend>&
GetTextSuggestionBackend();
// Used by the spell check menu timer to notify Blink that the timer has // Used by the spell check menu timer to notify Blink that the timer has
// expired. // expired.
void OnSuggestionMenuTimeout(); void OnSuggestionMenuTimeout();
...@@ -106,7 +108,7 @@ class TextSuggestionHostAndroid : public RenderWidgetHostConnector, ...@@ -106,7 +108,7 @@ class TextSuggestionHostAndroid : public RenderWidgetHostConnector,
// Current RenderWidgetHostView connected to this instance. Can be null. // Current RenderWidgetHostView connected to this instance. Can be null.
RenderWidgetHostViewAndroid* rwhva_; RenderWidgetHostViewAndroid* rwhva_;
JavaObjectWeakGlobalRef java_text_suggestion_host_; JavaObjectWeakGlobalRef java_text_suggestion_host_;
blink::mojom::TextSuggestionBackendPtr text_suggestion_backend_; mojo::Remote<blink::mojom::TextSuggestionBackend> text_suggestion_backend_;
TimeoutMonitor suggestion_menu_timeout_; TimeoutMonitor suggestion_menu_timeout_;
}; };
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "third_party/blink/renderer/core/editing/suggestion/text_suggestion_backend_impl.h" #include "third_party/blink/renderer/core/editing/suggestion/text_suggestion_backend_impl.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "third_party/blink/renderer/core/editing/suggestion/text_suggestion_controller.h" #include "third_party/blink/renderer/core/editing/suggestion/text_suggestion_controller.h"
#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
...@@ -16,10 +16,10 @@ TextSuggestionBackendImpl::TextSuggestionBackendImpl(LocalFrame& frame) ...@@ -16,10 +16,10 @@ TextSuggestionBackendImpl::TextSuggestionBackendImpl(LocalFrame& frame)
// static // static
void TextSuggestionBackendImpl::Create( void TextSuggestionBackendImpl::Create(
LocalFrame* frame, LocalFrame* frame,
mojom::blink::TextSuggestionBackendRequest request) { mojo::PendingReceiver<mojom::blink::TextSuggestionBackend> receiver) {
mojo::MakeStrongBinding(std::unique_ptr<TextSuggestionBackendImpl>( mojo::MakeSelfOwnedReceiver(std::unique_ptr<TextSuggestionBackendImpl>(
new TextSuggestionBackendImpl(*frame)), new TextSuggestionBackendImpl(*frame)),
std::move(request)); std::move(receiver));
} }
void TextSuggestionBackendImpl::ApplySpellCheckSuggestion( void TextSuggestionBackendImpl::ApplySpellCheckSuggestion(
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_SUGGESTION_TEXT_SUGGESTION_BACKEND_IMPL_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_SUGGESTION_TEXT_SUGGESTION_BACKEND_IMPL_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_SUGGESTION_TEXT_SUGGESTION_BACKEND_IMPL_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_SUGGESTION_TEXT_SUGGESTION_BACKEND_IMPL_H_
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/mojom/input/input_messages.mojom-blink.h" #include "third_party/blink/public/mojom/input/input_messages.mojom-blink.h"
#include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/heap/persistent.h" #include "third_party/blink/renderer/platform/heap/persistent.h"
...@@ -17,7 +18,9 @@ class LocalFrame; ...@@ -17,7 +18,9 @@ class LocalFrame;
class CORE_EXPORT TextSuggestionBackendImpl final class CORE_EXPORT TextSuggestionBackendImpl final
: public mojom::blink::TextSuggestionBackend { : public mojom::blink::TextSuggestionBackend {
public: public:
static void Create(LocalFrame*, mojom::blink::TextSuggestionBackendRequest); static void Create(
LocalFrame*,
mojo::PendingReceiver<mojom::blink::TextSuggestionBackend>);
void ApplySpellCheckSuggestion(const String& suggestion) final; void ApplySpellCheckSuggestion(const String& suggestion) final;
void ApplyTextSuggestion(int32_t marker_tag, int32_t suggestion_index) final; void ApplyTextSuggestion(int32_t marker_tag, int32_t suggestion_index) final;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment