| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 | 740 |
| 741 DISALLOW_COPY_AND_ASSIGN(SessionRestoreImpl); | 741 DISALLOW_COPY_AND_ASSIGN(SessionRestoreImpl); |
| 742 }; | 742 }; |
| 743 | 743 |
| 744 } // namespace | 744 } // namespace |
| 745 | 745 |
| 746 // SessionRestore ------------------------------------------------------------- | 746 // SessionRestore ------------------------------------------------------------- |
| 747 | 747 |
| 748 // static | 748 // static |
| 749 Browser* SessionRestore::RestoreSession( | 749 Browser* SessionRestore::RestoreSession( |
| 750 Profile* profile, | 750 Profile* profile, Browser* browser, |
| 751 Browser* browser, | 751 SessionRestore::BehaviorBitmask behavior, |
| 752 uint32_t behavior, | |
| 753 const std::vector<GURL>& urls_to_open) { | 752 const std::vector<GURL>& urls_to_open) { |
| 754 #if defined(OS_CHROMEOS) | 753 #if defined(OS_CHROMEOS) |
| 755 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker( | 754 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker( |
| 756 "SessionRestore-Start", false); | 755 "SessionRestore-Start", false); |
| 757 #endif | 756 #endif |
| 758 DCHECK(profile); | 757 DCHECK(profile); |
| 759 // Always restore from the original profile (incognito profiles have no | 758 // Always restore from the original profile (incognito profiles have no |
| 760 // session service). | 759 // session service). |
| 761 profile = profile->GetOriginalProfile(); | 760 profile = profile->GetOriginalProfile(); |
| 762 if (!SessionServiceFactory::GetForProfile(profile)) { | 761 if (!SessionServiceFactory::GetForProfile(profile)) { |
| 763 NOTREACHED(); | 762 NOTREACHED(); |
| 764 return nullptr; | 763 return nullptr; |
| 765 } | 764 } |
| 766 profile->set_restored_last_session(true); | 765 profile->set_restored_last_session(true); |
| 767 // SessionRestoreImpl takes care of deleting itself when done. | 766 // SessionRestoreImpl takes care of deleting itself when done. |
| 768 SessionRestoreImpl* restorer = new SessionRestoreImpl( | 767 SessionRestoreImpl* restorer = new SessionRestoreImpl( |
| 769 profile, browser, (behavior & SYNCHRONOUS) != 0, | 768 profile, browser, (behavior & SYNCHRONOUS) != 0, |
| 770 (behavior & CLOBBER_CURRENT_TAB) != 0, | 769 (behavior & CLOBBER_CURRENT_TAB) != 0, |
| 771 (behavior & ALWAYS_CREATE_TABBED_BROWSER) != 0, urls_to_open, | 770 (behavior & ALWAYS_CREATE_TABBED_BROWSER) != 0, urls_to_open, |
| 772 SessionRestore::on_session_restored_callbacks()); | 771 SessionRestore::on_session_restored_callbacks()); |
| 773 return restorer->Restore(); | 772 return restorer->Restore(); |
| 774 } | 773 } |
| 775 | 774 |
| 776 // static | 775 // static |
| 777 void SessionRestore::RestoreSessionAfterCrash(Browser* browser) { | 776 void SessionRestore::RestoreSessionAfterCrash(Browser* browser) { |
| 778 uint32_t behavior = | 777 SessionRestore::BehaviorBitmask behavior = |
| 779 HasSingleNewTabPage(browser) ? SessionRestore::CLOBBER_CURRENT_TAB : 0; | 778 HasSingleNewTabPage(browser) ? SessionRestore::CLOBBER_CURRENT_TAB : 0; |
| 780 SessionRestore::RestoreSession(browser->profile(), browser, behavior, | 779 SessionRestore::RestoreSession(browser->profile(), browser, behavior, |
| 781 std::vector<GURL>()); | 780 std::vector<GURL>()); |
| 782 } | 781 } |
| 783 | 782 |
| 784 // static | 783 // static |
| 785 void SessionRestore::OpenStartupPagesAfterCrash(Browser* browser) { | 784 void SessionRestore::OpenStartupPagesAfterCrash(Browser* browser) { |
| 786 WebContents* tab_to_clobber = nullptr; | 785 WebContents* tab_to_clobber = nullptr; |
| 787 if (HasSingleNewTabPage(browser)) | 786 if (HasSingleNewTabPage(browser)) |
| 788 tab_to_clobber = browser->tab_strip_model()->GetActiveWebContents(); | 787 tab_to_clobber = browser->tab_strip_model()->GetActiveWebContents(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 // static | 845 // static |
| 847 SessionRestore::CallbackSubscription | 846 SessionRestore::CallbackSubscription |
| 848 SessionRestore::RegisterOnSessionRestoredCallback( | 847 SessionRestore::RegisterOnSessionRestoredCallback( |
| 849 const base::Callback<void(int)>& callback) { | 848 const base::Callback<void(int)>& callback) { |
| 850 return on_session_restored_callbacks()->Add(callback); | 849 return on_session_restored_callbacks()->Add(callback); |
| 851 } | 850 } |
| 852 | 851 |
| 853 // static | 852 // static |
| 854 base::CallbackList<void(int)>* | 853 base::CallbackList<void(int)>* |
| 855 SessionRestore::on_session_restored_callbacks_ = nullptr; | 854 SessionRestore::on_session_restored_callbacks_ = nullptr; |
| OLD | NEW |