Enforce Permissions-Policy and permission checks for Screen Wake Lock [chromium/src : main]

0 views
Skip to first unread message

Hongchan Choi (Gerrit)

unread,
May 29, 2026, 5:22:44 PM (2 days ago) May 29
to Alvin Ji, Chromium LUCI CQ, chromium...@chromium.org, Raphael Kubo da Costa, mattreyno...@chromium.org
Attention needed from Alvin Ji

Hongchan Choi added 1 comment

Patchset-level comments
File-level comment, Patchset 6 (Latest):
Hongchan Choi . resolved

PTAL

Open in Gerrit

Related details

Attention is currently required from:
  • Alvin Ji
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I260c8efa828d2d5cac11b7f2929064b9c5ca2bf3
Gerrit-Change-Number: 7871829
Gerrit-PatchSet: 6
Gerrit-Owner: Hongchan Choi <hong...@chromium.org>
Gerrit-Reviewer: Alvin Ji <alv...@chromium.org>
Gerrit-Reviewer: Hongchan Choi <hong...@chromium.org>
Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
Gerrit-Attention: Alvin Ji <alv...@chromium.org>
Gerrit-Comment-Date: Fri, 29 May 2026 21:22:32 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Alvin Ji (Gerrit)

unread,
May 29, 2026, 6:00:42 PM (2 days ago) May 29
to Hongchan Choi, Chromium LUCI CQ, chromium...@chromium.org, Raphael Kubo da Costa, mattreyno...@chromium.org
Attention needed from Hongchan Choi

Alvin Ji voted and added 4 comments

Votes added by Alvin Ji

Code-Review+1

4 comments

Patchset-level comments
Alvin Ji . resolved

LGTM

Alvin Ji . resolved

LGTM with nits.

File content/browser/wake_lock/wake_lock_service_impl.cc
Line 39, Patchset 6 (Latest): if (reason == device::mojom::WakeLockReason::kOther) {
Alvin Ji . unresolved

nit: Perhaps we can add a comment explaining `WakeLockReason::kOther` represent requests from web content.

Line 68, Patchset 6 (Latest): } else {
if (type != device::mojom::WakeLockType::kPreventDisplaySleep &&
type != device::mojom::WakeLockType::kPreventDisplaySleepAllowDimming) {
ReportBadMessageAndDeleteThis(
"Invalid WakeLockType for internal request.");
return;
}
}
Alvin Ji . unresolved
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;
}
```
Open in Gerrit

Related details

Attention is currently required from:
  • Hongchan Choi
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I260c8efa828d2d5cac11b7f2929064b9c5ca2bf3
    Gerrit-Change-Number: 7871829
    Gerrit-PatchSet: 6
    Gerrit-Owner: Hongchan Choi <hong...@chromium.org>
    Gerrit-Reviewer: Alvin Ji <alv...@chromium.org>
    Gerrit-Reviewer: Hongchan Choi <hong...@chromium.org>
    Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
    Gerrit-Attention: Hongchan Choi <hong...@chromium.org>
    Gerrit-Comment-Date: Fri, 29 May 2026 22:00:26 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Hongchan Choi (Gerrit)

    unread,
    May 29, 2026, 6:17:45 PM (2 days ago) May 29
    to Bo Liu, Alvin Ji, Chromium LUCI CQ, chromium...@chromium.org, Raphael Kubo da Costa, mattreyno...@chromium.org
    Attention needed from Bo Liu

    Hongchan Choi added 3 comments

    Hongchan Choi . resolved

    PTAL

    File content/browser/wake_lock/wake_lock_service_impl.cc
    Line 39, Patchset 6: if (reason == device::mojom::WakeLockReason::kOther) {
    Alvin Ji . resolved

    nit: Perhaps we can add a comment explaining `WakeLockReason::kOther` represent requests from web content.

    Hongchan Choi

    Done


    if (type != device::mojom::WakeLockType::kPreventDisplaySleep &&
    type != device::mojom::WakeLockType::kPreventDisplaySleepAllowDimming) {
    ReportBadMessageAndDeleteThis(
    "Invalid WakeLockType for internal request.");
    return;
    }
    }
    Alvin Ji . resolved
    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;
    }
    ```
    Hongchan Choi

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Bo Liu
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I260c8efa828d2d5cac11b7f2929064b9c5ca2bf3
      Gerrit-Change-Number: 7871829
      Gerrit-PatchSet: 8
      Gerrit-Owner: Hongchan Choi <hong...@chromium.org>
      Gerrit-Reviewer: Alvin Ji <alv...@chromium.org>
      Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
      Gerrit-Reviewer: Hongchan Choi <hong...@chromium.org>
      Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
      Gerrit-Attention: Bo Liu <bo...@chromium.org>
      Gerrit-Comment-Date: Fri, 29 May 2026 22:17:31 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Alvin Ji <alv...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Bo Liu (Gerrit)

      unread,
      May 31, 2026, 10:45:59 PM (2 hours ago) May 31
      to Hongchan Choi, Reilly Grant, Bo Liu, Alvin Ji, Chromium LUCI CQ, chromium...@chromium.org, Raphael Kubo da Costa, mattreyno...@chromium.org
      Attention needed from Hongchan Choi and Reilly Grant

      Bo Liu added 3 comments

      Patchset-level comments
      Bo Liu . resolved

      +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

      File content/browser/wake_lock/wake_lock_service_impl.cc
      Line 42, Patchset 8 (Latest): if (reason == device::mojom::WakeLockReason::kOther) {
      Bo Liu . unresolved

      prefer to use a switch statement without default so this gets recompiled if the enum changes

      Line 43, Patchset 8 (Latest): if (type == device::mojom::WakeLockType::kPreventDisplaySleep) {
      Bo Liu . unresolved

      ditto switch statement

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Hongchan Choi
      • Reilly Grant
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I260c8efa828d2d5cac11b7f2929064b9c5ca2bf3
        Gerrit-Change-Number: 7871829
        Gerrit-PatchSet: 8
        Gerrit-Owner: Hongchan Choi <hong...@chromium.org>
        Gerrit-Reviewer: Alvin Ji <alv...@chromium.org>
        Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
        Gerrit-Reviewer: Hongchan Choi <hong...@chromium.org>
        Gerrit-Reviewer: Reilly Grant <rei...@chromium.org>
        Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
        Gerrit-Attention: Reilly Grant <rei...@chromium.org>
        Gerrit-Attention: Hongchan Choi <hong...@chromium.org>
        Gerrit-Comment-Date: Mon, 01 Jun 2026 02:45:46 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy
        Reply all
        Reply to author
        Forward
        0 new messages