Commit c2677085 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert SpellCheckPanel to new Mojo types

This CL converts SpellCheckPanelRequest and SpellCheckPanelPtr
in spellcheck_panel.mojom using PendingReceiver,
ReceiverSet, and Remote.

Bug: 955171
Change-Id: I145e80e71f152f6ac621299d5c2918bf174a8614
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1845131Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarTim Volodine <timvolodine@chromium.org>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#704028}
parent 1e722e37
......@@ -26,6 +26,7 @@
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/service_manager/public/cpp/interface_provider.h"
using content::RenderViewHost;
......@@ -197,9 +198,10 @@ using content::RenderViewHost;
RenderViewHost::From(renderWidgetHost_));
DCHECK(webContents && webContents->GetFocusedFrame());
spellcheck::mojom::SpellCheckPanelPtr focused_spell_check_panel_client;
mojo::Remote<spellcheck::mojom::SpellCheckPanel>
focused_spell_check_panel_client;
webContents->GetFocusedFrame()->GetRemoteInterfaces()->GetInterface(
&focused_spell_check_panel_client);
focused_spell_check_panel_client.BindNewPipeAndPassReceiver());
focused_spell_check_panel_client->AdvanceToNextMisspelling();
}
......@@ -221,9 +223,10 @@ using content::RenderViewHost;
RenderViewHost::From(renderWidgetHost_));
DCHECK(webContents && webContents->GetFocusedFrame());
spellcheck::mojom::SpellCheckPanelPtr focused_spell_check_panel_client;
mojo::Remote<spellcheck::mojom::SpellCheckPanel>
focused_spell_check_panel_client;
webContents->GetFocusedFrame()->GetRemoteInterfaces()->GetInterface(
&focused_spell_check_panel_client);
focused_spell_check_panel_client.BindNewPipeAndPassReceiver());
focused_spell_check_panel_client->ToggleSpellPanel(visible);
}
......
......@@ -74,6 +74,7 @@
#if BUILDFLAG(HAS_SPELLCHECK_PANEL)
#include "chrome/browser/spellchecker/test/spellcheck_panel_browsertest_helper.h"
#include "components/spellcheck/common/spellcheck_panel.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
#endif // BUILDFLAG(HAS_SPELLCHECK_PANEL)
#endif
......@@ -1127,9 +1128,9 @@ IN_PROC_BROWSER_TEST_F(ChromeSitePerProcessTest, OOPIFSpellCheckPanelTest) {
EXPECT_TRUE(cross_site_subframe->IsCrossProcessSubframe());
spellcheck::mojom::SpellCheckPanelPtr spell_check_panel_client;
mojo::Remote<spellcheck::mojom::SpellCheckPanel> spell_check_panel_client;
cross_site_subframe->GetRemoteInterfaces()->GetInterface(
&spell_check_panel_client);
spell_check_panel_client.BindNewPipeAndPassReceiver());
spell_check_panel_client->ToggleSpellPanel(false);
test_helper.RunUntilBind();
......
......@@ -23,7 +23,7 @@ SpellCheckPanel::SpellCheckPanel(
DCHECK(render_frame);
DCHECK(embedder_provider);
registry->AddInterface(base::BindRepeating(
&SpellCheckPanel::SpellCheckPanelRequest, base::Unretained(this)));
&SpellCheckPanel::SpellCheckPanelReceiver, base::Unretained(this)));
render_frame->GetWebFrame()->SetSpellCheckPanelHostClient(this);
}
......@@ -47,9 +47,9 @@ void SpellCheckPanel::UpdateSpellingUIWithMisspelledWord(
GetSpellCheckPanelHost()->UpdateSpellingPanelWithMisspelledWord(word.Utf16());
}
void SpellCheckPanel::SpellCheckPanelRequest(
spellcheck::mojom::SpellCheckPanelRequest request) {
bindings_.AddBinding(this, std::move(request));
void SpellCheckPanel::SpellCheckPanelReceiver(
mojo::PendingReceiver<spellcheck::mojom::SpellCheckPanel> receiver) {
receivers_.Add(this, std::move(receiver));
}
void SpellCheckPanel::AdvanceToNextMisspelling() {
......
......@@ -9,7 +9,8 @@
#include "components/spellcheck/common/spellcheck_panel.mojom.h"
#include "components/spellcheck/spellcheck_buildflags.h"
#include "content/public/renderer/render_frame_observer.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "third_party/blink/public/platform/web_spell_check_panel_host_client.h"
......@@ -40,9 +41,9 @@ class SpellCheckPanel : public content::RenderFrameObserver,
void UpdateSpellingUIWithMisspelledWord(
const blink::WebString& word) override;
// Binds browser requests for the frame SpellCheckPanel interface.
void SpellCheckPanelRequest(
spellcheck::mojom::SpellCheckPanelRequest request);
// Binds browser receivers for the frame SpellCheckPanel interface.
void SpellCheckPanelReceiver(
mojo::PendingReceiver<spellcheck::mojom::SpellCheckPanel> receiver);
// spellcheck::mojom::SpellCheckPanel:
void ToggleSpellPanel(bool visible) override;
......@@ -50,8 +51,8 @@ class SpellCheckPanel : public content::RenderFrameObserver,
spellcheck::mojom::SpellCheckPanelHostPtr GetSpellCheckPanelHost();
// SpellCheckPanel bindings.
mojo::BindingSet<spellcheck::mojom::SpellCheckPanel> bindings_;
// SpellCheckPanel receivers.
mojo::ReceiverSet<spellcheck::mojom::SpellCheckPanel> receivers_;
// True if the browser is showing the spelling panel.
bool spelling_panel_visible_;
......
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