Consolidate common logic in DefaultBrowserSurfaceManager [chromium/src : main]

0 views
Skip to first unread message

Foromo Daniel Soromou (Gerrit)

unread,
Mar 2, 2026, 2:11:33 PM (yesterday) Mar 2
to Kaan Alsan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, fuzzin...@chromium.org, penghuan...@chromium.org, cblume...@chromium.org, chrome-intelligence-te...@google.com, net-r...@chromium.org, chrome-intell...@chromium.org, devtools...@chromium.org, nicolas...@chromium.org, ydago...@chromium.org
Attention needed from Kaan Alsan

Foromo Daniel Soromou voted and added 1 comment

Votes added by Foromo Daniel Soromou

Commit-Queue+1

1 comment

File chrome/browser/ui/startup/default_browser_prompt/default_browser_infobar_manager.cc
Line 68, Patchset 2: // tabs, so we don't need to do anything here for new browsers.
Foromo Daniel Soromou . resolved

This comment is slightly misleading. `Init()` handles browsers that exist when `Show()` is called. For browsers created after that, the `BrowserTabStripTracker` will observe them and add infobars as needed.

Suggestion:
```cpp
// The BrowserTabStripTracker will handle showing infobars for both existing
// and newly created browsers, so we don't need to do anything here.
```

Open in Gerrit

Related details

Attention is currently required from:
  • Kaan Alsan
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement 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: Ie19c05347c49cebb0a4afaa3928fcc2a5fd38ad3
Gerrit-Change-Number: 7624163
Gerrit-PatchSet: 6
Gerrit-Owner: Foromo Daniel Soromou <koreta...@chromium.org>
Gerrit-Reviewer: Foromo Daniel Soromou <koreta...@chromium.org>
Gerrit-Reviewer: Kaan Alsan <al...@chromium.org>
Gerrit-Attention: Kaan Alsan <al...@chromium.org>
Gerrit-Comment-Date: Mon, 02 Mar 2026 19:11:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Kaan Alsan (Gerrit)

unread,
Mar 2, 2026, 4:18:22 PM (22 hours ago) Mar 2
to Foromo Daniel Soromou, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, fuzzin...@chromium.org, penghuan...@chromium.org, cblume...@chromium.org, chrome-intelligence-te...@google.com, net-r...@chromium.org, chrome-intell...@chromium.org, devtools...@chromium.org, nicolas...@chromium.org, ydago...@chromium.org
Attention needed from Foromo Daniel Soromou

Kaan Alsan added 8 comments

File chrome/browser/ui/startup/default_browser_prompt/default_browser_infobar_manager.cc
Line 144, Patchset 6 (Latest):bool DefaultBrowserInfoBarManager::ShouldTrackBrowser(
Kaan Alsan . unresolved

could we replace this with DefaultBrowserSurfaceManager::IsBrowserValidForShowing

File chrome/browser/ui/startup/default_browser_prompt/default_browser_surface_manager.h
Line 70, Patchset 6 (Latest): // BrowserCollectionObserver:
void OnBrowserCreated(BrowserWindowInterface* browser) override;
void OnBrowserClosed(BrowserWindowInterface* browser) override;
Kaan Alsan . unresolved

These should be public, since we're using public inheritance.

Line 67, Patchset 6 (Latest): bool can_pin_to_taskbar_ = false;
Kaan Alsan . unresolved

Let's make this private and expose a getter method instead, so that child classes cannot modify this. We can consider adding a setter later if needed. Same for `controller_`.

Line 57, Patchset 6 (Latest): virtual void CloseAllUI() = 0;
Kaan Alsan . unresolved

supernit: "UI" sounds ambiguous: the first question that comes to mind is if this includes all UI for default browser, or just this surface. Perhaps `CloseAllSurfaceInstances` or something like that?

Line 51, Patchset 6 (Latest): virtual void ShowUIForBrowser(BrowserWindowInterface* browser) = 0;
Kaan Alsan . unresolved

supernit: Show/CloseForBrowser seems sufficient

Line 47, Patchset 6 (Latest): protected:
Kaan Alsan . unresolved

Are these methods called by any of the derived classes? If not, let's make them private

File chrome/browser/ui/startup/default_browser_prompt/default_browser_surface_manager.cc
Line 19, Patchset 6 (Latest): std::unique_ptr<default_browser::DefaultBrowserController> controller,
Kaan Alsan . unresolved

Could we instead create the controller within this method and destroy it in another method from this class so that the lifecycle is completely encapsulated?

Line 26, Patchset 6 (Latest): controller_->OnShown();
Kaan Alsan . unresolved

It might be a bit confusing that only a subset of actions are forwarded to the controller, which can skew data if a derived class forgets about the controller.

I think it would be cleaner/more consistent if either this class handles 100% of the interactions with controller (allowing us to hide it from derived classes), or handles none of the interactions. I have a slight preference for the first option, which would behave nicely with my previous comment.

Open in Gerrit

Related details

Attention is currently required from:
  • Foromo Daniel Soromou
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement 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: Ie19c05347c49cebb0a4afaa3928fcc2a5fd38ad3
    Gerrit-Change-Number: 7624163
    Gerrit-PatchSet: 6
    Gerrit-Owner: Foromo Daniel Soromou <koreta...@chromium.org>
    Gerrit-Reviewer: Foromo Daniel Soromou <koreta...@chromium.org>
    Gerrit-Reviewer: Kaan Alsan <al...@chromium.org>
    Gerrit-Attention: Foromo Daniel Soromou <koreta...@chromium.org>
    Gerrit-Comment-Date: Mon, 02 Mar 2026 21:18:16 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Foromo Daniel Soromou (Gerrit)

    unread,
    Mar 2, 2026, 8:48:27 PM (18 hours ago) Mar 2
    to Kaan Alsan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, fuzzin...@chromium.org, penghuan...@chromium.org, cblume...@chromium.org, chrome-intelligence-te...@google.com, net-r...@chromium.org, chrome-intell...@chromium.org, devtools...@chromium.org, nicolas...@chromium.org, ydago...@chromium.org
    Attention needed from Kaan Alsan

    Foromo Daniel Soromou added 8 comments

    File chrome/browser/ui/startup/default_browser_prompt/default_browser_infobar_manager.cc
    Line 144, Patchset 6:bool DefaultBrowserInfoBarManager::ShouldTrackBrowser(
    Kaan Alsan . resolved

    could we replace this with DefaultBrowserSurfaceManager::IsBrowserValidForShowing

    Foromo Daniel Soromou

    Done

    File chrome/browser/ui/startup/default_browser_prompt/default_browser_surface_manager.h
    Line 70, Patchset 6: // BrowserCollectionObserver:

    void OnBrowserCreated(BrowserWindowInterface* browser) override;
    void OnBrowserClosed(BrowserWindowInterface* browser) override;
    Kaan Alsan . resolved

    These should be public, since we're using public inheritance.

    Foromo Daniel Soromou

    Done

    Line 67, Patchset 6: bool can_pin_to_taskbar_ = false;
    Kaan Alsan . resolved

    Let's make this private and expose a getter method instead, so that child classes cannot modify this. We can consider adding a setter later if needed. Same for `controller_`.

    Foromo Daniel Soromou

    Done

    Line 57, Patchset 6: virtual void CloseAllUI() = 0;
    Kaan Alsan . resolved

    supernit: "UI" sounds ambiguous: the first question that comes to mind is if this includes all UI for default browser, or just this surface. Perhaps `CloseAllSurfaceInstances` or something like that?

    Foromo Daniel Soromou

    Done

    Line 51, Patchset 6: virtual void ShowUIForBrowser(BrowserWindowInterface* browser) = 0;
    Kaan Alsan . resolved

    supernit: Show/CloseForBrowser seems sufficient

    Foromo Daniel Soromou

    Done

    Kaan Alsan . unresolved

    Are these methods called by any of the derived classes? If not, let's make them private

    Foromo Daniel Soromou

    They are implemented by the derived classes. That is why it should be at least protected since derived classes cannot implement private methods from parent class.

    File chrome/browser/ui/startup/default_browser_prompt/default_browser_surface_manager.cc
    Line 19, Patchset 6: std::unique_ptr<default_browser::DefaultBrowserController> controller,
    Kaan Alsan . resolved

    Could we instead create the controller within this method and destroy it in another method from this class so that the lifecycle is completely encapsulated?

    Foromo Daniel Soromou

    Done

    Line 26, Patchset 6: controller_->OnShown();
    Kaan Alsan . resolved

    It might be a bit confusing that only a subset of actions are forwarded to the controller, which can skew data if a derived class forgets about the controller.

    I think it would be cleaner/more consistent if either this class handles 100% of the interactions with controller (allowing us to hide it from derived classes), or handles none of the interactions. I have a slight preference for the first option, which would behave nicely with my previous comment.

    Foromo Daniel Soromou

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Kaan Alsan
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement 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: Ie19c05347c49cebb0a4afaa3928fcc2a5fd38ad3
    Gerrit-Change-Number: 7624163
    Gerrit-PatchSet: 10
    Gerrit-Owner: Foromo Daniel Soromou <koreta...@chromium.org>
    Gerrit-Reviewer: Foromo Daniel Soromou <koreta...@chromium.org>
    Gerrit-Reviewer: Kaan Alsan <al...@chromium.org>
    Gerrit-Attention: Kaan Alsan <al...@chromium.org>
    Gerrit-Comment-Date: Tue, 03 Mar 2026 01:48:20 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Kaan Alsan <al...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Kaan Alsan (Gerrit)

    unread,
    9:32 AM (5 hours ago) 9:32 AM
    to Foromo Daniel Soromou, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, fuzzin...@chromium.org, penghuan...@chromium.org, cblume...@chromium.org, chrome-intelligence-te...@google.com, net-r...@chromium.org, chrome-intell...@chromium.org, devtools...@chromium.org, nicolas...@chromium.org, ydago...@chromium.org
    Attention needed from Foromo Daniel Soromou

    Kaan Alsan voted and added 2 comments

    Votes added by Kaan Alsan

    Code-Review+1

    2 comments

    Patchset-level comments
    File-level comment, Patchset 10 (Latest):
    Kaan Alsan . resolved

    lgtm % making the pure virtual methods private

    File chrome/browser/ui/startup/default_browser_prompt/default_browser_surface_manager.h
    Kaan Alsan . unresolved

    Are these methods called by any of the derived classes? If not, let's make them private

    Foromo Daniel Soromou

    They are implemented by the derived classes. That is why it should be at least protected since derived classes cannot implement private methods from parent class.

    Kaan Alsan

    Child classes can implement private methods from the parent class. By making it private, we're essentially saying "the child class should implement this, but only the base class will invoke it".

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Foromo Daniel Soromou
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement 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: Ie19c05347c49cebb0a4afaa3928fcc2a5fd38ad3
      Gerrit-Change-Number: 7624163
      Gerrit-PatchSet: 10
      Gerrit-Owner: Foromo Daniel Soromou <koreta...@chromium.org>
      Gerrit-Reviewer: Foromo Daniel Soromou <koreta...@chromium.org>
      Gerrit-Reviewer: Kaan Alsan <al...@chromium.org>
      Gerrit-Attention: Foromo Daniel Soromou <koreta...@chromium.org>
      Gerrit-Comment-Date: Tue, 03 Mar 2026 14:32:24 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Kaan Alsan <al...@chromium.org>
      Comment-In-Reply-To: Foromo Daniel Soromou <koreta...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Foromo Daniel Soromou (Gerrit)

      unread,
      9:46 AM (5 hours ago) 9:46 AM
      to Kaan Alsan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, fuzzin...@chromium.org, penghuan...@chromium.org, cblume...@chromium.org, chrome-intelligence-te...@google.com, net-r...@chromium.org, chrome-intell...@chromium.org, devtools...@chromium.org, nicolas...@chromium.org, ydago...@chromium.org

      Foromo Daniel Soromou added 1 comment

      File chrome/browser/ui/startup/default_browser_prompt/default_browser_surface_manager.h
      Kaan Alsan . resolved

      Are these methods called by any of the derived classes? If not, let's make them private

      Foromo Daniel Soromou

      They are implemented by the derived classes. That is why it should be at least protected since derived classes cannot implement private methods from parent class.

      Kaan Alsan

      Child classes can implement private methods from the parent class. By making it private, we're essentially saying "the child class should implement this, but only the base class will invoke it".

      Foromo Daniel Soromou

      Oh got it, Thank you for the clarification.

      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement 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: Ie19c05347c49cebb0a4afaa3928fcc2a5fd38ad3
        Gerrit-Change-Number: 7624163
        Gerrit-PatchSet: 11
        Gerrit-Owner: Foromo Daniel Soromou <koreta...@chromium.org>
        Gerrit-Reviewer: Foromo Daniel Soromou <koreta...@chromium.org>
        Gerrit-Reviewer: Kaan Alsan <al...@chromium.org>
        Gerrit-Comment-Date: Tue, 03 Mar 2026 14:46:06 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        open
        diffy

        Foromo Daniel Soromou (Gerrit)

        unread,
        10:05 AM (5 hours ago) 10:05 AM
        to Kaan Alsan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, fuzzin...@chromium.org, penghuan...@chromium.org, cblume...@chromium.org, chrome-intelligence-te...@google.com, net-r...@chromium.org, chrome-intell...@chromium.org, devtools...@chromium.org, nicolas...@chromium.org, ydago...@chromium.org

        Foromo Daniel Soromou voted Commit-Queue+2

        Commit-Queue+2
        Open in Gerrit

        Related details

        Attention set is empty
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement 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: Ie19c05347c49cebb0a4afaa3928fcc2a5fd38ad3
        Gerrit-Change-Number: 7624163
        Gerrit-PatchSet: 11
        Gerrit-Owner: Foromo Daniel Soromou <koreta...@chromium.org>
        Gerrit-Reviewer: Foromo Daniel Soromou <koreta...@chromium.org>
        Gerrit-Reviewer: Kaan Alsan <al...@chromium.org>
        Gerrit-Comment-Date: Tue, 03 Mar 2026 15:05:05 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        open
        diffy

        Chromium LUCI CQ (Gerrit)

        unread,
        11:13 AM (3 hours ago) 11:13 AM
        to Foromo Daniel Soromou, Kaan Alsan, AyeAye, chromium...@chromium.org, fuzzin...@chromium.org, penghuan...@chromium.org, cblume...@chromium.org, chrome-intelligence-te...@google.com, net-r...@chromium.org, chrome-intell...@chromium.org, devtools...@chromium.org, nicolas...@chromium.org, ydago...@chromium.org

        Chromium LUCI CQ submitted the change with unreviewed changes

        Unreviewed changes

        10 is the latest approved patch-set.
        The change was submitted with unreviewed changes in the following files:

        ```
        The name of the file: chrome/browser/ui/startup/default_browser_prompt/default_browser_surface_manager.h
        Insertions: 10, Deletions: 10.

        @@ -49,6 +49,16 @@
        bool can_pin_to_taskbar() const { return can_pin_to_taskbar_; }

        protected:
        + // Helper function to determine if a browser window is suitable for showing a
        + // prompt. Excludes incognito, guest, and non-normal browser windows.
        + bool IsBrowserValidForShowing(BrowserWindowInterface* browser);
        +
        + // Methods for derived classes to handle user interactions via the controller.
        + void HandleAccept();
        + void HandleDismiss();
        + void HandleIgnore();
        +
        + private:
        // Abstract methods to be implemented by subclasses to handle UI operations.
        //
        // Shows the specific prompt UI for the given browser window.
        @@ -60,16 +70,6 @@
        // Closes all prompt instances managed by the subclass.
        virtual void CloseAllPromptInstances() = 0;

        - // Helper function to determine if a browser window is suitable for showing a
        - // prompt. Excludes incognito, guest, and non-normal browser windows.
        - bool IsBrowserValidForShowing(BrowserWindowInterface* browser);
        -
        - // Methods for derived classes to handle user interactions via the controller.
        - void HandleAccept();
        - void HandleDismiss();
        - void HandleIgnore();
        -
        - private:
        // Flag indicating if the taskbar pinning option should be available.
        bool can_pin_to_taskbar_ = false;

        ```

        Change information

        Commit message:
        Consolidate common logic in DefaultBrowserSurfaceManager

        This refactoring transforms `DefaultBrowserSurfaceManager` from an
        interface into an abstract base class to handle shared functionality for
        different default browser prompt types.

        Previously, `DefaultBrowserBubbleDialogManager` and
        `DefaultBrowserInfoBarManager` duplicated logic for observing browser
        window creation and destruction, managing the
        `DefaultBrowserController`, and tracking the `can_pin_to_taskbar` state.
        With the upcoming `DefaultBrowserModalDialogManager` more code will be
        duplicated.

        This change centralizes that logic within the base class by:
        * Moving `BrowserCollectionObserver` inheritance and related lifecycle
        management to `DefaultBrowserSurfaceManager`.
        * Providing a shared `IsBrowserValidForShowing` helper to exclude
        incognito, guest, and non-normal browser windows consistently.
        * Introducing abstract methods (`ShowUIForBrowser`,
        `CloseUIForBrowser`, and `CloseAllUI`) that subclasses must
        implement for their specific UI presentation logic.

        Consolidating this logic reduces code duplication and simplifies the
        concrete implementations, ensuring a unified approach to displaying
        default browser prompts across the application.
        Bug: 454596623
        Change-Id: Ie19c05347c49cebb0a4afaa3928fcc2a5fd38ad3
        Reviewed-by: Kaan Alsan <al...@chromium.org>
        Commit-Queue: Foromo Daniel Soromou <koreta...@chromium.org>
        Cr-Commit-Position: refs/heads/main@{#1593255}
        Files:
        • M chrome/browser/ui/startup/default_browser_prompt/BUILD.gn
        • M chrome/browser/ui/startup/default_browser_prompt/default_browser_bubble_dialog_interactive_uitest.cc
        • M chrome/browser/ui/startup/default_browser_prompt/default_browser_bubble_dialog_manager.cc
        • M chrome/browser/ui/startup/default_browser_prompt/default_browser_bubble_dialog_manager.h
        • M chrome/browser/ui/startup/default_browser_prompt/default_browser_infobar_manager.cc
        • M chrome/browser/ui/startup/default_browser_prompt/default_browser_infobar_manager.h
        • M chrome/browser/ui/startup/default_browser_prompt/default_browser_prompt_manager.cc
        • A chrome/browser/ui/startup/default_browser_prompt/default_browser_surface_manager.cc
        • M chrome/browser/ui/startup/default_browser_prompt/default_browser_surface_manager.h
        Change size: L
        Delta: 9 files changed, 212 insertions(+), 150 deletions(-)
        Branch: refs/heads/main
        Submit Requirements:
        • requirement satisfiedCode-Review: +1 by Kaan Alsan
        Open in Gerrit
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: merged
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Ie19c05347c49cebb0a4afaa3928fcc2a5fd38ad3
        Gerrit-Change-Number: 7624163
        Gerrit-PatchSet: 12
        Gerrit-Owner: Foromo Daniel Soromou <koreta...@chromium.org>
        Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
        Gerrit-Reviewer: Foromo Daniel Soromou <koreta...@chromium.org>
        Gerrit-Reviewer: Kaan Alsan <al...@chromium.org>
        open
        diffy
        satisfied_requirement
        Reply all
        Reply to author
        Forward
        0 new messages