Chromium Code Reviews| Index: chrome/browser/profiles/profile_impl.cc |
| diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc |
| index 0fee3f3b08b8039fadf2676a757f85ec3e629bb5..7bc0df943205aaebea39ce2af59d36339b778a0b 100644 |
| --- a/chrome/browser/profiles/profile_impl.cc |
| +++ b/chrome/browser/profiles/profile_impl.cc |
| @@ -168,6 +168,12 @@ FilePath GetMediaCachePath(const FilePath& base) { |
| return base.Append(chrome::kMediaCacheDirname); |
| } |
| +void SaveSessionStateOnIOThread( |
| + net::URLRequestContextGetter* url_request_context_getter) { |
| + url_request_context_getter->GetURLRequestContext()->cookie_store()-> |
|
Miranda Callahan
2011/12/02 17:13:10
Could you add a DCHECK at the start of this method
marja
2011/12/05 08:40:16
Done.
|
| + GetCookieMonster()->SaveSessionCookies(); |
| +} |
| + |
| } // namespace |
| // static |
| @@ -230,7 +236,8 @@ ProfileImpl::ProfileImpl(const FilePath& path, |
| checked_instant_promo_(false), |
| #endif |
| delegate_(delegate), |
| - predictor_(NULL) { |
| + predictor_(NULL), |
| + session_restore_enabled_(false) { |
| DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
| "profile files to the root directory!"; |
| @@ -245,6 +252,8 @@ ProfileImpl::ProfileImpl(const FilePath& path, |
| !command_line->HasSwitch(switches::kDisablePreconnect), |
| g_browser_process->profile_manager() == NULL); |
| + session_restore_enabled_ = |
| + command_line->HasSwitch(switches::kEnableRestoreSessionState); |
| if (delegate_) { |
| prefs_.reset(PrefService::CreatePrefService( |
| GetPrefFilePath(), |
| @@ -358,6 +367,12 @@ void ProfileImpl::DoFinalInit() { |
| FilePath app_path = GetPath().Append(chrome::kIsolatedAppStateDirname); |
| + bool restore_old_session_cookies = |
| + session_restore_enabled_ && |
| + (!DidLastSessionExitCleanly() || |
| + CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kRestoreLastSession)); |
| + |
| // Make sure we initialize the ProfileIOData after everything else has been |
| // initialized that we might be reading from the IO thread. |
| @@ -365,7 +380,8 @@ void ProfileImpl::DoFinalInit() { |
| cache_max_size, media_cache_path, media_cache_max_size, |
| extensions_cookie_path, app_path, predictor_, |
| g_browser_process->local_state(), |
| - g_browser_process->io_thread()); |
| + g_browser_process->io_thread(), |
| + restore_old_session_cookies); |
| ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
| PluginPrefs::GetForProfile(this), &GetResourceContext()); |
| @@ -1563,6 +1579,15 @@ NetworkActionPredictor* ProfileImpl::GetNetworkActionPredictor() { |
| return network_action_predictor_.get(); |
| } |
| +void ProfileImpl::SaveSessionState() { |
| + if (!session_restore_enabled_) |
| + return; |
| + BrowserThread::PostTask( |
| + BrowserThread::IO, FROM_HERE, |
| + base::Bind(&SaveSessionStateOnIOThread, |
| + make_scoped_refptr(GetRequestContext()))); |
| +} |
| + |
| SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { |
| if (!spellcheck_profile_.get()) |
| spellcheck_profile_.reset(new SpellCheckProfile(path_)); |