Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Unified Diff: chrome/browser/sessions/session_restore.cc

Issue 21022018: Sessions API - previously Session Restore API. Supports restoring currently open foreign windows an… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added assert true to test Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698