| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
LGTM
LGTM with nits.
if (reason == device::mojom::WakeLockReason::kOther) {nit: Perhaps we can add a comment explaining `WakeLockReason::kOther` represent requests from web content.
} else {
if (type != device::mojom::WakeLockType::kPreventDisplaySleep &&
type != device::mojom::WakeLockType::kPreventDisplaySleepAllowDimming) {
ReportBadMessageAndDeleteThis(
"Invalid WakeLockType for internal request.");
return;
}
}nit: Since `kAudioPlayback` wake locks are initiated and managed entirely browser-side (via `MediaWebContentsObserver`), the renderer has no legitimate reason to ever send a `GetWakeLock` request with `reason == WakeLockReason::kAudioPlayback`.
To minimize the attack surface, we should explicitly restrict the `else` branch to only allow `kVideoPlayback`, and trigger `ReportBadMessage` for `kAudioPlayback` or any other unexpected reasons.
Something like:
```
} else if (reason == device::mojom::WakeLockReason::kVideoPlayback) {
if (type != device::mojom::WakeLockType::kPreventDisplaySleep &&
type != device::mojom::WakeLockType::kPreventDisplaySleepAllowDimming) {
ReportBadMessageAndDeleteThis("Invalid WakeLockType for video playback.");
return;
}
} else {
ReportBadMessageAndDeleteThis("Invalid WakeLockReason.");
return;
}
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
PTAL
nit: Perhaps we can add a comment explaining `WakeLockReason::kOther` represent requests from web content.
Done
} else {
if (type != device::mojom::WakeLockType::kPreventDisplaySleep &&
type != device::mojom::WakeLockType::kPreventDisplaySleepAllowDimming) {
ReportBadMessageAndDeleteThis(
"Invalid WakeLockType for internal request.");
return;
}
}nit: Since `kAudioPlayback` wake locks are initiated and managed entirely browser-side (via `MediaWebContentsObserver`), the renderer has no legitimate reason to ever send a `GetWakeLock` request with `reason == WakeLockReason::kAudioPlayback`.
To minimize the attack surface, we should explicitly restrict the `else` branch to only allow `kVideoPlayback`, and trigger `ReportBadMessage` for `kAudioPlayback` or any other unexpected reasons.
Something like:
```
} else if (reason == device::mojom::WakeLockReason::kVideoPlayback) {
if (type != device::mojom::WakeLockType::kPreventDisplaySleep &&
type != device::mojom::WakeLockType::kPreventDisplaySleepAllowDimming) {
ReportBadMessageAndDeleteThis("Invalid WakeLockType for video playback.");
return;
}
} else {
ReportBadMessageAndDeleteThis("Invalid WakeLockReason.");
return;
}
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
+reillyg as blink wake_lock owner, to take a look that this is all sane
code search is throwing errors, so makes checking things hard, gonna try again tomorrow to see if cs is fixed
if (reason == device::mojom::WakeLockReason::kOther) {prefer to use a switch statement without default so this gets recompiled if the enum changes
if (type == device::mojom::WakeLockType::kPreventDisplaySleep) {ditto switch statement
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |