Activate proper tab on restoring window from session
This fixes a regression introduced in https://chromium-review.googlesource.com/c/chromium/src/+/5460410 TabRestoreServiceHelper is saving selected_tab_index in TabRestoreServiceHelper::BrowserClosing() but the saved index wasn't used later and TabRestoreServiceHelper was always activating the first tab when the whole window was restored. This CL adds a test TabRestoreTest.RestoreWindow_ActiveTabIndex that verifies that the active tab is still active after closing and restoring the window. Bug: 344606398 Change-Id: I6c3262a465b8d902a4ba9a7213fdad6142a38723 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5594032 Commit-Queue: Tomasz Moniuszko <tmoniuszko@opera.com> Reviewed-by: Scott Violet <sky@chromium.org> Reviewed-by: Darryl James <dljames@chromium.org> Cr-Commit-Position: refs/heads/main@{#1311219}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
e0e3e40e81
commit
dccb3c31b4
chrome/browser
performance_manager
sessions
ui
components/sessions/core
@ -622,10 +622,19 @@ std::vector<LiveTab*> TabRestoreServiceHelper::RestoreEntryById(
|
||||
window.show_state, window.workspace, window.user_title,
|
||||
window.extra_data);
|
||||
|
||||
CHECK(!window.tabs.empty());
|
||||
const int selected_tab_index =
|
||||
window.selected_tab_index >= 0 &&
|
||||
window.selected_tab_index <
|
||||
static_cast<int>(window.tabs.size())
|
||||
? window.selected_tab_index
|
||||
: 0;
|
||||
const SessionID selected_tab_id = window.tabs[selected_tab_index]->id;
|
||||
|
||||
for (const auto& tab : window.tabs) {
|
||||
const bool first_tab = window.tabs[0]->id == tab->id;
|
||||
const bool select_tab = tab->id == selected_tab_id;
|
||||
LiveTab* restored_tab = context->AddRestoredTab(
|
||||
*tab.get(), context->GetTabCount(), first_tab);
|
||||
*tab.get(), context->GetTabCount(), select_tab);
|
||||
|
||||
if (restored_tab) {
|
||||
client_->OnTabRestored(
|
||||
|
Reference in New Issue
Block a user