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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 } | 509 } |
507 | 510 |
508 // static | 511 // static |
509 void BrowserList::AttemptRestart() { | 512 void BrowserList::AttemptRestart() { |
510 #if defined(OS_CHROMEOS) | 513 #if defined(OS_CHROMEOS) |
511 // For CrOS instead of browser restart (which is not supported) perform a full | 514 // 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. | 515 // 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. | 516 // Same session restore behavior happens in case of full restart after update. |
514 AttemptUserExit(); | 517 AttemptUserExit(); |
515 #else | 518 #else |
| 519 |
| 520 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 521 switches::kEnableRestoreSessionState)) { |
| 522 BrowserVector::const_iterator it; |
| 523 for (it = begin(); it != end(); ++it) { |
| 524 (*it)->profile()->SaveSessionState(); |
| 525 } |
| 526 } |
| 527 |
516 // Set the flag to restore state after the restart. | 528 // Set the flag to restore state after the restart. |
517 PrefService* pref_service = g_browser_process->local_state(); | 529 PrefService* pref_service = g_browser_process->local_state(); |
518 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); | 530 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); |
519 AttemptExit(); | 531 AttemptExit(); |
520 #endif | 532 #endif |
521 } | 533 } |
522 | 534 |
523 // static | 535 // static |
524 void BrowserList::AttemptExit() { | 536 void BrowserList::AttemptExit() { |
525 // If we know that all browsers can be closed without blocking, | 537 // 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. | 869 // If no more TabContents from Browsers, check the BackgroundPrintingManager. |
858 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) { | 870 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) { |
859 cur_ = *bg_printing_iterator_; | 871 cur_ = *bg_printing_iterator_; |
860 CHECK(cur_); | 872 CHECK(cur_); |
861 ++bg_printing_iterator_; | 873 ++bg_printing_iterator_; |
862 return; | 874 return; |
863 } | 875 } |
864 // Reached the end - no more TabContents. | 876 // Reached the end - no more TabContents. |
865 cur_ = NULL; | 877 cur_ = NULL; |
866 } | 878 } |
OLD | NEW |