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( ...@@ -87,14 +87,15 @@ void ContentCaptureReceiverManager::RenderFrameDeleted(
void ContentCaptureReceiverManager::ReadyToCommitNavigation( void ContentCaptureReceiverManager::ReadyToCommitNavigation(
content::NavigationHandle* navigation_handle) { content::NavigationHandle* navigation_handle) {
auto* receiver = if (auto* receiver = ContentCaptureReceiverForFrame(
ContentCaptureReceiverForFrame(navigation_handle->GetRenderFrameHost()); navigation_handle->GetRenderFrameHost())) {
if (web_contents()->GetBrowserContext()->IsOffTheRecord() || if (web_contents()->GetBrowserContext()->IsOffTheRecord() ||
!ShouldCapture(navigation_handle->GetURL())) { !ShouldCapture(navigation_handle->GetURL())) {
receiver->StopCapture(); receiver->StopCapture();
return; return;
}
receiver->StartCapture();
} }
receiver->StartCapture();
} }
void ContentCaptureReceiverManager::DidCaptureContent( void ContentCaptureReceiverManager::DidCaptureContent(
...@@ -159,6 +160,7 @@ void ContentCaptureReceiverManager::BuildContentCaptureSession( ...@@ -159,6 +160,7 @@ void ContentCaptureReceiverManager::BuildContentCaptureSession(
if (!receiver) { if (!receiver) {
RenderFrameCreated(rfh); RenderFrameCreated(rfh);
receiver = ContentCaptureReceiverForFrame(rfh); receiver = ContentCaptureReceiverForFrame(rfh);
DCHECK(receiver);
} }
session->push_back(receiver->GetFrameContentCaptureData()); session->push_back(receiver->GetFrameContentCaptureData());
rfh = receiver->rfh()->GetParent(); 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