0

fixes two restore bugs with windows with titles

1. If a window with a single tab has a user supplied title,
   when closing we shouldn't add the tab. Instead we should
   add the window. Adding the tab means we lose the title.
2. SessionService::WindowOpened should set the user title.
   Otherwise it won't be saved.

Bug: None
Test: None
Change-Id: Ia2bef8a6a655eeffe5f417f5366d2a29975d8ecf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5763166
Reviewed-by: Elly FJ <ellyjones@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1338487}
This commit is contained in:
Scott Violet
2024-08-07 15:26:57 +00:00
committed by Chromium LUCI CQ
parent f7992b62bf
commit db85e2b6ff
2 changed files with 3 additions and 1 deletions
chrome/browser/sessions
components/sessions/core

@ -358,6 +358,7 @@ void SessionService::WindowOpened(Browser* browser) {
RestoreIfNecessary(StartupTabs(), browser, /* restore_apps */ false);
SetWindowType(browser->session_id(), browser->type());
SetWindowAppName(browser->session_id(), browser->app_name());
SetWindowUserTitle(browser->session_id(), browser->user_title());
// Save a browser workspace after window is created in `Browser()`.
// Bento desks restore feature in ash requires this line to restore correctly

@ -233,7 +233,8 @@ void TabRestoreServiceHelper::BrowserClosing(LiveTabContext* context) {
window->tabs.push_back(std::move(tab));
}
if (window->tabs.size() == 1 && window->app_name.empty()) {
if (window->tabs.size() == 1 && window->app_name.empty() &&
window->user_title.empty()) {
// Short-circuit creating a Window if only 1 tab was present. This fixes
// http://crbug.com/56744.
AddEntry(std::move(window->tabs[0]), true, true);