Chromium Code Reviews| 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/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 9 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 10 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 11 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/browser_shutdown.h" | 13 #include "chrome/browser/browser_shutdown.h" |
| 13 #include "chrome/browser/download/download_service.h" | 14 #include "chrome/browser/download/download_service.h" |
| 14 #include "chrome/browser/metrics/thread_watcher.h" | 15 #include "chrome/browser/metrics/thread_watcher.h" |
| 15 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
| 16 #include "chrome/browser/printing/background_printing_manager.h" | 17 #include "chrome/browser/printing/background_printing_manager.h" |
| 18 #include "chrome/browser/profiles/profile.h" | |
| 17 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
| 18 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
| 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| 23 #include "chrome/common/chrome_switches.h" | |
| 21 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 22 #include "content/browser/tab_contents/navigation_details.h" | 25 #include "content/browser/tab_contents/navigation_details.h" |
| 23 #include "content/public/browser/notification_registrar.h" | 26 #include "content/public/browser/notification_registrar.h" |
| 24 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/render_process_host.h" | 28 #include "content/public/browser/render_process_host.h" |
| 26 #include "content/public/common/result_codes.h" | 29 #include "content/public/common/result_codes.h" |
| 27 | 30 |
| 28 #if defined(OS_MACOSX) | 31 #if defined(OS_MACOSX) |
| 29 #include "chrome/browser/chrome_browser_application_mac.h" | 32 #include "chrome/browser/chrome_browser_application_mac.h" |
| 30 #endif | 33 #endif |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 500 // Reset the restart bit that might have been set in cancelled restart | 503 // Reset the restart bit that might have been set in cancelled restart |
| 501 // request. | 504 // request. |
| 502 PrefService* pref_service = g_browser_process->local_state(); | 505 PrefService* pref_service = g_browser_process->local_state(); |
| 503 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, false); | 506 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, false); |
| 504 #endif | 507 #endif |
| 505 AttemptExitInternal(); | 508 AttemptExitInternal(); |
| 506 } | 509 } |
| 507 | 510 |
| 508 // static | 511 // static |
| 509 void BrowserList::AttemptRestart() { | 512 void BrowserList::AttemptRestart() { |
| 513 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 514 switches::kEnableRestoreSessionState)) { | |
| 515 BrowserVector::const_iterator it; | |
| 516 for (it = begin(); it != end(); ++it) { | |
| 517 (*it)->profile()->SaveSessionState(); | |
| 518 } | |
| 519 } | |
|
erikwright (departed)
2011/11/29 13:43:22
Add a blank line.
marja
2011/11/29 14:58:21
Done.
| |
| 510 #if defined(OS_CHROMEOS) | 520 #if defined(OS_CHROMEOS) |
| 511 // For CrOS instead of browser restart (which is not supported) perform a full | 521 // For CrOS instead of browser restart (which is not supported) perform a full |
| 512 // sign out. Session will be only restored if user has that setting set. | 522 // sign out. Session will be only restored if user has that setting set. |
| 513 // Same session restore behavior happens in case of full restart after update. | 523 // Same session restore behavior happens in case of full restart after update. |
| 514 AttemptUserExit(); | 524 AttemptUserExit(); |
| 515 #else | 525 #else |
| 526 | |
|
erikwright (departed)
2011/11/29 13:43:22
Remove blank line.
marja
2011/11/29 14:58:21
Done.
| |
| 516 // Set the flag to restore state after the restart. | 527 // Set the flag to restore state after the restart. |
| 517 PrefService* pref_service = g_browser_process->local_state(); | 528 PrefService* pref_service = g_browser_process->local_state(); |
| 518 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); | 529 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); |
| 519 AttemptExit(); | 530 AttemptExit(); |
| 520 #endif | 531 #endif |
| 521 } | 532 } |
| 522 | 533 |
| 523 // static | 534 // static |
| 524 void BrowserList::AttemptExit() { | 535 void BrowserList::AttemptExit() { |
| 525 // If we know that all browsers can be closed without blocking, | 536 // If we know that all browsers can be closed without blocking, |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 857 // If no more TabContents from Browsers, check the BackgroundPrintingManager. | 868 // If no more TabContents from Browsers, check the BackgroundPrintingManager. |
| 858 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) { | 869 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) { |
| 859 cur_ = *bg_printing_iterator_; | 870 cur_ = *bg_printing_iterator_; |
| 860 CHECK(cur_); | 871 CHECK(cur_); |
| 861 ++bg_printing_iterator_; | 872 ++bg_printing_iterator_; |
| 862 return; | 873 return; |
| 863 } | 874 } |
| 864 // Reached the end - no more TabContents. | 875 // Reached the end - no more TabContents. |
| 865 cur_ = NULL; | 876 cur_ = NULL; |
| 866 } | 877 } |
| OLD | NEW |