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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 if (schedule_load) | 707 if (schedule_load) |
708 tab_loader_->ScheduleLoad(&tab_contents->controller()); | 708 tab_loader_->ScheduleLoad(&tab_contents->controller()); |
709 } | 709 } |
710 | 710 |
711 Browser* CreateRestoredBrowser(Browser::Type type, | 711 Browser* CreateRestoredBrowser(Browser::Type type, |
712 gfx::Rect bounds, | 712 gfx::Rect bounds, |
713 ui::WindowShowState show_state) { | 713 ui::WindowShowState show_state) { |
714 Browser* browser = new Browser(type, profile_); | 714 Browser* browser = new Browser(type, profile_); |
715 browser->set_override_bounds(bounds); | 715 browser->set_override_bounds(bounds); |
716 browser->set_show_state(show_state); | 716 browser->set_show_state(show_state); |
| 717 browser->set_is_session_restore(true); |
717 browser->InitBrowserWindow(); | 718 browser->InitBrowserWindow(); |
718 return browser; | 719 return browser; |
719 } | 720 } |
720 | 721 |
721 void ShowBrowser(Browser* browser, | 722 void ShowBrowser(Browser* browser, |
722 int initial_tab_count, | 723 int initial_tab_count, |
723 int selected_session_index) { | 724 int selected_session_index) { |
724 DCHECK(browser); | 725 DCHECK(browser); |
725 DCHECK(browser->tab_count()); | 726 DCHECK(browser->tab_count()); |
726 browser->ActivateTabAt( | 727 browser->ActivateTabAt( |
727 std::min(initial_tab_count + std::max(0, selected_session_index), | 728 std::min(initial_tab_count + std::max(0, selected_session_index), |
728 browser->tab_count() - 1), true); | 729 browser->tab_count() - 1), true); |
729 | 730 |
730 if (browser_ == browser) | 731 if (browser_ == browser) |
731 return; | 732 return; |
732 | 733 |
733 browser->window()->Show(); | 734 browser->window()->Show(); |
| 735 browser->set_is_session_restore(false); |
| 736 |
734 // TODO(jcampan): http://crbug.com/8123 we should not need to set the | 737 // TODO(jcampan): http://crbug.com/8123 we should not need to set the |
735 // initial focus explicitly. | 738 // initial focus explicitly. |
736 browser->GetSelectedTabContents()->view()->SetInitialFocus(); | 739 browser->GetSelectedTabContents()->view()->SetInitialFocus(); |
737 } | 740 } |
738 | 741 |
739 // Appends the urls in |urls| to |browser|. | 742 // Appends the urls in |urls| to |browser|. |
740 void AppendURLsToBrowser(Browser* browser, | 743 void AppendURLsToBrowser(Browser* browser, |
741 const std::vector<GURL>& urls) { | 744 const std::vector<GURL>& urls) { |
742 for (size_t i = 0; i < urls.size(); ++i) { | 745 for (size_t i = 0; i < urls.size(); ++i) { |
743 int add_types = TabStripModel::ADD_FORCE_INDEX; | 746 int add_types = TabStripModel::ADD_FORCE_INDEX; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 std::vector<GURL> gurls; | 855 std::vector<GURL> gurls; |
853 SessionRestoreImpl restorer(profile, | 856 SessionRestoreImpl restorer(profile, |
854 static_cast<Browser*>(NULL), true, false, true, gurls); | 857 static_cast<Browser*>(NULL), true, false, true, gurls); |
855 restorer.RestoreForeignTab(tab); | 858 restorer.RestoreForeignTab(tab); |
856 } | 859 } |
857 | 860 |
858 // static | 861 // static |
859 bool SessionRestore::IsRestoring() { | 862 bool SessionRestore::IsRestoring() { |
860 return restoring; | 863 return restoring; |
861 } | 864 } |
OLD | NEW |