0

Guard access to ContentClient in occlusion checker of Mac

Ensure that `performOcclusionStateUpdates` and `setWebContentsVisibility` check if content::GetContentClient() is nullptr before proceeding. Add necessary safeguards to prevent the crash when content::GetContentClient() is nullptr.

Bug: 385901565
Change-Id: I336982157f115517343db38223e4aabdcb6afa89
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6110550
Reviewed-by: Leonard Grey <lgrey@chromium.org>
Reviewed-by: Leon Han <shulianghan@microsoft.com>
Commit-Queue: Lichen Liu <lichenliu@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1403344}
This commit is contained in:
Lichen Liu
2025-01-07 17:48:18 -08:00
committed by Chromium LUCI CQ
parent 5b190d6ce5
commit cfe5f9292d
2 changed files with 17 additions and 5 deletions

@ -383,8 +383,12 @@ bool IsBrowserProcess() {
- (void)performOcclusionStateUpdates {
_occlusionStateUpdatesAreScheduled = NO;
if (content::GetContentClient()->browser() &&
content::GetContentClient()->browser()->IsShuttingDown()) {
auto* content_client = content::GetContentClient();
if (!content_client) {
return;
}
auto* browser = content_client->browser();
if (browser && browser->IsShuttingDown()) {
return;
}

@ -403,10 +403,18 @@ STATIC_ASSERT_ENUM(NSDragOperationMove, ui::DragDropTypes::DRAG_MOVE);
}
- (void)setWebContentsVisibility:(remote_cocoa::mojom::Visibility)visibility {
if (_host && !(content::GetContentClient()->browser() &&
content::GetContentClient()->browser()->IsShuttingDown())) {
_host->OnWindowVisibilityChanged(visibility);
if (!_host) {
return;
}
auto* content_client = content::GetContentClient();
if (!content_client) {
return;
}
auto* browser = content_client->browser();
if (browser && browser->IsShuttingDown()) {
return;
}
_host->OnWindowVisibilityChanged(visibility);
}
- (void)performDelayedSetWebContentsOccluded {