| 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..4bdb837ef94c02275795f53c266f5d2c01c3b9ca 100644
|
| --- a/chrome/browser/profiles/profile_impl.cc
|
| +++ b/chrome/browser/profiles/profile_impl.cc
|
| @@ -168,6 +168,13 @@ FilePath GetMediaCachePath(const FilePath& base) {
|
| return base.Append(chrome::kMediaCacheDirname);
|
| }
|
|
|
| +void SaveSessionStateOnIOThread(
|
| + net::URLRequestContextGetter* url_request_context_getter) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| + url_request_context_getter->GetURLRequestContext()->cookie_store()->
|
| + GetCookieMonster()->SaveSessionCookies();
|
| +}
|
| +
|
| } // namespace
|
|
|
| // static
|
| @@ -230,7 +237,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 +253,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 +368,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 +381,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 +1580,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_));
|
|
|