| 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/browser_shutdown.h" | 26 #include "content/public/browser/browser_shutdown.h" |
| 24 #include "content/public/browser/notification_registrar.h" | 27 #include "content/public/browser/notification_registrar.h" |
| 25 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 26 #include "content/public/browser/render_process_host.h" | 29 #include "content/public/browser/render_process_host.h" |
| 27 #include "content/public/common/result_codes.h" | 30 #include "content/public/common/result_codes.h" |
| 28 | 31 |
| 29 #if defined(OS_MACOSX) | 32 #if defined(OS_MACOSX) |
| 30 #include "chrome/browser/chrome_browser_application_mac.h" | 33 #include "chrome/browser/chrome_browser_application_mac.h" |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 // 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 |
| 502 // request. | 505 // request. |
| 503 PrefService* pref_service = g_browser_process->local_state(); | 506 PrefService* pref_service = g_browser_process->local_state(); |
| 504 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, false); | 507 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, false); |
| 505 #endif | 508 #endif |
| 506 AttemptExitInternal(); | 509 AttemptExitInternal(); |
| 507 } | 510 } |
| 508 | 511 |
| 509 // static | 512 // static |
| 510 void BrowserList::AttemptRestart() { | 513 void BrowserList::AttemptRestart() { |
| 514 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 515 switches::kEnableRestoreSessionState)) { |
| 516 BrowserVector::const_iterator it; |
| 517 for (it = begin(); it != end(); ++it) |
| 518 (*it)->profile()->SaveSessionState(); |
| 519 } |
| 520 |
| 511 #if defined(OS_CHROMEOS) | 521 #if defined(OS_CHROMEOS) |
| 512 // For CrOS instead of browser restart (which is not supported) perform a full | 522 // For CrOS instead of browser restart (which is not supported) perform a full |
| 513 // sign out. Session will be only restored if user has that setting set. | 523 // sign out. Session will be only restored if user has that setting set. |
| 514 // Same session restore behavior happens in case of full restart after update. | 524 // Same session restore behavior happens in case of full restart after update. |
| 515 AttemptUserExit(); | 525 AttemptUserExit(); |
| 516 #else | 526 #else |
| 517 // Set the flag to restore state after the restart. | 527 // Set the flag to restore state after the restart. |
| 518 PrefService* pref_service = g_browser_process->local_state(); | 528 PrefService* pref_service = g_browser_process->local_state(); |
| 519 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); | 529 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); |
| 520 AttemptExit(); | 530 AttemptExit(); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 // If no more TabContents from Browsers, check the BackgroundPrintingManager. | 858 // If no more TabContents from Browsers, check the BackgroundPrintingManager. |
| 849 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) { | 859 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) { |
| 850 cur_ = *bg_printing_iterator_; | 860 cur_ = *bg_printing_iterator_; |
| 851 CHECK(cur_); | 861 CHECK(cur_); |
| 852 ++bg_printing_iterator_; | 862 ++bg_printing_iterator_; |
| 853 return; | 863 return; |
| 854 } | 864 } |
| 855 // Reached the end - no more TabContents. | 865 // Reached the end - no more TabContents. |
| 856 cur_ = NULL; | 866 cur_ = NULL; |
| 857 } | 867 } |
| OLD | NEW |