diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-04 02:26:36 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-04 02:26:36 +0000 |
commit | 2ca1ea66c938dd34c25e3cafe9cdfc46cdd50881 (patch) | |
tree | d1f83644dd7f5c4e59304c5286f509eb1d8c46cb | |
parent | b68232832acde42bf3835dae286870c57ba1c6f7 (diff) | |
download | chromium_src-2ca1ea66c938dd34c25e3cafe9cdfc46cdd50881.zip chromium_src-2ca1ea66c938dd34c25e3cafe9cdfc46cdd50881.tar.gz chromium_src-2ca1ea66c938dd34c25e3cafe9cdfc46cdd50881.tar.bz2 |
Removes BrowserContext::DidLastSessionExitCleanly() and makes
NavigationController::Restore() take an enum instead that
encapsculates this.
BUG=90737
TEST=none
R=avi@chromium.org,sail@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11016038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160052 0039d316-1c4b-4281-b951-d872f2087c98
23 files changed, 103 insertions, 69 deletions
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc index ddb5623..33e3b6f 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.cc +++ b/chrome/browser/profiles/off_the_record_profile_impl.cc @@ -335,10 +335,6 @@ content::SpeechRecognitionPreferences* return profile_->GetSpeechRecognitionPreferences(); } -bool OffTheRecordProfileImpl::DidLastSessionExitCleanly() { - return profile_->DidLastSessionExitCleanly(); -} - quota::SpecialStoragePolicy* OffTheRecordProfileImpl::GetSpecialStoragePolicy() { return GetExtensionSpecialStoragePolicy(); @@ -389,6 +385,10 @@ bool OffTheRecordProfileImpl::WasCreatedByVersionOrLater( return profile_->WasCreatedByVersionOrLater(version); } +bool OffTheRecordProfileImpl::DidLastSessionExitCleanly() { + return profile_->DidLastSessionExitCleanly(); +} + #if defined(OS_CHROMEOS) void OffTheRecordProfileImpl::SetupChromeOSEnterpriseExtensionObserver() { profile_->SetupChromeOSEnterpriseExtensionObserver(); diff --git a/chrome/browser/profiles/off_the_record_profile_impl.h b/chrome/browser/profiles/off_the_record_profile_impl.h index be2278c..edcac8d 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.h +++ b/chrome/browser/profiles/off_the_record_profile_impl.h @@ -66,6 +66,7 @@ class OffTheRecordProfileImpl : public Profile, virtual FilePath last_selected_directory() OVERRIDE; virtual void set_last_selected_directory(const FilePath& path) OVERRIDE; virtual bool WasCreatedByVersionOrLater(const std::string& version) OVERRIDE; + virtual bool DidLastSessionExitCleanly() OVERRIDE; #if defined(OS_CHROMEOS) virtual void SetupChromeOSEnterpriseExtensionObserver() OVERRIDE; @@ -101,7 +102,6 @@ class OffTheRecordProfileImpl : public Profile, GetGeolocationPermissionContext() OVERRIDE; virtual content::SpeechRecognitionPreferences* GetSpeechRecognitionPreferences() OVERRIDE; - virtual bool DidLastSessionExitCleanly() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; // content::NotificationObserver implementation. diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h index 3e3688d..2d8f8f3 100644 --- a/chrome/browser/profiles/profile.h +++ b/chrome/browser/profiles/profile.h @@ -339,6 +339,9 @@ class Profile : public content::BrowserContext { return restored_last_session_; } + // Returns true if the last time this profile was open it was exited cleanly. + virtual bool DidLastSessionExitCleanly() = 0; + // Stop sending accessibility events until ResumeAccessibilityEvents(). // Calls to Pause nest; no events will be sent until the number of // Resume calls matches the number of Pause calls received. diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 8b0bfa4..7ef0012 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -637,6 +637,13 @@ bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { return (profile_version.CompareTo(arg_version) >= 0); } +bool ProfileImpl::DidLastSessionExitCleanly() { + // last_session_exited_cleanly_ is set when the preferences are loaded. Force + // it to be set by asking for the prefs. + GetPrefs(); + return last_session_exited_cleanly_; +} + policy::UserCloudPolicyManager* ProfileImpl::GetUserCloudPolicyManager() { return cloud_policy_manager_.get(); } @@ -791,13 +798,6 @@ DownloadManagerDelegate* ProfileImpl::GetDownloadManagerDelegate() { GetDownloadManagerDelegate(); } -bool ProfileImpl::DidLastSessionExitCleanly() { - // last_session_exited_cleanly_ is set when the preferences are loaded. Force - // it to be set by asking for the prefs. - GetPrefs(); - return last_session_exited_cleanly_; -} - quota::SpecialStoragePolicy* ProfileImpl::GetSpecialStoragePolicy() { return GetExtensionSpecialStoragePolicy(); } diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h index b714d39..53a9830f 100644 --- a/chrome/browser/profiles/profile_impl.h +++ b/chrome/browser/profiles/profile_impl.h @@ -70,7 +70,6 @@ class ProfileImpl : public Profile, GetGeolocationPermissionContext() OVERRIDE; virtual content::SpeechRecognitionPreferences* GetSpeechRecognitionPreferences() OVERRIDE; - virtual bool DidLastSessionExitCleanly() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; // Profile implementation: @@ -109,6 +108,7 @@ class ProfileImpl : public Profile, virtual void ClearNetworkingHistorySince(base::Time time) OVERRIDE; virtual GURL GetHomePage() OVERRIDE; virtual bool WasCreatedByVersionOrLater(const std::string& version) OVERRIDE; + virtual bool DidLastSessionExitCleanly() OVERRIDE; #if defined(OS_CHROMEOS) virtual void ChangeAppLocale(const std::string& locale, diff --git a/chrome/browser/sessions/session_restore_android.cc b/chrome/browser/sessions/session_restore_android.cc index 836ff0c..7864667 100644 --- a/chrome/browser/sessions/session_restore_android.cc +++ b/chrome/browser/sessions/session_restore_android.cc @@ -14,9 +14,9 @@ #include "content/public/browser/web_contents.h" #include "ipc/ipc_message.h" -// static // The android implementation does not do anything "foreign session" specific. // We use it to restore tabs from "recently closed" too. +// static void SessionRestore::RestoreForeignSessionTab( content::WebContents* web_contents, const SessionTab& session_tab, @@ -32,9 +32,10 @@ void SessionRestore::RestoreForeignSessionTab( content::WebContents* new_web_contents = content::WebContents::Create( context, NULL, MSG_ROUTING_NONE, NULL); int selected_index = session_tab.normalized_navigation_index(); - new_web_contents->GetController().Restore(selected_index, - true, /* from_last_session */ - &entries); + new_web_contents->GetController().Restore( + selected_index, + content::NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, + &entries); tab_model->CreateTab(new_web_contents); } diff --git a/chrome/browser/ui/browser_tabrestore.cc b/chrome/browser/ui/browser_tabrestore.cc index da35864..7c93e92 100644 --- a/chrome/browser/ui/browser_tabrestore.cc +++ b/chrome/browser/ui/browser_tabrestore.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/browser_tabrestore.h" #include "chrome/browser/extensions/tab_helper.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/sessions/session_service.h" #include "chrome/browser/sessions/session_service_factory.h" #include "chrome/browser/tab_contents/tab_util.h" @@ -26,6 +27,20 @@ using content::NavigationEntry; namespace chrome { +namespace { + +NavigationController::RestoreType GetRestoreType( + Browser* browser, + bool from_last_session) { + if (!from_last_session) + return NavigationController::RESTORE_CURRENT_SESSION; + return browser->profile()->DidLastSessionExitCleanly() ? + NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY : + NavigationController::RESTORE_LAST_SESSION_CRASHED; +} + +} + int GetIndexForInsertionDuringRestore(Browser* browser, int relative_index) { return (browser->tab_strip_model()->insertion_policy() == TabStripModel::INSERT_AFTER) ? browser->tab_count() : relative_index; @@ -64,7 +79,8 @@ content::WebContents* AddRestoredTab( navigations, browser->profile()); new_tab->SetUserAgentOverride(user_agent_override); new_tab->GetController().Restore( - selected_navigation, from_last_session, &entries); + selected_navigation, GetRestoreType(browser, from_last_session), + &entries); DCHECK_EQ(0u, entries.size()); int add_types = select ? TabStripModel::ADD_ACTIVE : @@ -127,7 +143,8 @@ void ReplaceRestoredTab( TabNavigation::CreateNavigationEntriesFromTabNavigations( navigations, browser->profile()); replacement->GetController().Restore( - selected_navigation, from_last_session, &entries); + selected_navigation, GetRestoreType(browser, from_last_session), + &entries); DCHECK_EQ(0u, entries.size()); browser->tab_strip_model()->ReplaceNavigationControllerAt( diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc index 94586c5..a78981e 100644 --- a/chrome/browser/ui/startup/startup_browser_creator.cc +++ b/chrome/browser/ui/startup/startup_browser_creator.cc @@ -563,5 +563,5 @@ void StartupBrowserCreator::ProcessCommandLineAlreadyRunning( bool HasPendingUncleanExit(Profile* profile) { return !profile->DidLastSessionExitCleanly() && - !profile_launch_observer.Get().HasBeenLaunched(profile); + !profile_launch_observer.Get().HasBeenLaunched(profile); } diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc index ffffe3f..9ee170d 100644 --- a/chrome/test/base/testing_profile.cc +++ b/chrome/test/base/testing_profile.cc @@ -731,10 +731,6 @@ void TestingProfile::SetID(const std::wstring& id) { id_ = id; } -bool TestingProfile::DidLastSessionExitCleanly() { - return last_session_exited_cleanly_; -} - bool TestingProfile::IsSameProfile(Profile *p) { return this == p; } @@ -798,6 +794,10 @@ bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { return true; } +bool TestingProfile::DidLastSessionExitCleanly() { + return last_session_exited_cleanly_; +} + base::Callback<ChromeURLDataManagerBackend*(void)> TestingProfile::GetChromeURLDataManagerBackendGetter() const { return base::Callback<ChromeURLDataManagerBackend*(void)>(); diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h index 1c48188..11f6a70 100644 --- a/chrome/test/base/testing_profile.h +++ b/chrome/test/base/testing_profile.h @@ -197,7 +197,6 @@ class TestingProfile : public Profile { GetGeolocationPermissionContext() OVERRIDE; virtual content::SpeechRecognitionPreferences* GetSpeechRecognitionPreferences() OVERRIDE; - virtual bool DidLastSessionExitCleanly() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; virtual TestingProfile* AsTestingProfile() OVERRIDE; @@ -272,6 +271,7 @@ class TestingProfile : public Profile { virtual FilePath last_selected_directory() OVERRIDE; virtual void set_last_selected_directory(const FilePath& path) OVERRIDE; virtual bool WasCreatedByVersionOrLater(const std::string& version) OVERRIDE; + virtual bool DidLastSessionExitCleanly() OVERRIDE; #if defined(OS_CHROMEOS) virtual void SetupChromeOSEnterpriseExtensionObserver() OVERRIDE { } diff --git a/content/browser/download/download_manager_impl_unittest.cc b/content/browser/download/download_manager_impl_unittest.cc index 3c24652..a401e58 100644 --- a/content/browser/download/download_manager_impl_unittest.cc +++ b/content/browser/download/download_manager_impl_unittest.cc @@ -397,7 +397,6 @@ class MockBrowserContext : public content::BrowserContext { content::GeolocationPermissionContext* ()); MOCK_METHOD0(GetSpeechRecognitionPreferences, content::SpeechRecognitionPreferences* ()); - MOCK_METHOD0(DidLastSessionExitCleanly, bool()); MOCK_METHOD0(GetSpecialStoragePolicy, quota::SpecialStoragePolicy*()); }; diff --git a/content/browser/web_contents/navigation_controller_impl.cc b/content/browser/web_contents/navigation_controller_impl.cc index 56a9988..3e749f7 100644 --- a/content/browser/web_contents/navigation_controller_impl.cc +++ b/content/browser/web_contents/navigation_controller_impl.cc @@ -85,18 +85,30 @@ void SetContentStateIfEmpty(NavigationEntryImpl* entry) { } } +NavigationEntryImpl::RestoreType ControllerRestoreTypeToEntryType( + NavigationController::RestoreType type) { + switch (type) { + case NavigationController::RESTORE_CURRENT_SESSION: + return NavigationEntryImpl::RESTORE_CURRENT_SESSION; + case NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY: + return NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY; + case NavigationController::RESTORE_LAST_SESSION_CRASHED: + return NavigationEntryImpl::RESTORE_LAST_SESSION_CRASHED; + } + NOTREACHED(); + return NavigationEntryImpl::RESTORE_CURRENT_SESSION; +} + // Configure all the NavigationEntries in entries for restore. This resets // the transition type to reload and makes sure the content state isn't empty. void ConfigureEntriesForRestore( std::vector<linked_ptr<NavigationEntryImpl> >* entries, - bool from_last_session) { + NavigationController::RestoreType type) { for (size_t i = 0; i < entries->size(); ++i) { // Use a transition type of reload so that we don't incorrectly increase // the typed count. (*entries)[i]->SetTransitionType(content::PAGE_TRANSITION_RELOAD); - (*entries)[i]->set_restore_type(from_last_session ? - NavigationEntryImpl::RESTORE_LAST_SESSION : - NavigationEntryImpl::RESTORE_CURRENT_SESSION); + (*entries)[i]->set_restore_type(ControllerRestoreTypeToEntryType(type)); // NOTE(darin): This code is only needed for backwards compat. SetContentStateIfEmpty((*entries)[i].get()); } @@ -222,7 +234,7 @@ void NavigationControllerImpl::SetBrowserContext( void NavigationControllerImpl::Restore( int selected_navigation, - bool from_last_session, + RestoreType type, std::vector<NavigationEntry*>* entries) { // Verify that this controller is unused and that the input is valid. DCHECK(GetEntryCount() == 0 && !GetPendingEntry()); @@ -238,7 +250,7 @@ void NavigationControllerImpl::Restore( entries->clear(); // And finish the restore. - FinishRestore(selected_navigation, from_last_session); + FinishRestore(selected_navigation, type); } void NavigationControllerImpl::Reload(bool check_for_repost) { @@ -1150,7 +1162,7 @@ void NavigationControllerImpl::CopyStateFrom( make_pair(it->first, source_namespace->Clone())); } - FinishRestore(source.last_committed_entry_index_, false); + FinishRestore(source.last_committed_entry_index_, RESTORE_CURRENT_SESSION); // Copy the max page id map from the old tab to the new tab. This ensures // that new and existing navigations in the tab's current SiteInstances @@ -1537,9 +1549,9 @@ void NavigationControllerImpl::NotifyEntryChanged(const NavigationEntry* entry, } void NavigationControllerImpl::FinishRestore(int selected_index, - bool from_last_session) { + RestoreType type) { DCHECK(selected_index >= 0 && selected_index < GetEntryCount()); - ConfigureEntriesForRestore(&entries_, from_last_session); + ConfigureEntriesForRestore(&entries_, type); SetMaxRestoredPageID(static_cast<int32>(GetEntryCount())); diff --git a/content/browser/web_contents/navigation_controller_impl.h b/content/browser/web_contents/navigation_controller_impl.h index 660fa0c..bc88904 100644 --- a/content/browser/web_contents/navigation_controller_impl.h +++ b/content/browser/web_contents/navigation_controller_impl.h @@ -37,7 +37,7 @@ class CONTENT_EXPORT NavigationControllerImpl content::BrowserContext* browser_context) OVERRIDE; virtual void Restore( int selected_navigation, - bool from_last_session, + RestoreType type, std::vector<content::NavigationEntry*>* entries) OVERRIDE; virtual content::NavigationEntry* GetActiveEntry() const OVERRIDE; virtual content::NavigationEntry* GetVisibleEntry() const OVERRIDE; @@ -247,8 +247,8 @@ class CONTENT_EXPORT NavigationControllerImpl // Invoked after session/tab restore or cloning a tab. Resets the transition // type of the entries, updates the max page id and creates the active - // contents. See RestoreFromState for a description of from_last_session. - void FinishRestore(int selected_index, bool from_last_session); + // contents. + void FinishRestore(int selected_index, RestoreType type); // Inserts a new entry or replaces the current entry with a new one, removing // all entries after it. The new entry will become the active one. diff --git a/content/browser/web_contents/navigation_controller_impl_unittest.cc b/content/browser/web_contents/navigation_controller_impl_unittest.cc index 02cd375..bc80f1b 100644 --- a/content/browser/web_contents/navigation_controller_impl_unittest.cc +++ b/content/browser/web_contents/navigation_controller_impl_unittest.cc @@ -1891,13 +1891,16 @@ TEST_F(NavigationControllerTest, RestoreNavigate) { WebContentsImpl::Create(browser_context(), NULL, MSG_ROUTING_NONE, NULL)); NavigationControllerImpl& our_controller = our_contents->GetController(); - our_controller.Restore(0, true, &entries); + our_controller.Restore( + 0, + NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, + &entries); ASSERT_EQ(0u, entries.size()); // Before navigating to the restored entry, it should have a restore_type // and no SiteInstance. ASSERT_EQ(1, our_controller.GetEntryCount()); - EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION, + EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY, NavigationEntryImpl::FromNavigationEntry( our_controller.GetEntryAtIndex(0))->restore_type()); EXPECT_FALSE(NavigationEntryImpl::FromNavigationEntry( @@ -1966,12 +1969,13 @@ TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) { WebContentsImpl::Create(browser_context(), NULL, MSG_ROUTING_NONE, NULL)); NavigationControllerImpl& our_controller = our_contents->GetController(); - our_controller.Restore(0, true, &entries); + our_controller.Restore( + 0, NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries); ASSERT_EQ(0u, entries.size()); // Before navigating to the restored entry, it should have a restore_type // and no SiteInstance. - EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION, + EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY, NavigationEntryImpl::FromNavigationEntry( our_controller.GetEntryAtIndex(0))->restore_type()); EXPECT_FALSE(NavigationEntryImpl::FromNavigationEntry( diff --git a/content/browser/web_contents/navigation_entry_impl.h b/content/browser/web_contents/navigation_entry_impl.h index f404b5d..8a2ca90 100644 --- a/content/browser/web_contents/navigation_entry_impl.h +++ b/content/browser/web_contents/navigation_entry_impl.h @@ -125,8 +125,9 @@ class CONTENT_EXPORT NavigationEntryImpl // Enumerations of the possible restore types. enum RestoreType { - // The entry has been restored is from the last session. - RESTORE_LAST_SESSION, + // Restore from the previous session. + RESTORE_LAST_SESSION_EXITED_CLEANLY, + RESTORE_LAST_SESSION_CRASHED, // The entry has been restored from the current session. This is used when // the user issues 'reopen closed tab'. diff --git a/content/browser/web_contents/navigation_entry_impl_unittest.cc b/content/browser/web_contents/navigation_entry_impl_unittest.cc index e4f2dc1..6bda03e 100644 --- a/content/browser/web_contents/navigation_entry_impl_unittest.cc +++ b/content/browser/web_contents/navigation_entry_impl_unittest.cc @@ -172,8 +172,10 @@ TEST_F(NavigationEntryTest, NavigationEntryAccessors) { // Restored EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, entry1_->restore_type()); EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, entry2_->restore_type()); - entry2_->set_restore_type(NavigationEntryImpl::RESTORE_LAST_SESSION); - EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION, entry2_->restore_type()); + entry2_->set_restore_type( + NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY); + EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY, + entry2_->restore_type()); // Original URL EXPECT_EQ(GURL(), entry1_->GetOriginalRequestURL()); diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 089d1f9..eb4668d 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -208,8 +208,8 @@ ViewMsg_Navigate_Type::Value GetNavigationType( // |RenderViewImpl::PopulateStateFromPendingNavigationParams| differentiates // between |RESTORE_WITH_POST| and |RESTORE|. - if (entry.restore_type() == NavigationEntryImpl::RESTORE_LAST_SESSION && - browser_context->DidLastSessionExitCleanly()) { + if (entry.restore_type() == + NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY) { if (entry.GetHasPostData()) return ViewMsg_Navigate_Type::RESTORE_WITH_POST; return ViewMsg_Navigate_Type::RESTORE; diff --git a/content/public/browser/browser_context.h b/content/public/browser/browser_context.h index 16a2ea5..3962265 100644 --- a/content/public/browser/browser_context.h +++ b/content/public/browser/browser_context.h @@ -126,10 +126,6 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { // to return NULL. virtual SpeechRecognitionPreferences* GetSpeechRecognitionPreferences() = 0; - // Returns true if the last time this context was open it was exited cleanly. - // This doesn't belong here; http://crbug.com/90737 - virtual bool DidLastSessionExitCleanly() = 0; - // Returns a special storage policy implementation, or NULL. virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() = 0; }; diff --git a/content/public/browser/navigation_controller.h b/content/public/browser/navigation_controller.h index cc0a27f..27357a6 100644 --- a/content/public/browser/navigation_controller.h +++ b/content/public/browser/navigation_controller.h @@ -83,6 +83,16 @@ class NavigationController { // static constants. }; + enum RestoreType { + // Indicates the restore is from the current session. For example, restoring + // a closed tab. + RESTORE_CURRENT_SESSION, + + // Restore from the previous session. + RESTORE_LAST_SESSION_EXITED_CLEANLY, + RESTORE_LAST_SESSION_CRASHED, + }; + // Creates a navigation entry and translates the virtual url to a real one. // This is a general call; prefer LoadURL[FromRenderer]/TransferURL below. // Extra headers are separated by \n. @@ -161,14 +171,13 @@ class NavigationController { virtual void SetBrowserContext(BrowserContext* browser_context) = 0; // Initializes this NavigationController with the given saved navigations, - // using selected_navigation as the currently loaded entry. Before this call - // the controller should be unused (there should be no current entry). If - // from_last_session is true, navigations are from the previous session, - // otherwise they are from the current session (undo tab close). This takes - // ownership of the NavigationEntrys in |entries| and clears it out. - // This is used for session restore. + // using |selected_navigation| as the currently loaded entry. Before this call + // the controller should be unused (there should be no current entry). |type| + // indicates where the restor comes from. This takes ownership of the + // NavigationEntrys in |entries| and clears it out. This is used for session + // restore. virtual void Restore(int selected_navigation, - bool from_last_session, + RestoreType type, std::vector<NavigationEntry*>* entries) = 0; // Entries ------------------------------------------------------------------- diff --git a/content/public/test/test_browser_context.cc b/content/public/test/test_browser_context.cc index 4d808f6..c605515 100644 --- a/content/public/test/test_browser_context.cc +++ b/content/public/test/test_browser_context.cc @@ -148,10 +148,6 @@ SpeechRecognitionPreferences* return NULL; } -bool TestBrowserContext::DidLastSessionExitCleanly() { - return true; -} - quota::SpecialStoragePolicy* TestBrowserContext::GetSpecialStoragePolicy() { return special_storage_policy_.get(); } diff --git a/content/public/test/test_browser_context.h b/content/public/test/test_browser_context.h index 07f8015..931d2b1 100644 --- a/content/public/test/test_browser_context.h +++ b/content/public/test/test_browser_context.h @@ -46,7 +46,6 @@ class TestBrowserContext : public BrowserContext { GetGeolocationPermissionContext() OVERRIDE; virtual SpeechRecognitionPreferences* GetSpeechRecognitionPreferences() OVERRIDE; - virtual bool DidLastSessionExitCleanly() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; private: diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc index a5ad7af..0a66e15 100644 --- a/content/shell/shell_browser_context.cc +++ b/content/shell/shell_browser_context.cc @@ -154,10 +154,6 @@ SpeechRecognitionPreferences* return NULL; } -bool ShellBrowserContext::DidLastSessionExitCleanly() { - return true; -} - quota::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() { return NULL; } diff --git a/content/shell/shell_browser_context.h b/content/shell/shell_browser_context.h index fbcbc6e..4386a80 100644 --- a/content/shell/shell_browser_context.h +++ b/content/shell/shell_browser_context.h @@ -43,7 +43,6 @@ class ShellBrowserContext : public BrowserContext { GetGeolocationPermissionContext() OVERRIDE; virtual SpeechRecognitionPreferences* GetSpeechRecognitionPreferences() OVERRIDE; - virtual bool DidLastSessionExitCleanly() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; private: |