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

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

Issue 3133022: sync: take two for: "Added classes to enable session sync... (Closed)
Patch Set: Created 10 years, 4 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
« no previous file with comments | « chrome/browser/sessions/session_restore.h ('k') | chrome/browser/sessions/session_types.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/session_restore.cc
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc
index a75f7defa029107cd21b7baecc4cc6ddf219aa98..9a20e6506a85bee9edab68892f4c8d5c0a204e77 100644
--- a/chrome/browser/sessions/session_restore.cc
+++ b/chrome/browser/sessions/session_restore.cc
@@ -298,6 +298,33 @@ class SessionRestoreImpl : public NotificationObserver {
}
}
+ void RestoreForeignSession(std::vector<SessionWindow*>* windows) {
+ tab_loader_.reset(new TabLoader());
+ // Create a browser instance to put the restored tabs in.
+ bool has_tabbed_browser = false;
+ for (std::vector<SessionWindow*>::iterator i = (*windows).begin();
+ i != (*windows).end(); ++i) {
+ Browser* browser = NULL;
+ if (!has_tabbed_browser && (*i)->type == Browser::TYPE_NORMAL)
+ has_tabbed_browser = true;
+ browser = new Browser(static_cast<Browser::Type>((*i)->type),
+ profile_);
+ browser->set_override_bounds((*i)->bounds);
+ browser->set_maximized_state((*i)->is_maximized ?
+ Browser::MAXIMIZED_STATE_MAXIMIZED :
+ Browser::MAXIMIZED_STATE_UNMAXIMIZED);
+ browser->CreateBrowserWindow();
+
+ // Restore and show the browser.
+ const int initial_tab_count = browser->tab_count();
+ RestoreTabsToBrowser(*(*i), browser);
+ ShowBrowser(browser, initial_tab_count,
+ (*i)->selected_tab_index);
+ NotifySessionServiceOfRestoredTabs(browser, initial_tab_count);
+ FinishedTabCreation(true, has_tabbed_browser);
+ }
+ }
+
~SessionRestoreImpl() {
STLDeleteElements(&windows_);
restoring = false;
@@ -614,6 +641,16 @@ void SessionRestore::RestoreSession(Profile* profile,
}
// static
+void SessionRestore::RestoreForeignSessionWindows(Profile* profile,
+ std::vector<SessionWindow*>* windows) {
+ // Create a SessionRestore object to eventually restore the tabs.
+ std::vector<GURL> gurls;
+ SessionRestoreImpl restorer(profile,
+ static_cast<Browser*>(NULL), true, false, true, gurls);
+ restorer.RestoreForeignSession(windows);
+}
+
+// static
void SessionRestore::RestoreSessionSynchronously(
Profile* profile,
const std::vector<GURL>& urls_to_open) {
« no previous file with comments | « chrome/browser/sessions/session_restore.h ('k') | chrome/browser/sessions/session_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698