Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: chrome/browser/profiles/profile_impl.cc

Issue 9965012: Honor session content settings even if "continue where I left off" is selected. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/profiles/profile_impl.h" 5 #include "chrome/browser/profiles/profile_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 int media_cache_max_size; 355 int media_cache_max_size;
356 GetCacheParameters(true, &media_cache_path, &media_cache_max_size); 356 GetCacheParameters(true, &media_cache_path, &media_cache_max_size);
357 media_cache_path = GetMediaCachePath(media_cache_path); 357 media_cache_path = GetMediaCachePath(media_cache_path);
358 358
359 FilePath extensions_cookie_path = GetPath(); 359 FilePath extensions_cookie_path = GetPath();
360 extensions_cookie_path = 360 extensions_cookie_path =
361 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename); 361 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename);
362 362
363 FilePath app_path = GetPath().Append(chrome::kIsolatedAppStateDirname); 363 FilePath app_path = GetPath().Append(chrome::kIsolatedAppStateDirname);
364 364
365 bool restore_old_session_cookies = false;
sail 2012/03/30 15:50:01 Hi Marja. Since this is getting a bit complicated
marja 2012/03/30 16:26:42 This got reverted back to the original version.
366 if (session_restore_enabled_) {
367 // Restore old session cookies
368 // - after crashes
369 // - after updates
370 // - when the user has the "continue where I left off" startup option
371 // selected, and hasn't selected to clear cookies on exit or restricted them
372 // to session only.
373 const CommandLine* command_line = CommandLine::ForCurrentProcess();
365 #if defined(OS_ANDROID) 374 #if defined(OS_ANDROID)
366 SessionStartupPref::Type startup_pref_type = 375 SessionStartupPref::Type startup_pref_type =
367 SessionStartupPref::GetDefaultStartupType(); 376 SessionStartupPref::GetDefaultStartupType();
368 #else 377 #else
369 SessionStartupPref::Type startup_pref_type = 378 SessionStartupPref::Type startup_pref_type =
370 BrowserInit::GetSessionStartupPref(*CommandLine::ForCurrentProcess(), 379 BrowserInit::GetSessionStartupPref(*command_line, this).type;
371 this).type;
372 #endif 380 #endif
373 bool restore_old_session_cookies = 381 CookieSettings* cookie_settings =
374 session_restore_enabled_ && 382 CookieSettings::Factory::GetForProfile(this);
375 (!DidLastSessionExitCleanly() || 383
376 startup_pref_type == SessionStartupPref::LAST); 384 restore_old_session_cookies =
385 !DidLastSessionExitCleanly() ||
386 command_line->HasSwitch(switches::kRestoreLastSession) ||
387 BrowserInit::WasRestarted() ||
388 (startup_pref_type == SessionStartupPref::LAST &&
389 !clear_local_state_on_exit_ &&
390 cookie_settings->GetDefaultCookieSetting(NULL) !=
391 CONTENT_SETTING_SESSION_ONLY);
392 }
377 393
378 InitHostZoomMap(); 394 InitHostZoomMap();
379 395
380 // Make sure we initialize the ProfileIOData after everything else has been 396 // Make sure we initialize the ProfileIOData after everything else has been
381 // initialized that we might be reading from the IO thread. 397 // initialized that we might be reading from the IO thread.
382 398
383 io_data_.Init(cookie_path, server_bound_cert_path, cache_path, 399 io_data_.Init(cookie_path, server_bound_cert_path, cache_path,
384 cache_max_size, media_cache_path, media_cache_max_size, 400 cache_max_size, media_cache_path, media_cache_max_size,
385 extensions_cookie_path, app_path, predictor_, 401 extensions_cookie_path, app_path, predictor_,
386 g_browser_process->local_state(), 402 g_browser_process->local_state(),
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 569
554 void ProfileImpl::set_last_selected_directory(const FilePath& path) { 570 void ProfileImpl::set_last_selected_directory(const FilePath& path) {
555 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); 571 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path);
556 } 572 }
557 573
558 ProfileImpl::~ProfileImpl() { 574 ProfileImpl::~ProfileImpl() {
559 content::NotificationService::current()->Notify( 575 content::NotificationService::current()->Notify(
560 chrome::NOTIFICATION_PROFILE_DESTROYED, 576 chrome::NOTIFICATION_PROFILE_DESTROYED,
561 content::Source<Profile>(this), 577 content::Source<Profile>(this),
562 content::NotificationService::NoDetails()); 578 content::NotificationService::NoDetails());
563 // Save the session state if we're going to restore the session during the 579 if (clear_local_state_on_exit_)
564 // next startup.
565 SessionStartupPref pref = SessionStartupPref::GetStartupPref(this);
566 if (pref.type == SessionStartupPref::LAST) {
567 if (session_restore_enabled_)
568 BrowserContext::SaveSessionState(this);
569 } else if (clear_local_state_on_exit_) {
570 BrowserContext::ClearLocalOnDestruction(this); 580 BrowserContext::ClearLocalOnDestruction(this);
571 }
572 581
573 StopCreateSessionServiceTimer(); 582 StopCreateSessionServiceTimer();
574 583
575 // Remove pref observers 584 // Remove pref observers
576 pref_change_registrar_.RemoveAll(); 585 pref_change_registrar_.RemoveAll();
577 586
578 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( 587 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext(
579 io_data_.GetResourceContextNoInit()); 588 io_data_.GetResourceContextNoInit());
580 589
581 if (io_data_.HasMainRequestContext() && 590 if (io_data_.HasMainRequestContext() &&
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 FilePath* cache_path, 1355 FilePath* cache_path,
1347 int* max_size) { 1356 int* max_size) {
1348 DCHECK(cache_path); 1357 DCHECK(cache_path);
1349 DCHECK(max_size); 1358 DCHECK(max_size);
1350 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); 1359 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir));
1351 if (!path.empty()) 1360 if (!path.empty())
1352 *cache_path = path; 1361 *cache_path = path;
1353 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : 1362 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) :
1354 prefs_->GetInteger(prefs::kDiskCacheSize); 1363 prefs_->GetInteger(prefs::kDiskCacheSize);
1355 } 1364 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | chrome/browser/profiles/profile_io_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698