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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sessions/session_restore.h" 5 #include "chrome/browser/sessions/session_restore.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 delete this; 291 delete this;
292 return; 292 return;
293 } 293 }
294 294
295 if (browser_) { 295 if (browser_) {
296 registrar_.Add(this, NotificationType::BROWSER_CLOSED, 296 registrar_.Add(this, NotificationType::BROWSER_CLOSED,
297 Source<Browser>(browser_)); 297 Source<Browser>(browser_));
298 } 298 }
299 } 299 }
300 300
301 void RestoreForeignSession(std::vector<SessionWindow*>* windows) {
302 tab_loader_.reset(new TabLoader());
303 // Create a browser instance to put the restored tabs in.
304 bool has_tabbed_browser = false;
305 for (std::vector<SessionWindow*>::iterator i = (*windows).begin();
306 i != (*windows).end(); ++i) {
307 Browser* browser = NULL;
308 if (!has_tabbed_browser && (*i)->type == Browser::TYPE_NORMAL)
309 has_tabbed_browser = true;
310 browser = new Browser(static_cast<Browser::Type>((*i)->type),
311 profile_);
312 browser->set_override_bounds((*i)->bounds);
313 browser->set_maximized_state((*i)->is_maximized ?
314 Browser::MAXIMIZED_STATE_MAXIMIZED :
315 Browser::MAXIMIZED_STATE_UNMAXIMIZED);
316 browser->CreateBrowserWindow();
317
318 // Restore and show the browser.
319 const int initial_tab_count = browser->tab_count();
320 RestoreTabsToBrowser(*(*i), browser);
321 ShowBrowser(browser, initial_tab_count,
322 (*i)->selected_tab_index);
323 NotifySessionServiceOfRestoredTabs(browser, initial_tab_count);
324 FinishedTabCreation(true, has_tabbed_browser);
325 }
326 }
327
301 ~SessionRestoreImpl() { 328 ~SessionRestoreImpl() {
302 STLDeleteElements(&windows_); 329 STLDeleteElements(&windows_);
303 restoring = false; 330 restoring = false;
304 } 331 }
305 332
306 virtual void Observe(NotificationType type, 333 virtual void Observe(NotificationType type,
307 const NotificationSource& source, 334 const NotificationSource& source,
308 const NotificationDetails& details) { 335 const NotificationDetails& details) {
309 switch (type.value) { 336 switch (type.value) {
310 case NotificationType::BROWSER_CLOSED: 337 case NotificationType::BROWSER_CLOSED:
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 void SessionRestore::RestoreSession(Profile* profile, 634 void SessionRestore::RestoreSession(Profile* profile,
608 Browser* browser, 635 Browser* browser,
609 bool clobber_existing_window, 636 bool clobber_existing_window,
610 bool always_create_tabbed_browser, 637 bool always_create_tabbed_browser,
611 const std::vector<GURL>& urls_to_open) { 638 const std::vector<GURL>& urls_to_open) {
612 Restore(profile, browser, false, clobber_existing_window, 639 Restore(profile, browser, false, clobber_existing_window,
613 always_create_tabbed_browser, urls_to_open); 640 always_create_tabbed_browser, urls_to_open);
614 } 641 }
615 642
616 // static 643 // static
644 void SessionRestore::RestoreForeignSessionWindows(Profile* profile,
645 std::vector<SessionWindow*>* windows) {
646 // Create a SessionRestore object to eventually restore the tabs.
647 std::vector<GURL> gurls;
648 SessionRestoreImpl restorer(profile,
649 static_cast<Browser*>(NULL), true, false, true, gurls);
650 restorer.RestoreForeignSession(windows);
651 }
652
653 // static
617 void SessionRestore::RestoreSessionSynchronously( 654 void SessionRestore::RestoreSessionSynchronously(
618 Profile* profile, 655 Profile* profile,
619 const std::vector<GURL>& urls_to_open) { 656 const std::vector<GURL>& urls_to_open) {
620 Restore(profile, NULL, true, false, true, urls_to_open); 657 Restore(profile, NULL, true, false, true, urls_to_open);
621 } 658 }
622 659
623 // static 660 // static
624 bool SessionRestore::IsRestoring() { 661 bool SessionRestore::IsRestoring() {
625 return restoring; 662 return restoring;
626 } 663 }
OLDNEW
« 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