| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/browser_list.h" | 5 #include "chrome/browser/ui/browser_list.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 chromeos::BootTimesLoader::Get()->RecordCurrentStats(kLogoutStarted); | 487 chromeos::BootTimesLoader::Get()->RecordCurrentStats(kLogoutStarted); |
| 488 | 488 |
| 489 // Login screen should show up in owner's locale. | 489 // Login screen should show up in owner's locale. |
| 490 PrefService* state = g_browser_process->local_state(); | 490 PrefService* state = g_browser_process->local_state(); |
| 491 if (state) { | 491 if (state) { |
| 492 std::string owner_locale = state->GetString(prefs::kOwnerLocale); | 492 std::string owner_locale = state->GetString(prefs::kOwnerLocale); |
| 493 if (!owner_locale.empty() && | 493 if (!owner_locale.empty() && |
| 494 state->GetString(prefs::kApplicationLocale) != owner_locale && | 494 state->GetString(prefs::kApplicationLocale) != owner_locale && |
| 495 !state->IsManagedPreference(prefs::kApplicationLocale)) { | 495 !state->IsManagedPreference(prefs::kApplicationLocale)) { |
| 496 state->SetString(prefs::kApplicationLocale, owner_locale); | 496 state->SetString(prefs::kApplicationLocale, owner_locale); |
| 497 state->SavePersistentPrefs(); | 497 state->CommitPendingWrite(); |
| 498 } | 498 } |
| 499 } | 499 } |
| 500 g_session_manager_requested_shutdown = false; | 500 g_session_manager_requested_shutdown = false; |
| 501 if (FastShutdown()) | 501 if (FastShutdown()) |
| 502 return; | 502 return; |
| 503 #else | 503 #else |
| 504 // Reset the restart bit that might have been set in cancelled restart | 504 // Reset the restart bit that might have been set in cancelled restart |
| 505 // request. | 505 // request. |
| 506 PrefService* pref_service = g_browser_process->local_state(); | 506 PrefService* pref_service = g_browser_process->local_state(); |
| 507 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, false); | 507 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, false); |
| 508 #endif | 508 #endif |
| 509 AttemptExitInternal(); | 509 AttemptExitInternal(); |
| 510 } | 510 } |
| 511 | 511 |
| 512 // static | 512 // static |
| 513 void BrowserList::AttemptRestart() { | 513 void BrowserList::AttemptRestart() { |
| 514 if (CommandLine::ForCurrentProcess()->HasSwitch( | 514 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 515 switches::kEnableRestoreSessionState)) { | 515 switches::kEnableRestoreSessionState)) { |
| 516 BrowserVector::const_iterator it; | 516 BrowserVector::const_iterator it; |
| 517 for (it = begin(); it != end(); ++it) | 517 for (it = begin(); it != end(); ++it) |
| 518 (*it)->profile()->SaveSessionState(); | 518 (*it)->profile()->SaveSessionState(); |
| 519 } | 519 } |
| 520 | 520 |
| 521 PrefService* pref_service = g_browser_process->local_state(); | 521 PrefService* pref_service = g_browser_process->local_state(); |
| 522 pref_service->SetBoolean(prefs::kWasRestarted, true); | 522 pref_service->SetBoolean(prefs::kWasRestarted, true); |
| 523 pref_service->ScheduleSavePersistentPrefs(); | |
| 524 | 523 |
| 525 #if defined(OS_CHROMEOS) | 524 #if defined(OS_CHROMEOS) |
| 526 // For CrOS instead of browser restart (which is not supported) perform a full | 525 // For CrOS instead of browser restart (which is not supported) perform a full |
| 527 // sign out. Session will be only restored if user has that setting set. | 526 // sign out. Session will be only restored if user has that setting set. |
| 528 // Same session restore behavior happens in case of full restart after update. | 527 // Same session restore behavior happens in case of full restart after update. |
| 529 AttemptUserExit(); | 528 AttemptUserExit(); |
| 530 #else | 529 #else |
| 531 // Set the flag to restore state after the restart. | 530 // Set the flag to restore state after the restart. |
| 532 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); | 531 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); |
| 533 AttemptExit(); | 532 AttemptExit(); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 // If no more TabContents from Browsers, check the BackgroundPrintingManager. | 860 // If no more TabContents from Browsers, check the BackgroundPrintingManager. |
| 862 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) { | 861 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) { |
| 863 cur_ = *bg_printing_iterator_; | 862 cur_ = *bg_printing_iterator_; |
| 864 CHECK(cur_); | 863 CHECK(cur_); |
| 865 ++bg_printing_iterator_; | 864 ++bg_printing_iterator_; |
| 866 return; | 865 return; |
| 867 } | 866 } |
| 868 // Reached the end - no more TabContents. | 867 // Reached the end - no more TabContents. |
| 869 cur_ = NULL; | 868 cur_ = NULL; |
| 870 } | 869 } |
| OLD | NEW |