| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 10 #include <string> |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 std::vector<const SessionWindow*>::const_iterator begin, | 546 std::vector<const SessionWindow*>::const_iterator begin, |
| 547 std::vector<const SessionWindow*>::const_iterator end) { | 547 std::vector<const SessionWindow*>::const_iterator end) { |
| 548 StartTabCreation(); | 548 StartTabCreation(); |
| 549 // Create a browser instance to put the restored tabs in. | 549 // Create a browser instance to put the restored tabs in. |
| 550 for (std::vector<const SessionWindow*>::const_iterator i = begin; | 550 for (std::vector<const SessionWindow*>::const_iterator i = begin; |
| 551 i != end; ++i) { | 551 i != end; ++i) { |
| 552 Browser* browser = CreateRestoredBrowser( | 552 Browser* browser = CreateRestoredBrowser( |
| 553 static_cast<Browser::Type>((*i)->type), | 553 static_cast<Browser::Type>((*i)->type), |
| 554 (*i)->bounds, | 554 (*i)->bounds, |
| 555 (*i)->show_state, | 555 (*i)->show_state, |
| 556 (*i)->app_name); | 556 (*i)->app_name, |
| 557 (*i)->user_has_changed_window_or_position); |
| 557 | 558 |
| 558 // Restore and show the browser. | 559 // Restore and show the browser. |
| 559 const int initial_tab_count = 0; | 560 const int initial_tab_count = 0; |
| 560 int selected_tab_index = std::max( | 561 int selected_tab_index = std::max( |
| 561 0, | 562 0, |
| 562 std::min((*i)->selected_tab_index, | 563 std::min((*i)->selected_tab_index, |
| 563 static_cast<int>((*i)->tabs.size()) - 1)); | 564 static_cast<int>((*i)->tabs.size()) - 1)); |
| 564 selected_tab_index = | 565 selected_tab_index = |
| 565 RestoreTabsToBrowser(*(*i), browser, selected_tab_index); | 566 RestoreTabsToBrowser(*(*i), browser, selected_tab_index); |
| 566 ShowBrowser(browser, selected_tab_index); | 567 ShowBrowser(browser, selected_tab_index); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 // restore non-tabbed items... | 820 // restore non-tabbed items... |
| 820 DCHECK(!browser || browser->is_type_tabbed()); | 821 DCHECK(!browser || browser->is_type_tabbed()); |
| 821 DCHECK((*i)->type == Browser::TYPE_TABBED); | 822 DCHECK((*i)->type == Browser::TYPE_TABBED); |
| 822 } | 823 } |
| 823 #endif | 824 #endif |
| 824 if (!browser) { | 825 if (!browser) { |
| 825 browser = CreateRestoredBrowser( | 826 browser = CreateRestoredBrowser( |
| 826 static_cast<Browser::Type>((*i)->type), | 827 static_cast<Browser::Type>((*i)->type), |
| 827 (*i)->bounds, | 828 (*i)->bounds, |
| 828 show_state, | 829 show_state, |
| 829 (*i)->app_name); | 830 (*i)->app_name, |
| 831 (*i)->user_has_changed_window_or_position); |
| 830 } | 832 } |
| 831 #if defined(OS_CHROMEOS) | 833 #if defined(OS_CHROMEOS) |
| 832 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( | 834 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( |
| 833 "SessionRestore-CreateRestoredBrowser-End", false); | 835 "SessionRestore-CreateRestoredBrowser-End", false); |
| 834 #endif | 836 #endif |
| 835 } | 837 } |
| 836 if ((*i)->type == Browser::TYPE_TABBED) | 838 if ((*i)->type == Browser::TYPE_TABBED) |
| 837 last_browser = browser; | 839 last_browser = browser; |
| 838 WebContents* active_tab = chrome::GetActiveWebContents(browser); | 840 WebContents* active_tab = chrome::GetActiveWebContents(browser); |
| 839 int initial_tab_count = browser->tab_count(); | 841 int initial_tab_count = browser->tab_count(); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 } | 995 } |
| 994 | 996 |
| 995 if (schedule_load) | 997 if (schedule_load) |
| 996 tab_loader_->ScheduleLoad(&web_contents->GetController()); | 998 tab_loader_->ScheduleLoad(&web_contents->GetController()); |
| 997 return web_contents; | 999 return web_contents; |
| 998 } | 1000 } |
| 999 | 1001 |
| 1000 Browser* CreateRestoredBrowser(Browser::Type type, | 1002 Browser* CreateRestoredBrowser(Browser::Type type, |
| 1001 gfx::Rect bounds, | 1003 gfx::Rect bounds, |
| 1002 ui::WindowShowState show_state, | 1004 ui::WindowShowState show_state, |
| 1003 const std::string& app_name) { | 1005 const std::string& app_name, |
| 1006 bool user_has_changed_window_or_position) { |
| 1004 Browser::CreateParams params(type, profile_); | 1007 Browser::CreateParams params(type, profile_); |
| 1005 params.app_name = app_name; | 1008 params.app_name = app_name; |
| 1006 params.initial_bounds = bounds; | 1009 params.initial_bounds = bounds; |
| 1007 params.initial_show_state = show_state; | 1010 params.initial_show_state = show_state; |
| 1008 params.is_session_restore = true; | 1011 params.is_session_restore = true; |
| 1012 params.initial_user_has_changed_window_or_position = |
| 1013 user_has_changed_window_or_position; |
| 1009 return new Browser(params); | 1014 return new Browser(params); |
| 1010 } | 1015 } |
| 1011 | 1016 |
| 1012 void ShowBrowser(Browser* browser, int selected_tab_index) { | 1017 void ShowBrowser(Browser* browser, int selected_tab_index) { |
| 1013 DCHECK(browser); | 1018 DCHECK(browser); |
| 1014 DCHECK(browser->tab_count()); | 1019 DCHECK(browser->tab_count()); |
| 1015 chrome::ActivateTabAt(browser, selected_tab_index, true); | 1020 chrome::ActivateTabAt(browser, selected_tab_index, true); |
| 1016 | 1021 |
| 1017 if (browser_ == browser) | 1022 if (browser_ == browser) |
| 1018 return; | 1023 return; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 if (active_session_restorers == NULL) | 1174 if (active_session_restorers == NULL) |
| 1170 return false; | 1175 return false; |
| 1171 for (std::set<SessionRestoreImpl*>::const_iterator it = | 1176 for (std::set<SessionRestoreImpl*>::const_iterator it = |
| 1172 active_session_restorers->begin(); | 1177 active_session_restorers->begin(); |
| 1173 it != active_session_restorers->end(); ++it) { | 1178 it != active_session_restorers->end(); ++it) { |
| 1174 if ((*it)->profile() == profile) | 1179 if ((*it)->profile() == profile) |
| 1175 return true; | 1180 return true; |
| 1176 } | 1181 } |
| 1177 return false; | 1182 return false; |
| 1178 } | 1183 } |
| OLD | NEW |