AWC window.maximize, minimize and restore promises implemented [chromium/src : main]

0 views
Skip to first unread message

Patryk Chodur (Gerrit)

unread,
Nov 4, 2025, 11:16:43 AM (2 days ago) Nov 4
to Code Review Nudger, Olga Korokhina, Andrew Rayskiy, Daniel Cheng, AyeAye, AI Code Reviewer, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-revi...@chromium.org, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, creis...@chromium.org, gavinp...@chromium.org, ipc-securi...@chromium.org, kinuko...@chromium.org, loading...@chromium.org, navigation...@chromium.org
Attention needed from Andrew Rayskiy and Olga Korokhina

Patryk Chodur added 1 comment

File third_party/blink/renderer/core/page/chrome_client_impl.cc
Line 256, Patchset 8: std::move(callback).Run(/*minimized=*/false);
Andrew Rayskiy . resolved

You're removing this branching in https://chromium-review.googlesource.com/c/chromium/src/+/7106319/1/third_party/blink/renderer/core/page/chrome_client_impl.h. Is it really necessary for the API to include true/false return values?

Patryk Chodur

After I remove the `#ifdefs` I think no. I plan to add timeouts to the callbacks which will require that, but given that it will be done in a different CL I can remove them when rebasing.

Patryk Chodur

Discussed in chat. Keeping if for now for the timeouts.

Open in Gerrit

Related details

Attention is currently required from:
  • Andrew Rayskiy
  • Olga Korokhina
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • 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: I212501e1b8f0750becdd0c9aa3a474d4bb687f5e
Gerrit-Change-Number: 7041143
Gerrit-PatchSet: 13
Gerrit-Owner: Patryk Chodur <pch...@google.com>
Gerrit-Reviewer: Andrew Rayskiy <green...@google.com>
Gerrit-Reviewer: Olga Korokhina <koro...@google.com>
Gerrit-Reviewer: Patryk Chodur <pch...@google.com>
Gerrit-CC: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
Gerrit-CC: Daniel Cheng <dch...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Andrew Rayskiy <green...@google.com>
Gerrit-Attention: Olga Korokhina <koro...@google.com>
Gerrit-Comment-Date: Tue, 04 Nov 2025 16:16:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Patryk Chodur <pch...@google.com>
Comment-In-Reply-To: Andrew Rayskiy <green...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Olga Korokhina (Gerrit)

unread,
Nov 4, 2025, 11:29:44 AM (2 days ago) Nov 4
to Patryk Chodur, Code Review Nudger, Andrew Rayskiy, Daniel Cheng, AyeAye, AI Code Reviewer, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-revi...@chromium.org, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, creis...@chromium.org, gavinp...@chromium.org, ipc-securi...@chromium.org, kinuko...@chromium.org, loading...@chromium.org, navigation...@chromium.org
Attention needed from Andrew Rayskiy and Patryk Chodur

Olga Korokhina added 1 comment

File third_party/blink/renderer/modules/awc/additional_windowing_controls.cc
Line 165, Patchset 7: "Could not restore the window."));
Olga Korokhina . resolved

Can we have a bit more of a context/reason here, f.i. "Window could not be restored due to [reason]", or this is not needed @greengrape ?

Patryk Chodur

As of now these callbacks can't really be rejected unless somebody breaks something in the code. The checks for whether the API is allowed and makes sense were earlier, for example in the `IsPermissionGranted` function.

Olga Korokhina

Got it, so we don't have a reason here, just a fact. Thank you.

Open in Gerrit

Related details

Attention is currently required from:
  • Andrew Rayskiy
  • Patryk Chodur
Gerrit-Attention: Patryk Chodur <pch...@google.com>
Gerrit-Attention: Andrew Rayskiy <green...@google.com>
Gerrit-Comment-Date: Tue, 04 Nov 2025 16:29:27 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Patryk Chodur <pch...@google.com>
Comment-In-Reply-To: Olga Korokhina <koro...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrew Rayskiy (Gerrit)

unread,
Nov 4, 2025, 11:50:10 AM (2 days ago) Nov 4
to Patryk Chodur, Code Review Nudger, Olga Korokhina, Daniel Cheng, AyeAye, AI Code Reviewer, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-revi...@chromium.org, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, creis...@chromium.org, gavinp...@chromium.org, ipc-securi...@chromium.org, kinuko...@chromium.org, loading...@chromium.org, navigation...@chromium.org
Attention needed from Olga Korokhina and Patryk Chodur

Andrew Rayskiy voted and added 4 comments

Votes added by Andrew Rayskiy

Code-Review+1

4 comments

File third_party/blink/renderer/core/exported/web_view_impl.h
Line 1032, Patchset 8: Vector<MinimizeCallback> minimize_callbacks_;
Andrew Rayskiy . resolved

Maybe use `base/callback_list.h` here? I'm not sure what the guidance here is.

Patryk Chodur

I don't see it being used in the blink code ([here](https://source.chromium.org/search?q=CallbackList%20path:blink&sq=)) whereas a `Vector` with callbacks is used in many places ([here](https://source.chromium.org/search?q=case:yes%20pcre:yes%20Vector%3C%5B%5Cw%3C%3E%5Cs:%5D%2B%5BcC%5Dallback%5Cw%2B;%20path:blink)). Besides, `CallbackList` is mostly useful for fixing lifetime issues (with the `CallbackListSubscription`), but the promise resolved in these callbacks is garbage collected, so _as far as I understand_ there's no problem.

Andrew Rayskiy

Ack!

File third_party/blink/renderer/core/frame/web_frame_widget_impl.cc
Line 1818, Patchset 13 (Latest): ui::mojom::blink::WindowShowState old_show_state = window_show_state_;
Andrew Rayskiy . unresolved

nit: I'd do a func-local `using WindowShowState = ui::mojom::blink::WindowShowState;` -- this might simplify the switch too

File third_party/blink/renderer/modules/awc/additional_windowing_controls.cc
Line 65, Patchset 13 (Latest): ui::mojom::blink::WindowShowState::kMaximized;
Andrew Rayskiy . unresolved

nit: `using ui::mojom::blink::WindowShowState` in the anon namespace

Line 110, Patchset 7: if (window->GetFrame()->GetWidgetForLocalRoot()->WindowShowState() ==
Andrew Rayskiy . resolved

(here and elsewhere) this condition is hard to read. How about an anon func?
```
bool IsMaximized(LocalDOMWindow* window) { return ... }
```

and then...
```
if (IsMaximized(window)) {
resolver->Resolve();
return;
}

// inline the callback here...

window->GetFrame()->GetChromeClient().Maximize(*window->GetFrame(),
std::move(callback));
```

Is there any sense in allowing parallel requests btw? i.e. calling minimize() while a maximize() call is in progress?

Olga Korokhina

+1, as long as there are more than 1 inclusions of this check this seems to be reasonable.

Patryk Chodur

Added the anon function and inlined the callback.

As for whether it makes sense to issue parallel requests – in general it doesn't make much sense to do it, but it's likely going to happen because:

  • this is a UI thing and we're resolving the promises when the OS changes the window state. In case of any lag the user will likely try to hit various buttons and the app will issue appropriate requests
  • the OS can ignore the requests to change the window state. What will happen right now is we'll never resolve nor reject the promise. I plan to add some timeouts, but even then we can have 2 pending promises waiting to be resolved or rejected.
Andrew Rayskiy

Acknowledged

Open in Gerrit

Related details

Attention is currently required from:
  • Olga Korokhina
  • Patryk Chodur
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: I212501e1b8f0750becdd0c9aa3a474d4bb687f5e
    Gerrit-Change-Number: 7041143
    Gerrit-PatchSet: 13
    Gerrit-Owner: Patryk Chodur <pch...@google.com>
    Gerrit-Reviewer: Andrew Rayskiy <green...@google.com>
    Gerrit-Reviewer: Olga Korokhina <koro...@google.com>
    Gerrit-Reviewer: Patryk Chodur <pch...@google.com>
    Gerrit-CC: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Attention: Patryk Chodur <pch...@google.com>
    Gerrit-Attention: Olga Korokhina <koro...@google.com>
    Gerrit-Comment-Date: Tue, 04 Nov 2025 16:49:56 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Patryk Chodur <pch...@google.com>
    Comment-In-Reply-To: Andrew Rayskiy <green...@google.com>
    Comment-In-Reply-To: Olga Korokhina <koro...@google.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Olga Korokhina (Gerrit)

    unread,
    Nov 4, 2025, 11:57:28 AM (2 days ago) Nov 4
    to Patryk Chodur, Andrew Rayskiy, Code Review Nudger, Daniel Cheng, AyeAye, AI Code Reviewer, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-revi...@chromium.org, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, creis...@chromium.org, gavinp...@chromium.org, ipc-securi...@chromium.org, kinuko...@chromium.org, loading...@chromium.org, navigation...@chromium.org
    Attention needed from Patryk Chodur

    Olga Korokhina voted Code-Review+1

    Code-Review+1
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Patryk Chodur
    Gerrit-Comment-Date: Tue, 04 Nov 2025 16:57:10 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Olga Korokhina (Gerrit)

    unread,
    Nov 4, 2025, 11:57:58 AM (2 days ago) Nov 4
    to Patryk Chodur, Andrew Rayskiy, Code Review Nudger, Daniel Cheng, AyeAye, AI Code Reviewer, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-revi...@chromium.org, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, creis...@chromium.org, gavinp...@chromium.org, ipc-securi...@chromium.org, kinuko...@chromium.org, loading...@chromium.org, navigation...@chromium.org
    Attention needed from Patryk Chodur

    Olga Korokhina added 1 comment

    Patchset-level comments
    File-level comment, Patchset 13 (Latest):
    Olga Korokhina . resolved

    +1 after tests fixed.

    Gerrit-Comment-Date: Tue, 04 Nov 2025 16:57:44 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Patryk Chodur (Gerrit)

    unread,
    Nov 4, 2025, 12:57:25 PM (2 days ago) Nov 4
    to Olga Korokhina, Andrew Rayskiy, Code Review Nudger, Daniel Cheng, AyeAye, AI Code Reviewer, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-revi...@chromium.org, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, creis...@chromium.org, gavinp...@chromium.org, ipc-securi...@chromium.org, kinuko...@chromium.org, loading...@chromium.org, navigation...@chromium.org

    Patryk Chodur added 2 comments

    File third_party/blink/renderer/core/frame/web_frame_widget_impl.cc
    Line 1818, Patchset 13: ui::mojom::blink::WindowShowState old_show_state = window_show_state_;
    Andrew Rayskiy . resolved

    nit: I'd do a func-local `using WindowShowState = ui::mojom::blink::WindowShowState;` -- this might simplify the switch too

    Patryk Chodur

    Done

    File third_party/blink/renderer/modules/awc/additional_windowing_controls.cc
    Line 65, Patchset 13: ui::mojom::blink::WindowShowState::kMaximized;
    Andrew Rayskiy . resolved

    nit: `using ui::mojom::blink::WindowShowState` in the anon namespace

    Patryk Chodur

    Done

    Open in Gerrit

    Related details

    Attention set is empty
    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: I212501e1b8f0750becdd0c9aa3a474d4bb687f5e
      Gerrit-Change-Number: 7041143
      Gerrit-PatchSet: 14
      Gerrit-Owner: Patryk Chodur <pch...@google.com>
      Gerrit-Reviewer: Andrew Rayskiy <green...@google.com>
      Gerrit-Reviewer: Olga Korokhina <koro...@google.com>
      Gerrit-Reviewer: Patryk Chodur <pch...@google.com>
      Gerrit-CC: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
      Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
      Gerrit-CC: Daniel Cheng <dch...@chromium.org>
      Gerrit-CC: Nate Chapin <jap...@chromium.org>
      Gerrit-Comment-Date: Tue, 04 Nov 2025 17:57:06 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Andrew Rayskiy <green...@google.com>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Mike Wasserman (Gerrit)

      unread,
      Nov 5, 2025, 1:44:16 PM (19 hours ago) Nov 5
      to Patryk Chodur, Olga Korokhina, Andrew Rayskiy, Code Review Nudger, Daniel Cheng, AyeAye, AI Code Reviewer, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-revi...@chromium.org, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, creis...@chromium.org, gavinp...@chromium.org, ipc-securi...@chromium.org, kinuko...@chromium.org, loading...@chromium.org, navigation...@chromium.org
      Attention needed from Patryk Chodur

      Mike Wasserman added 6 comments

      File chrome/browser/ui/views/web_apps/frame_toolbar/web_app_frame_toolbar_browsertest.cc
      Line 2340, Patchset 15 (Latest): const char restore_script[] =
      Mike Wasserman . unresolved

      optional nit: extract shared script string literals or test helper methods

      I suggest a helper that takes the API method name and expected state, e.g.:
      ```
      EvalJsResult EvalDisplayStateChange(
      const ToRenderFrameHost& execution_target,
      std::string_view window_method,
      std::string_view expected_state) {
      const char script[] =
      R"(new Promise((resolve, reject) => {
      window.$1().then(() => {
      if (window.matchMedia('(display-state: $2)').matches) {
      resolve('window.$1() succeeded.');
      } else {
      reject('window.$1() resolved, but ' +
      '`display-state: $2` not matched.');
      }
      }).catch(() => reject('window.$1() rejected.'));
      });)";
      return content::EvalJs(web_contents, content::JsReplace(script, window_method, expected_state));
      ```
      File third_party/blink/renderer/core/exported/web_view_impl.h
      Line 616, Patchset 15 (Latest): void WasMinimized();
      Mike Wasserman . unresolved

      Consider adding a single `OnWindowShowStateChanged(ui::mojom::blink::WindowShowState)` instead.

      File third_party/blink/renderer/core/exported/web_view_impl.cc
      Line 3191, Patchset 15 (Latest): for (auto& callback : callbacks) {
      Mike Wasserman . unresolved

      This is a great improvement over the initial impl, thank you.

      Still, this won't work really well when a sequence of JS methods are invoked, then promises are resolved out of order e.g. `m1 = minimize(); r1 = restore(); m2 = minimize();` m2 will resolve when the first minimize() completes, potentially before the window is restored and minimized a second time.

      Getting this right depends on how requests are issued to the WM (looks like we don't currently queue requests internally, we just issue them to the WM directly) and how the underlying WM handles our requests. If the WM treats requests in a FIFO queue, we could probably keep a single ordered list of all callbacks (with an associated type), and resolve everything at the front of the queue matching the state surfaced here.

      Getting this correct wouldn't be easy, so API spec/docs should explain what behavior clients can expect.

      Maybe rejecting requests when another request is in flight would yield a simpler and more reliable impl?

      File third_party/blink/renderer/core/frame/web_frame_widget_impl.cc
      Line 1878, Patchset 15 (Latest): if (old_show_state != window_show_state_) {
      Mike Wasserman . unresolved

      There's no clear request denial signal at this layer, right? If so, when the WM silently ignores a request, the JS promise will hang indefinitely. I wonder if the promises should reject with some timeout? (e.g. no window state change in 3s?). Again, we don't need a perfect impl, but having something well documented and reliable would be great.

      Line 1889, Patchset 15 (Latest): if (old_show_state == WindowShowState::kMinimized ||
      old_show_state == WindowShowState::kFullscreen) {
      // We cannot reliably tell whether the change was caused by restoring
      // the window or maximizing it.
      View()->WasRestored();
      }
      Mike Wasserman . unresolved

      Clients like WebViewImpl would be better served be a single notification of window state change (as I suggested above). Then WebViewImpl can decide how to resolve its own callbacks from the clearest underlying signals, not from potentially ambiguous interpretations encapsulated here.

      File third_party/blink/renderer/modules/awc/additional_windowing_controls.cc
      Line 112, Patchset 15 (Latest): const String& error_message, bool maximized) {
      Mike Wasserman . unresolved
      This represents success for any of the operations, not just maximized
      ```suggestion
      const String& error_message, bool result) {
      ```
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Patryk Chodur
      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: I212501e1b8f0750becdd0c9aa3a474d4bb687f5e
        Gerrit-Change-Number: 7041143
        Gerrit-PatchSet: 15
        Gerrit-Owner: Patryk Chodur <pch...@google.com>
        Gerrit-Reviewer: Andrew Rayskiy <green...@google.com>
        Gerrit-Reviewer: Mike Wasserman <m...@chromium.org>
        Gerrit-Reviewer: Olga Korokhina <koro...@google.com>
        Gerrit-Reviewer: Patryk Chodur <pch...@google.com>
        Gerrit-CC: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-CC: Daniel Cheng <dch...@chromium.org>
        Gerrit-CC: Nate Chapin <jap...@chromium.org>
        Gerrit-Attention: Patryk Chodur <pch...@google.com>
        Gerrit-Comment-Date: Wed, 05 Nov 2025 18:44:06 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy
        Reply all
        Reply to author
        Forward
        0 new messages