| 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <malloc.h> | 8 #include <malloc.h> |
| 9 #else | 9 #else |
| 10 #include <alloca.h> | 10 #include <alloca.h> |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 void RestoreForeignSession( | 496 void RestoreForeignSession( |
| 497 std::vector<const SessionWindow*>::const_iterator begin, | 497 std::vector<const SessionWindow*>::const_iterator begin, |
| 498 std::vector<const SessionWindow*>::const_iterator end) { | 498 std::vector<const SessionWindow*>::const_iterator end) { |
| 499 StartTabCreation(); | 499 StartTabCreation(); |
| 500 // Create a browser instance to put the restored tabs in. | 500 // Create a browser instance to put the restored tabs in. |
| 501 for (std::vector<const SessionWindow*>::const_iterator i = begin; | 501 for (std::vector<const SessionWindow*>::const_iterator i = begin; |
| 502 i != end; ++i) { | 502 i != end; ++i) { |
| 503 Browser* browser = CreateRestoredBrowser( | 503 Browser* browser = CreateRestoredBrowser( |
| 504 static_cast<Browser::Type>((*i)->type), | 504 static_cast<Browser::Type>((*i)->type), |
| 505 (*i)->bounds, | 505 (*i)->bounds, |
| 506 (*i)->show_state); | 506 (*i)->show_state, |
| 507 (*i)->app_name); |
| 507 | 508 |
| 508 // Restore and show the browser. | 509 // Restore and show the browser. |
| 509 const int initial_tab_count = browser->tab_count(); | 510 const int initial_tab_count = browser->tab_count(); |
| 510 int selected_tab_index = (*i)->selected_tab_index; | 511 int selected_tab_index = (*i)->selected_tab_index; |
| 511 RestoreTabsToBrowser(*(*i), browser, selected_tab_index); | 512 RestoreTabsToBrowser(*(*i), browser, selected_tab_index); |
| 512 ShowBrowser(browser, initial_tab_count, selected_tab_index); | 513 ShowBrowser(browser, initial_tab_count, selected_tab_index); |
| 513 tab_loader_->TabIsLoading( | 514 tab_loader_->TabIsLoading( |
| 514 &browser->GetSelectedWebContents()->GetController()); | 515 &browser->GetSelectedWebContents()->GetController()); |
| 515 NotifySessionServiceOfRestoredTabs(browser, initial_tab_count); | 516 NotifySessionServiceOfRestoredTabs(browser, initial_tab_count); |
| 516 } | 517 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 "SessionRestore-CreateRestoredBrowser-Start", false); | 686 "SessionRestore-CreateRestoredBrowser-Start", false); |
| 686 #endif | 687 #endif |
| 687 // Show the first window if none are visible. | 688 // Show the first window if none are visible. |
| 688 ui::WindowShowState show_state = (*i)->show_state; | 689 ui::WindowShowState show_state = (*i)->show_state; |
| 689 if (!has_visible_browser) { | 690 if (!has_visible_browser) { |
| 690 show_state = ui::SHOW_STATE_NORMAL; | 691 show_state = ui::SHOW_STATE_NORMAL; |
| 691 has_visible_browser = true; | 692 has_visible_browser = true; |
| 692 } | 693 } |
| 693 | 694 |
| 694 browser = CreateRestoredBrowser( | 695 browser = CreateRestoredBrowser( |
| 695 static_cast<Browser::Type>((*i)->type), (*i)->bounds, show_state); | 696 static_cast<Browser::Type>((*i)->type), |
| 697 (*i)->bounds, |
| 698 show_state, |
| 699 (*i)->app_name); |
| 696 #if defined(OS_CHROMEOS) | 700 #if defined(OS_CHROMEOS) |
| 697 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( | 701 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( |
| 698 "SessionRestore-CreateRestoredBrowser-End", false); | 702 "SessionRestore-CreateRestoredBrowser-End", false); |
| 699 #endif | 703 #endif |
| 700 } | 704 } |
| 701 if ((*i)->type == Browser::TYPE_TABBED) | 705 if ((*i)->type == Browser::TYPE_TABBED) |
| 702 last_browser = browser; | 706 last_browser = browser; |
| 703 WebContents* active_tab = browser->GetSelectedWebContents(); | 707 WebContents* active_tab = browser->GetSelectedWebContents(); |
| 704 int initial_tab_count = browser->tab_count(); | 708 int initial_tab_count = browser->tab_count(); |
| 705 int selected_tab_index = (*i)->selected_tab_index; | 709 int selected_tab_index = (*i)->selected_tab_index; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 content::ChildProcessSecurityPolicy::GetInstance()-> | 801 content::ChildProcessSecurityPolicy::GetInstance()-> |
| 798 GrantPermissionsForFile(id, *file, read_file_permissions); | 802 GrantPermissionsForFile(id, *file, read_file_permissions); |
| 799 } | 803 } |
| 800 | 804 |
| 801 if (schedule_load) | 805 if (schedule_load) |
| 802 tab_loader_->ScheduleLoad(&web_contents->GetController()); | 806 tab_loader_->ScheduleLoad(&web_contents->GetController()); |
| 803 } | 807 } |
| 804 | 808 |
| 805 Browser* CreateRestoredBrowser(Browser::Type type, | 809 Browser* CreateRestoredBrowser(Browser::Type type, |
| 806 gfx::Rect bounds, | 810 gfx::Rect bounds, |
| 807 ui::WindowShowState show_state) { | 811 ui::WindowShowState show_state, |
| 808 Browser* browser = new Browser(type, profile_); | 812 const std::string& app_name) { |
| 809 browser->set_override_bounds(bounds); | 813 Browser::CreateParams params(type, profile_); |
| 810 browser->set_show_state(show_state); | 814 params.app_name = app_name; |
| 811 browser->set_is_session_restore(true); | 815 params.initial_bounds = bounds; |
| 812 browser->InitBrowserWindow(); | 816 params.initial_show_state = show_state; |
| 813 return browser; | 817 params.is_session_restore = true; |
| 818 return Browser::CreateWithParams(params); |
| 814 } | 819 } |
| 815 | 820 |
| 816 void ShowBrowser(Browser* browser, | 821 void ShowBrowser(Browser* browser, |
| 817 int initial_tab_count, | 822 int initial_tab_count, |
| 818 int selected_session_index) { | 823 int selected_session_index) { |
| 819 DCHECK(browser); | 824 DCHECK(browser); |
| 820 DCHECK(browser->tab_count()); | 825 DCHECK(browser->tab_count()); |
| 821 browser->ActivateTabAt( | 826 browser->ActivateTabAt( |
| 822 std::min(initial_tab_count + std::max(0, selected_session_index), | 827 std::min(initial_tab_count + std::max(0, selected_session_index), |
| 823 browser->tab_count() - 1), true); | 828 browser->tab_count() - 1), true); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 if (active_session_restorers == NULL) | 981 if (active_session_restorers == NULL) |
| 977 return false; | 982 return false; |
| 978 for (std::set<SessionRestoreImpl*>::const_iterator it = | 983 for (std::set<SessionRestoreImpl*>::const_iterator it = |
| 979 active_session_restorers->begin(); | 984 active_session_restorers->begin(); |
| 980 it != active_session_restorers->end(); ++it) { | 985 it != active_session_restorers->end(); ++it) { |
| 981 if ((*it)->profile() == profile) | 986 if ((*it)->profile() == profile) |
| 982 return true; | 987 return true; |
| 983 } | 988 } |
| 984 return false; | 989 return false; |
| 985 } | 990 } |
| OLD | NEW |