Chromium Code Reviews| Index: chrome/browser/sessions/tab_restore_service_helper.cc |
| diff --git a/chrome/browser/sessions/tab_restore_service_helper.cc b/chrome/browser/sessions/tab_restore_service_helper.cc |
| index 7e1ca3a6ad952dc6b80138a22c18bb00ad3f2303..bf03828fbbcb428134dccbd3f5b3d7e4a5336f61 100644 |
| --- a/chrome/browser/sessions/tab_restore_service_helper.cc |
| +++ b/chrome/browser/sessions/tab_restore_service_helper.cc |
| @@ -170,13 +170,15 @@ const TabRestoreService::Entries& TabRestoreServiceHelper::entries() const { |
| return entries_; |
| } |
| -void TabRestoreServiceHelper::RestoreMostRecentEntry( |
| - TabRestoreServiceDelegate* delegate, |
| - chrome::HostDesktopType host_desktop_type) { |
| +std::vector<content::WebContents*> |
| + TabRestoreServiceHelper::RestoreMostRecentEntry( |
|
sky
2013/08/05 16:16:17
Same indentation comment.
Kristen Dwan
2013/08/05 18:01:38
Done.
|
| + TabRestoreServiceDelegate* delegate, |
| + chrome::HostDesktopType host_desktop_type) { |
| if (entries_.empty()) |
| - return; |
| + return std::vector<WebContents*>(); |
| - RestoreEntryById(delegate, entries_.front()->id, host_desktop_type, UNKNOWN); |
| + return RestoreEntryById(delegate, entries_.front()->id, host_desktop_type, |
| + UNKNOWN); |
| } |
| TabRestoreService::Tab* TabRestoreServiceHelper::RemoveTabEntryById( |
| @@ -194,7 +196,7 @@ TabRestoreService::Tab* TabRestoreServiceHelper::RemoveTabEntryById( |
| return tab; |
| } |
| -void TabRestoreServiceHelper::RestoreEntryById( |
| +std::vector<content::WebContents*> TabRestoreServiceHelper::RestoreEntryById( |
| TabRestoreServiceDelegate* delegate, |
| SessionID::id_type id, |
| chrome::HostDesktopType host_desktop_type, |
| @@ -202,7 +204,7 @@ void TabRestoreServiceHelper::RestoreEntryById( |
| Entries::iterator entry_iterator = GetEntryIteratorById(id); |
| if (entry_iterator == entries_.end()) |
| // Don't hoark here, we allow an invalid id. |
| - return; |
| + return std::vector<WebContents*>(); |
| if (observer_) |
| observer_->OnRestoreEntryById(id, entry_iterator); |
| @@ -221,9 +223,12 @@ void TabRestoreServiceHelper::RestoreEntryById( |
| // |delegate| will be NULL in cases where one isn't already available (eg, |
| // when invoked on Mac OS X with no windows open). In this case, create a |
| // new browser into which we restore the tabs. |
| + std::vector<WebContents*> web_contents; |
| if (entry->type == TabRestoreService::TAB) { |
| Tab* tab = static_cast<Tab*>(entry); |
| - delegate = RestoreTab(*tab, delegate, host_desktop_type, disposition); |
| + web_contents.resize(1); |
|
sky
2013/08/05 16:16:17
Assuming no one else modifies web_contents before
Kristen Dwan
2013/08/05 18:01:38
Done.
|
| + delegate = RestoreTab(*tab, delegate, host_desktop_type, disposition, |
| + &web_contents[0]); |
| delegate->ShowBrowserWindow(); |
| } else if (entry->type == TabRestoreService::WINDOW) { |
| TabRestoreServiceDelegate* current_delegate = delegate; |
| @@ -250,6 +255,7 @@ void TabRestoreServiceHelper::RestoreEntryById( |
| if (restored_tab) { |
| restored_tab->GetController().LoadIfNecessary(); |
| RecordAppLaunch(profile_, tab); |
| + web_contents.push_back(restored_tab); |
| } |
| } |
| // All the window's tabs had the same former browser_id. |
| @@ -264,7 +270,9 @@ void TabRestoreServiceHelper::RestoreEntryById( |
| tab_i != window->tabs.end(); ++tab_i) { |
| const Tab& tab = *tab_i; |
| if (tab.id == id) { |
| - delegate = RestoreTab(tab, delegate, host_desktop_type, disposition); |
| + web_contents.resize(1); |
| + delegate = RestoreTab(tab, delegate, host_desktop_type, disposition, |
| + &web_contents[0]); |
| window->tabs.erase(tab_i); |
| // If restoring the tab leaves the window with nothing else, delete it |
| // as well. |
| @@ -302,6 +310,7 @@ void TabRestoreServiceHelper::RestoreEntryById( |
| restoring_ = false; |
| NotifyTabsChanged(); |
| + return web_contents; |
| } |
| void TabRestoreServiceHelper::NotifyTabsChanged() { |
| @@ -437,14 +446,17 @@ TabRestoreServiceDelegate* TabRestoreServiceHelper::RestoreTab( |
| const Tab& tab, |
| TabRestoreServiceDelegate* delegate, |
| chrome::HostDesktopType host_desktop_type, |
| - WindowOpenDisposition disposition) { |
| + WindowOpenDisposition disposition, |
| + WebContents** contents) { |
| + WebContents* web_contents; |
| if (disposition == CURRENT_TAB && delegate) { |
| - delegate->ReplaceRestoredTab(tab.navigations, |
| - tab.current_navigation_index, |
| - tab.from_last_session, |
| - tab.extension_app_id, |
| - tab.session_storage_namespace.get(), |
| - tab.user_agent_override); |
| + web_contents = delegate->ReplaceRestoredTab( |
| + tab.navigations, |
| + tab.current_navigation_index, |
| + tab.from_last_session, |
| + tab.extension_app_id, |
| + tab.session_storage_namespace.get(), |
| + tab.user_agent_override); |
| } else { |
| // We only respsect the tab's original browser if there's no disposition. |
| if (disposition == UNKNOWN && tab.has_browser()) { |
| @@ -473,19 +485,21 @@ TabRestoreServiceDelegate* TabRestoreServiceHelper::RestoreTab( |
| tab_index = delegate->GetTabCount(); |
| } |
| - WebContents* web_contents = |
| - delegate->AddRestoredTab(tab.navigations, |
| - tab_index, |
| - tab.current_navigation_index, |
| - tab.extension_app_id, |
| - disposition != NEW_BACKGROUND_TAB, |
| - tab.pinned, |
| - tab.from_last_session, |
| - tab.session_storage_namespace.get(), |
| - tab.user_agent_override); |
| + web_contents = delegate->AddRestoredTab(tab.navigations, |
| + tab_index, |
| + tab.current_navigation_index, |
| + tab.extension_app_id, |
| + disposition != NEW_BACKGROUND_TAB, |
| + tab.pinned, |
| + tab.from_last_session, |
| + tab.session_storage_namespace.get(), |
| + tab.user_agent_override); |
| web_contents->GetController().LoadIfNecessary(); |
| } |
| RecordAppLaunch(profile_, tab); |
| + if (contents) |
| + *contents = web_contents; |
| + |
| return delegate; |
| } |