Commit 399d9e34 authored by Kevin McNee's avatar Kevin McNee Committed by Commit Bot

Portals: Use AssociatedReceiver::ReportBadMessage

We needed to manually reset the frame host AssociatedReceiver after
reporting a bad message, since AssociatedReceiver didn't have a
ReportBadMessage until recently.

Bug: None
Change-Id: I49b13134f4dc4202d684248db4d5aa01c8fe5ad8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2514466Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Auto-Submit: Kevin McNee <mcnee@chromium.org>
Commit-Queue: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823405}
parent 309530b6
...@@ -5268,27 +5268,24 @@ void RenderFrameHostImpl::CreatePortal( ...@@ -5268,27 +5268,24 @@ void RenderFrameHostImpl::CreatePortal(
mojo::PendingAssociatedRemote<blink::mojom::PortalClient> client, mojo::PendingAssociatedRemote<blink::mojom::PortalClient> client,
CreatePortalCallback callback) { CreatePortalCallback callback) {
if (!Portal::IsEnabled()) { if (!Portal::IsEnabled()) {
mojo::ReportBadMessage( frame_host_associated_receiver_.ReportBadMessage(
"blink.mojom.Portal can only be used if the Portals feature is " "blink.mojom.Portal can only be used if the Portals feature is "
"enabled."); "enabled.");
frame_host_associated_receiver_.reset();
return; return;
} }
// We don't support attaching a portal inside a nested browsing context. // We don't support attaching a portal inside a nested browsing context.
if (!is_main_frame()) { if (!is_main_frame()) {
mojo::ReportBadMessage( frame_host_associated_receiver_.ReportBadMessage(
"RFHI::CreatePortal called in a nested browsing context"); "RFHI::CreatePortal called in a nested browsing context");
frame_host_associated_receiver_.reset();
return; return;
} }
// TODO(crbug.com/1051639): We need to find a long term solution to when/how // TODO(crbug.com/1051639): We need to find a long term solution to when/how
// portals should work in sandboxed documents. // portals should work in sandboxed documents.
if (active_sandbox_flags_ != network::mojom::WebSandboxFlags::kNone) { if (active_sandbox_flags_ != network::mojom::WebSandboxFlags::kNone) {
mojo::ReportBadMessage( frame_host_associated_receiver_.ReportBadMessage(
"RFHI::CreatePortal called in a sandboxed browsing context"); "RFHI::CreatePortal called in a sandboxed browsing context");
frame_host_associated_receiver_.reset();
return; return;
} }
...@@ -5297,8 +5294,8 @@ void RenderFrameHostImpl::CreatePortal( ...@@ -5297,8 +5294,8 @@ void RenderFrameHostImpl::CreatePortal(
// TODO(1008989): Once issue 1008989 is fixed we could move this check into // TODO(1008989): Once issue 1008989 is fixed we could move this check into
// |Portal::Create|. // |Portal::Create|.
if (!GetLastCommittedURL().SchemeIsHTTPOrHTTPS()) { if (!GetLastCommittedURL().SchemeIsHTTPOrHTTPS()) {
mojo::ReportBadMessage("Portal creation is restricted to the HTTP family."); frame_host_associated_receiver_.ReportBadMessage(
frame_host_associated_receiver_.reset(); "Portal creation is restricted to the HTTP family.");
return; return;
} }
...@@ -5323,8 +5320,8 @@ void RenderFrameHostImpl::AdoptPortal(const blink::PortalToken& portal_token, ...@@ -5323,8 +5320,8 @@ void RenderFrameHostImpl::AdoptPortal(const blink::PortalToken& portal_token,
AdoptPortalCallback callback) { AdoptPortalCallback callback) {
Portal* portal = FindPortalByToken(portal_token); Portal* portal = FindPortalByToken(portal_token);
if (!portal) { if (!portal) {
mojo::ReportBadMessage("Unknown portal_token when adopting portal."); frame_host_associated_receiver_.ReportBadMessage(
frame_host_associated_receiver_.reset(); "Unknown portal_token when adopting portal.");
return; return;
} }
DCHECK_EQ(portal->owner_render_frame_host(), this); DCHECK_EQ(portal->owner_render_frame_host(), this);
......
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