Index: chrome/browser/sessions/tab_restore_service.cc |
diff --git a/chrome/browser/sessions/tab_restore_service.cc b/chrome/browser/sessions/tab_restore_service.cc |
index fa19cf5ebd2d91abc5a5d7f06e9396a5e3c1b58b..380f917e0e6c6c553d4f802c5b7f265d9fc957a9 100644 |
--- a/chrome/browser/sessions/tab_restore_service.cc |
+++ b/chrome/browser/sessions/tab_restore_service.cc |
@@ -81,6 +81,7 @@ static const SessionCommand::id_type kCommandWindow = 3; |
static const SessionCommand::id_type kCommandSelectedNavigationInTab = 4; |
static const SessionCommand::id_type kCommandPinnedState = 5; |
static const SessionCommand::id_type kCommandSetExtensionAppID = 6; |
+static const SessionCommand::id_type kCommandSetWindowAppName = 7; |
// Number of entries (not commands) before we clobber the file and write |
// everything. |
@@ -240,6 +241,8 @@ void TabRestoreService::BrowserClosing(TabRestoreServiceDelegate* delegate) { |
scoped_ptr<Window> window(new Window()); |
window->selected_tab_index = delegate->GetSelectedIndex(); |
window->timestamp = TimeNow(); |
+ window->app_name = delegate->GetAppName(); |
+ |
// Don't use std::vector::resize() because it will push copies of an empty tab |
// into the vector, which will give all tabs in a window the same ID. |
for (int i = 0; i < delegate->GetTabCount(); ++i) { |
@@ -258,7 +261,7 @@ void TabRestoreService::BrowserClosing(TabRestoreServiceDelegate* delegate) { |
entry_index++; |
} |
} |
- if (window->tabs.size() == 1) { |
+ if (window->tabs.size() == 1 && window->app_name.empty()) { |
// Short-circuit creating a Window if only 1 tab was present. This fixes |
// http://crbug.com/56744. Copy the Tab because it's owned by an object on |
// the stack. |
@@ -349,7 +352,7 @@ void TabRestoreService::RestoreEntryById(TabRestoreServiceDelegate* delegate, |
// single tab within it. If the entry's ID matches the one to restore, then |
// the entire window will be restored. |
if (!restoring_tab_in_window) { |
- delegate = TabRestoreServiceDelegate::Create(profile()); |
+ delegate = TabRestoreServiceDelegate::Create(profile(), window->app_name); |
for (size_t tab_i = 0; tab_i < window->tabs.size(); ++tab_i) { |
const Tab& tab = window->tabs[tab_i]; |
WebContents* restored_tab = |
@@ -612,6 +615,13 @@ void TabRestoreService::ScheduleCommandsForWindow(const Window& window) { |
valid_tab_count, |
window.timestamp)); |
+ if (!window.app_name.empty()) { |
+ ScheduleCommand( |
+ CreateSetWindowAppNameCommand(kCommandSetWindowAppName, |
+ window.id, |
+ window.app_name)); |
+ } |
+ |
for (size_t i = 0; i < window.tabs.size(); ++i) { |
int selected_index = GetSelectedNavigationIndexToPersist(window.tabs[i]); |
if (selected_index != -1) |
@@ -886,6 +896,22 @@ void TabRestoreService::CreateEntriesFromCommands( |
break; |
} |
+ case kCommandSetWindowAppName: { |
+ if (!current_window) { |
+ // We should have created a window already. |
+ NOTREACHED(); |
+ return; |
+ } |
+ |
+ SessionID::id_type window_id; |
+ std::string app_name; |
+ if (!RestoreSetWindowAppNameCommand(command, &window_id, &app_name)) |
+ return; |
+ |
+ current_window->app_name.swap(app_name); |
+ break; |
+ } |
+ |
case kCommandSetExtensionAppID: { |
if (!current_tab) { |
// Should be in a tab when we get this. |
@@ -936,7 +962,7 @@ TabRestoreServiceDelegate* TabRestoreService::RestoreTab( |
if (delegate && disposition != NEW_WINDOW) { |
tab_index = tab.tabstrip_index; |
} else { |
- delegate = TabRestoreServiceDelegate::Create(profile()); |
+ delegate = TabRestoreServiceDelegate::Create(profile(), std::string()); |
if (tab.has_browser()) |
UpdateTabBrowserIDs(tab.browser_id, delegate->GetSessionID().id()); |
} |