Fix a crash in OutputProtectionDelegate
OutputProtectionDelegate is not owned by ash. It is created
by Chrome via OutputProtectionImpl, which can invoke its
delegate even after ash::Shell instance has been destroyed.
This CL fixes this issue.
Fixed: b:256706119
Change-Id: I7005467a5e1ab4893340ca97eb20401af6ace590
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3995522
Reviewed-by: James Cook <jamescook@chromium.org>
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1065988}
diff --git a/ash/display/output_protection_delegate.cc b/ash/display/output_protection_delegate.cc
index 2ad374d8..eab160b 100644
--- a/ash/display/output_protection_delegate.cc
+++ b/ash/display/output_protection_delegate.cc
@@ -23,6 +23,12 @@
void MaybeSetCaptureModeWindowProtection(aura::Window* window,
uint32_t protection_mask) {
+ // `OutputProtectionDelegate` is not owned by ash. It is created by
+ // `OutputProtectionImpl` which exists in Chrome, and can invoke the delegate
+ // even after `Shell` has been destroyed. See b/256706119.
+ if (!Shell::HasInstance())
+ return;
+
CaptureModeController::Get()->SetWindowProtectionMask(window,
protection_mask);
}