Commit 290c9292 authored by Tao Bai's avatar Tao Bai Committed by Commit Bot

Fix a crash of null ContentCaptureReceiver

Check if ContentCaptureReceiver is valid before start capture.
Also, add a DCHECK() to the other call site of
ContentCaptureReceiverForFrame().

Bug: 1029678
Change-Id: Iaed486b6a7e9b322174e06fc0469defd5babb2c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1947284Reviewed-by: default avatarChangwan Ryu <changwan@chromium.org>
Commit-Queue: Tao Bai <michaelbai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720729}
parent f7ab2ada
......@@ -87,14 +87,15 @@ void ContentCaptureReceiverManager::RenderFrameDeleted(
void ContentCaptureReceiverManager::ReadyToCommitNavigation(
content::NavigationHandle* navigation_handle) {
auto* receiver =
ContentCaptureReceiverForFrame(navigation_handle->GetRenderFrameHost());
if (web_contents()->GetBrowserContext()->IsOffTheRecord() ||
!ShouldCapture(navigation_handle->GetURL())) {
receiver->StopCapture();
return;
if (auto* receiver = ContentCaptureReceiverForFrame(
navigation_handle->GetRenderFrameHost())) {
if (web_contents()->GetBrowserContext()->IsOffTheRecord() ||
!ShouldCapture(navigation_handle->GetURL())) {
receiver->StopCapture();
return;
}
receiver->StartCapture();
}
receiver->StartCapture();
}
void ContentCaptureReceiverManager::DidCaptureContent(
......@@ -159,6 +160,7 @@ void ContentCaptureReceiverManager::BuildContentCaptureSession(
if (!receiver) {
RenderFrameCreated(rfh);
receiver = ContentCaptureReceiverForFrame(rfh);
DCHECK(receiver);
}
session->push_back(receiver->GetFrameContentCaptureData());
rfh = receiver->rfh()->GetParent();
......
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