OLD | NEW |
---|---|
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 Loading... | |
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; | |
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 = |
Bernhard Bauer
2012/03/30 12:40:05
Nit: Indent
marja
2012/03/30 12:51:37
Done.
| |
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_ && | |
Bernhard Bauer
2012/03/30 12:40:05
Can you indent this line and the next one by one s
marja
2012/03/30 12:51:37
Done.
| |
390 cookie_settings->GetDefaultCookieSetting(NULL) != | |
391 CONTENT_SETTING_SESSION_ONLY); | |
Bernhard Bauer
2012/03/30 12:40:05
...and this line by five spaces (so it's indented
marja
2012/03/30 12:51:37
Done.
| |
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 Loading... | |
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_) { |
Bernhard Bauer
2012/03/30 12:40:05
Nit: Braces unnecessary.
marja
2012/03/30 12:51:37
Done.
| |
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 } | 581 } |
572 | 582 |
573 StopCreateSessionServiceTimer(); | 583 StopCreateSessionServiceTimer(); |
574 | 584 |
575 // Remove pref observers | 585 // Remove pref observers |
576 pref_change_registrar_.RemoveAll(); | 586 pref_change_registrar_.RemoveAll(); |
577 | 587 |
578 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( | 588 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( |
579 io_data_.GetResourceContextNoInit()); | 589 io_data_.GetResourceContextNoInit()); |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1346 FilePath* cache_path, | 1356 FilePath* cache_path, |
1347 int* max_size) { | 1357 int* max_size) { |
1348 DCHECK(cache_path); | 1358 DCHECK(cache_path); |
1349 DCHECK(max_size); | 1359 DCHECK(max_size); |
1350 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); | 1360 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); |
1351 if (!path.empty()) | 1361 if (!path.empty()) |
1352 *cache_path = path; | 1362 *cache_path = path; |
1353 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1363 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
1354 prefs_->GetInteger(prefs::kDiskCacheSize); | 1364 prefs_->GetInteger(prefs::kDiskCacheSize); |
1355 } | 1365 } |
OLD | NEW |