Pop the fragment in the backstack when custom tab is active and the onCloseWindow window callback of the BrowserChromeClient is triggered #7410
+31
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Task/Issue URL: https://app.asana.com/1/137249556945/project/1211724162604201/task/1206984821130536?focus=true
Description
Custom tabs were not properly handling window closure during single sign-on flows. When an SSO flow opened a new window (which adds a fragment to the backstack), the window.close() callback from the OAuth provider would attempt to use regular browser tab logic (removing from tab repository and updating tab selection). This approach failed in custom tabs because they don't use the tab repository concept - they manage navigation through fragment backstack transactions. As a result, the SSO window remained open and prevented the login callback code from executing on the previous fragment, breaking the authentication flow.
Solution
Added custom tab-specific handling for window closure. When closeCurrentTab() is called in a custom tab context, it now triggers a fragment backstack pop operation instead of attempting repository-based tab removal. This properly closes the SSO fragment and returns to the calling fragment, allowing the authentication callback to execute correctly. Regular browser tabs continue to use the existing repository-based logic, ensuring no regression in standard tab behavior.
Steps to test this PR
Check steps in the attached task.
UI changes
No UI changes, only behavior changes.
Note
Introduce
NavigateBackInCustomTabso closing in custom tabs pops the fragment back stack rather than deleting a tab; wire it in ViewModel/Fragment and add tests.Command.NavigateBackInCustomTab.BrowserTabViewModel.closeCurrentTab()to emitNavigateBackInCustomTabwhenisCustomTabScreenis true; otherwise keep deleting the tab from repository.NavigateBackInCustomTabinBrowserTabFragmentby popping the fragment back stack when active custom tab.Written by Cursor Bugbot for commit 32d48b3. This will update automatically on new commits. Configure here.