| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <list> | 8 #include <list> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 if (browser_) { | 439 if (browser_) { |
| 440 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, | 440 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, |
| 441 Source<Browser>(browser_)); | 441 Source<Browser>(browser_)); |
| 442 } | 442 } |
| 443 | 443 |
| 444 return browser_; | 444 return browser_; |
| 445 } | 445 } |
| 446 | 446 |
| 447 // Restore window(s) from a foreign session. | 447 // Restore window(s) from a foreign session. |
| 448 void RestoreForeignSession( | 448 void RestoreForeignSession( |
| 449 std::vector<SessionWindow*>::const_iterator begin, | 449 std::vector<const SessionWindow*>::const_iterator begin, |
| 450 std::vector<SessionWindow*>::const_iterator end) { | 450 std::vector<const SessionWindow*>::const_iterator end) { |
| 451 StartTabCreation(); | 451 StartTabCreation(); |
| 452 // Create a browser instance to put the restored tabs in. | 452 // Create a browser instance to put the restored tabs in. |
| 453 for (std::vector<SessionWindow*>::const_iterator i = begin; | 453 for (std::vector<const SessionWindow*>::const_iterator i = begin; |
| 454 i != end; ++i) { | 454 i != end; ++i) { |
| 455 Browser* browser = CreateRestoredBrowser( | 455 Browser* browser = CreateRestoredBrowser( |
| 456 static_cast<Browser::Type>((*i)->type), | 456 static_cast<Browser::Type>((*i)->type), |
| 457 (*i)->bounds, | 457 (*i)->bounds, |
| 458 (*i)->show_state); | 458 (*i)->show_state); |
| 459 | 459 |
| 460 // Restore and show the browser. | 460 // Restore and show the browser. |
| 461 const int initial_tab_count = browser->tab_count(); | 461 const int initial_tab_count = browser->tab_count(); |
| 462 int selected_tab_index = (*i)->selected_tab_index; | 462 int selected_tab_index = (*i)->selected_tab_index; |
| 463 RestoreTabsToBrowser(*(*i), browser, selected_tab_index); | 463 RestoreTabsToBrowser(*(*i), browser, selected_tab_index); |
| 464 ShowBrowser(browser, initial_tab_count, selected_tab_index); | 464 ShowBrowser(browser, initial_tab_count, selected_tab_index); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 profile, browser, (behavior & SYNCHRONOUS) != 0, | 835 profile, browser, (behavior & SYNCHRONOUS) != 0, |
| 836 (behavior & CLOBBER_CURRENT_TAB) != 0, | 836 (behavior & CLOBBER_CURRENT_TAB) != 0, |
| 837 (behavior & ALWAYS_CREATE_TABBED_BROWSER) != 0, | 837 (behavior & ALWAYS_CREATE_TABBED_BROWSER) != 0, |
| 838 urls_to_open); | 838 urls_to_open); |
| 839 return restorer->Restore(); | 839 return restorer->Restore(); |
| 840 } | 840 } |
| 841 | 841 |
| 842 // static | 842 // static |
| 843 void SessionRestore::RestoreForeignSessionWindows( | 843 void SessionRestore::RestoreForeignSessionWindows( |
| 844 Profile* profile, | 844 Profile* profile, |
| 845 std::vector<SessionWindow*>::const_iterator begin, | 845 std::vector<const SessionWindow*>::const_iterator begin, |
| 846 std::vector<SessionWindow*>::const_iterator end) { | 846 std::vector<const SessionWindow*>::const_iterator end) { |
| 847 // Create a SessionRestore object to eventually restore the tabs. | 847 // Create a SessionRestore object to eventually restore the tabs. |
| 848 std::vector<GURL> gurls; | 848 std::vector<GURL> gurls; |
| 849 SessionRestoreImpl restorer(profile, | 849 SessionRestoreImpl restorer(profile, |
| 850 static_cast<Browser*>(NULL), true, false, true, gurls); | 850 static_cast<Browser*>(NULL), true, false, true, gurls); |
| 851 restorer.RestoreForeignSession(begin, end); | 851 restorer.RestoreForeignSession(begin, end); |
| 852 } | 852 } |
| 853 | 853 |
| 854 // static | 854 // static |
| 855 void SessionRestore::RestoreForeignSessionTab(Profile* profile, | 855 void SessionRestore::RestoreForeignSessionTab(Profile* profile, |
| 856 const SessionTab& tab) { | 856 const SessionTab& tab) { |
| 857 // Create a SessionRestore object to eventually restore the tabs. | 857 // Create a SessionRestore object to eventually restore the tabs. |
| 858 std::vector<GURL> gurls; | 858 std::vector<GURL> gurls; |
| 859 SessionRestoreImpl restorer(profile, | 859 SessionRestoreImpl restorer(profile, |
| 860 static_cast<Browser*>(NULL), true, false, true, gurls); | 860 static_cast<Browser*>(NULL), true, false, true, gurls); |
| 861 restorer.RestoreForeignTab(tab); | 861 restorer.RestoreForeignTab(tab); |
| 862 } | 862 } |
| 863 | 863 |
| 864 // static | 864 // static |
| 865 bool SessionRestore::IsRestoring() { | 865 bool SessionRestore::IsRestoring() { |
| 866 return restoring; | 866 return restoring; |
| 867 } | 867 } |
| OLD | NEW |