Skip to content

Commit

Permalink
ContentCapture: Fix a sender crash in corner case
Browse files Browse the repository at this point in the history
Bug: 1127082
Change-Id: I64ea0a51b703c8094e24fb473189c93f47b6217f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2406178
Commit-Queue: Tao Bai <michaelbai@chromium.org>
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806226}
  • Loading branch information
Michael Bai authored and Commit Bot committed Sep 11, 2020
1 parent 0d27609 commit 4a3d875
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions components/content_capture/renderer/content_capture_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,22 @@ void ContentCaptureSender::DidRemoveContent(blink::WebVector<int64_t> data) {
}

void ContentCaptureSender::StartCapture() {
render_frame()->GetWebFrame()->SetContentCaptureClient(this);
// The render_frame() is invalid after RenderFrameObserver::RenderFrameGone()
// called.
// Refer to crbug.com/1127082.
if (auto* rf = render_frame()) {
if (auto* web_frame = rf->GetWebFrame()) {
web_frame->SetContentCaptureClient(this);
}
}
}

void ContentCaptureSender::StopCapture() {
render_frame()->GetWebFrame()->SetContentCaptureClient(nullptr);
if (auto* rf = render_frame()) {
if (auto* web_frame = rf->GetWebFrame()) {
web_frame->SetContentCaptureClient(nullptr);
}
}
}

void ContentCaptureSender::OnDestruct() {
Expand Down

0 comments on commit 4a3d875

Please sign in to comment.