diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-05 23:37:36 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-05 23:37:36 +0000 |
commit | 95e394714d67b3a6951f351ae0b7e7c5ff02aab6 (patch) | |
tree | 226eb73c8cb5d122807dd949ab6081601d9fdc4d /chrome/browser/sessions | |
parent | 3bf196c17d3a5f619fa8cbda848bce764bffdbf4 (diff) | |
download | chromium_src-95e394714d67b3a6951f351ae0b7e7c5ff02aab6.zip chromium_src-95e394714d67b3a6951f351ae0b7e7c5ff02aab6.tar.gz chromium_src-95e394714d67b3a6951f351ae0b7e7c5ff02aab6.tar.bz2 |
Fixes two bugs that made tab restore service not return the right set
of tabs during an exit on chromeos.
. When we forcefully shutdown we wouldn't tell TabRestoreService the
browsers was closing, which resulted in not recording the close.
. BrowserCommandController was triggering creation of
TabRestoreService during shutdown.
BUG=150799
TEST=see bug
R=ben@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11049016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160515 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sessions')
-rw-r--r-- | chrome/browser/sessions/tab_restore_service.cc | 13 | ||||
-rw-r--r-- | chrome/browser/sessions/tab_restore_service_factory.cc | 7 | ||||
-rw-r--r-- | chrome/browser/sessions/tab_restore_service_factory.h | 4 |
3 files changed, 19 insertions, 5 deletions
diff --git a/chrome/browser/sessions/tab_restore_service.cc b/chrome/browser/sessions/tab_restore_service.cc index d29f042..a83f9d1 100644 --- a/chrome/browser/sessions/tab_restore_service.cc +++ b/chrome/browser/sessions/tab_restore_service.cc @@ -451,11 +451,14 @@ void TabRestoreService::LoadTabsFromLastSession() { SessionService* session_service = SessionServiceFactory::GetForProfile(profile()); - if (!profile()->restored_last_session() && - profile()->GetLastSessionExitType() == Profile::EXIT_CRASHED && - session_service) { - // The previous session crashed and wasn't restored. Load the tabs/windows - // that were open at the point of crash from the session service. + Profile::ExitType exit_type = profile()->GetLastSessionExitType(); + if (!profile()->restored_last_session() && session_service && + (exit_type == Profile::EXIT_CRASHED || + exit_type == Profile::EXIT_SESSION_ENDED)) { + // The previous session crashed and wasn't restored, or was a forced + // shutdown. Both of which won't have notified us of the browser close so + // that we need to load the windows from session service (which will have + // saved them). session_service->GetLastSession( &crash_consumer_, base::Bind(&TabRestoreService::OnGotPreviousSession, diff --git a/chrome/browser/sessions/tab_restore_service_factory.cc b/chrome/browser/sessions/tab_restore_service_factory.cc index d227075..e575cfe 100644 --- a/chrome/browser/sessions/tab_restore_service_factory.cc +++ b/chrome/browser/sessions/tab_restore_service_factory.cc @@ -14,6 +14,13 @@ TabRestoreService* TabRestoreServiceFactory::GetForProfile(Profile* profile) { } // static +TabRestoreService* TabRestoreServiceFactory::GetForProfileIfExisting( + Profile* profile) { + return static_cast<TabRestoreService*>( + GetInstance()->GetServiceForProfile(profile, false)); +} + +// static void TabRestoreServiceFactory::ResetForProfile(Profile* profile) { TabRestoreServiceFactory* factory = GetInstance(); factory->ProfileShutdown(profile); diff --git a/chrome/browser/sessions/tab_restore_service_factory.h b/chrome/browser/sessions/tab_restore_service_factory.h index 0471fa5..be90f8e 100644 --- a/chrome/browser/sessions/tab_restore_service_factory.h +++ b/chrome/browser/sessions/tab_restore_service_factory.h @@ -18,6 +18,10 @@ class TabRestoreServiceFactory : public ProfileKeyedServiceFactory { public: static TabRestoreService* GetForProfile(Profile* profile); + // Variant of GetForProfile() that returns NULL if TabRestoreService does not + // exist. + static TabRestoreService* GetForProfileIfExisting(Profile* profile); + static void ResetForProfile(Profile* profile); static TabRestoreServiceFactory* GetInstance(); |