Chromium Code Reviews| Index: chrome/browser/sessions/session_restore.cc |
| diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc |
| index a257b50400008caf28ebe9d6a5be6bd82820ea9c..27736fd058ef41d38a7f8aee0a1f94f7f7c150a9 100644 |
| --- a/chrome/browser/sessions/session_restore.cc |
| +++ b/chrome/browser/sessions/session_restore.cc |
| @@ -567,11 +567,13 @@ class SessionRestoreImpl : public content::NotificationObserver { |
| return browser_; |
| } |
| - // Restore window(s) from a foreign session. |
| - void RestoreForeignSession( |
| + // Restore window(s) from a foreign session. Return corresponding created |
|
sky
2013/08/01 00:05:43
Returns newly created Browsers.
Kristen Dwan
2013/08/02 20:54:19
Done.
|
| + // Browsers to identify restored Windows. |
| + std::vector<Browser*> RestoreForeignSession( |
| std::vector<const SessionWindow*>::const_iterator begin, |
| std::vector<const SessionWindow*>::const_iterator end) { |
| StartTabCreation(); |
| + std::vector<Browser*> browsers; |
| // Create a browser instance to put the restored tabs in. |
| for (std::vector<const SessionWindow*>::const_iterator i = begin; |
| i != end; ++i) { |
| @@ -580,6 +582,7 @@ class SessionRestoreImpl : public content::NotificationObserver { |
| (*i)->bounds, |
| (*i)->show_state, |
| (*i)->app_name); |
| + browsers.push_back(browser); |
| // Restore and show the browser. |
| const int initial_tab_count = 0; |
| @@ -594,12 +597,14 @@ class SessionRestoreImpl : public content::NotificationObserver { |
| // Always create in a new window |
| FinishedTabCreation(true, true); |
| + return browsers; |
| } |
| // Restore a single tab from a foreign session. |
| // Opens in the tab in the last active browser, unless disposition is |
| - // NEW_WINDOW, in which case the tab will be opened in a new browser. |
| - void RestoreForeignTab(const SessionTab& tab, |
| + // NEW_WINDOW, in which case the tab will be opened in a new browser. Returns |
| + // the WebContents of the restored tab. |
| + WebContents* RestoreForeignTab(const SessionTab& tab, |
| WindowOpenDisposition disposition) { |
|
sky
2013/08/01 00:05:43
nit: fix indentation.
Kristen Dwan
2013/08/02 20:54:19
Done.
|
| DCHECK(!tab.navigations.empty()); |
| int selected_index = tab.current_navigation_index; |
| @@ -616,19 +621,20 @@ class SessionRestoreImpl : public content::NotificationObserver { |
| RecordAppLaunchForTab(browser, tab, selected_index); |
| + WebContents* web_contents; |
| if (disposition == CURRENT_TAB) { |
| DCHECK(!use_new_window); |
| - chrome::ReplaceRestoredTab(browser, |
| - tab.navigations, |
| - selected_index, |
| - true, |
| - tab.extension_app_id, |
| - NULL, |
| - tab.user_agent_override); |
| + web_contents = chrome::ReplaceRestoredTab(browser, |
| + tab.navigations, |
| + selected_index, |
| + true, |
| + tab.extension_app_id, |
| + NULL, |
| + tab.user_agent_override); |
| } else { |
| int tab_index = |
| use_new_window ? 0 : browser->tab_strip_model()->active_index() + 1; |
| - WebContents* web_contents = chrome::AddRestoredTab( |
| + web_contents = chrome::AddRestoredTab( |
| browser, |
| tab.navigations, |
| tab_index, |
| @@ -653,6 +659,7 @@ class SessionRestoreImpl : public content::NotificationObserver { |
| // Since FinishedTabCreation() is not called here, |this| will leak if we |
| // are not in sychronous mode. |
| DCHECK(synchronous_); |
| + return web_contents; |
| } |
| virtual ~SessionRestoreImpl() { |
| @@ -1219,7 +1226,7 @@ Browser* SessionRestore::RestoreSession( |
| } |
| // static |
| -void SessionRestore::RestoreForeignSessionWindows( |
| +std::vector<Browser*> SessionRestore::RestoreForeignSessionWindows( |
| Profile* profile, |
| chrome::HostDesktopType host_desktop_type, |
| std::vector<const SessionWindow*>::const_iterator begin, |
| @@ -1227,11 +1234,11 @@ void SessionRestore::RestoreForeignSessionWindows( |
| std::vector<GURL> gurls; |
| SessionRestoreImpl restorer(profile, |
| static_cast<Browser*>(NULL), host_desktop_type, true, false, true, gurls); |
| - restorer.RestoreForeignSession(begin, end); |
| + return restorer.RestoreForeignSession(begin, end); |
| } |
| // static |
| -void SessionRestore::RestoreForeignSessionTab( |
| +WebContents* SessionRestore::RestoreForeignSessionTab( |
| content::WebContents* source_web_contents, |
| const SessionTab& tab, |
| WindowOpenDisposition disposition) { |
| @@ -1240,7 +1247,7 @@ void SessionRestore::RestoreForeignSessionTab( |
| std::vector<GURL> gurls; |
| SessionRestoreImpl restorer(profile, browser, browser->host_desktop_type(), |
| true, false, false, gurls); |
| - restorer.RestoreForeignTab(tab, disposition); |
| + return restorer.RestoreForeignTab(tab, disposition); |
| } |
| // static |