diff options
author | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-28 21:12:57 +0000 |
---|---|---|
committer | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-28 21:12:57 +0000 |
commit | bc63a07355d1e7f57aaad72ef2b2b8359637c55d (patch) | |
tree | ff5fbfa2e0d8586a692268be18a60e1827c21179 | |
parent | 4c79b45fb6ebeebf308e2286811a714ac1c2fc07 (diff) | |
download | chromium_src-bc63a07355d1e7f57aaad72ef2b2b8359637c55d.zip chromium_src-bc63a07355d1e7f57aaad72ef2b2b8359637c55d.tar.gz chromium_src-bc63a07355d1e7f57aaad72ef2b2b8359637c55d.tar.bz2 |
Don't set exit_cleanly bit early if shutdown can be canceled.
Cleanups:
Added Browser::Restart.
Moved code around to reduce if/defs.
Updated the comment of APP_EXITING to emphasize the difference from APP_TERMINATING.
Review URL: http://codereview.chromium.org/7129027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90839 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.cc | 2 | ||||
-rw-r--r-- | chrome/browser/background/background_mode_manager.cc | 2 | ||||
-rw-r--r-- | chrome/browser/browser_main_posix.cc | 11 | ||||
-rw-r--r-- | chrome/browser/browser_process_impl.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 20 | ||||
-rw-r--r-- | chrome/browser/ui/browser_list.cc | 180 | ||||
-rw-r--r-- | chrome/browser/ui/browser_list.h | 45 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/restart_browser.mm | 7 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/update_recommended_dialog.cc | 8 | ||||
-rw-r--r-- | chrome/browser/ui/views/about_chrome_view.cc | 10 | ||||
-rw-r--r-- | chrome/browser/ui/views/frame/browser_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/views/update_recommended_message_box.cc | 9 | ||||
-rw-r--r-- | chrome/browser/ui/webui/flags_ui.cc | 12 | ||||
-rw-r--r-- | chrome/browser/ui/webui/options/language_options_handler.cc | 6 | ||||
-rw-r--r-- | chrome/test/in_process_browser_test.cc | 6 | ||||
-rw-r--r-- | content/common/notification_type.h | 11 |
16 files changed, 180 insertions, 155 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index ab18793..71964bd 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -431,7 +431,7 @@ bool TestingAutomationProvider::OnMessageReceived( void TestingAutomationProvider::OnChannelError() { if (!reinitialize_on_channel_error_ && browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) - BrowserList::CloseAllBrowsersAndExit(); + BrowserList::AttemptExit(); AutomationProvider::OnChannelError(); } diff --git a/chrome/browser/background/background_mode_manager.cc b/chrome/browser/background/background_mode_manager.cc index 05475b6..8629e8c 100644 --- a/chrome/browser/background/background_mode_manager.cc +++ b/chrome/browser/background/background_mode_manager.cc @@ -334,7 +334,7 @@ void BackgroundModeManager::ExecuteCommand(int command_id) { break; case IDC_EXIT: UserMetrics::RecordAction(UserMetricsAction("Exit")); - BrowserList::CloseAllBrowsersAndExit(); + BrowserList::AttemptExit(); break; case IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND: { // Background mode must already be enabled (as otherwise this menu would diff --git a/chrome/browser/browser_main_posix.cc b/chrome/browser/browser_main_posix.cc index 5b44c0c..42dde45 100644 --- a/chrome/browser/browser_main_posix.cc +++ b/chrome/browser/browser_main_posix.cc @@ -133,12 +133,15 @@ void ShutdownDetector::ThreadMain() { } bytes_read += ret; } while (bytes_read < sizeof(signal)); - VLOG(1) << "Handling shutdown for signal " << signal << "."; +#if defined(OS_CHROMEOS) + // On ChromeOS, exiting on signal should be always clean. + Task* task = NewRunnableFunction(BrowserList::ExitCleanly); +#else + Task* task = NewRunnableFunction(BrowserList::AttemptExit); +#endif - if (!BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - NewRunnableFunction(BrowserList::CloseAllBrowsersAndExit))) { + if (!BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, task)) { // Without a UI thread to post the exit task to, there aren't many // options. Raise the signal again. The default handler will pick it up // and cause an ungraceful exit. diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index 43e90b2..4aefc4ee 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -1126,7 +1126,7 @@ void BrowserProcessImpl::RestartPersistentInstance() { } DLOG(WARNING) << "Shutting down current instance of the browser."; - BrowserList::CloseAllBrowsersAndExit(); + BrowserList::AttemptExit(); // Transfer ownership to Upgrade. upgrade_util::SetNewCommandLine(new_cl.release()); diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 04c2ad2..3fa7eea 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -1650,25 +1650,7 @@ void Browser::ShowKeyboardOverlay() { void Browser::Exit() { UserMetrics::RecordAction(UserMetricsAction("Exit")); -#if defined(OS_CHROMEOS) - chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutStarted", false); - // Write /tmp/uptime-logout-started as well. - const char kLogoutStarted[] = "logout-started"; - chromeos::BootTimesLoader::Get()->RecordCurrentStats(kLogoutStarted); - - // Login screen should show up in owner's locale. - PrefService* state = g_browser_process->local_state(); - if (state) { - std::string owner_locale = state->GetString(prefs::kOwnerLocale); - if (!owner_locale.empty() && - state->GetString(prefs::kApplicationLocale) != owner_locale && - !state->IsManagedPreference(prefs::kApplicationLocale)) { - state->SetString(prefs::kApplicationLocale, owner_locale); - state->ScheduleSavePersistentPrefs(); - } - } -#endif - BrowserList::Exit(); + BrowserList::AttemptUserExit(); } void Browser::BookmarkCurrentPage() { diff --git a/chrome/browser/ui/browser_list.cc b/chrome/browser/ui/browser_list.cc index 764654a..cc536f1 100644 --- a/chrome/browser/ui/browser_list.cc +++ b/chrome/browser/ui/browser_list.cc @@ -10,10 +10,12 @@ #include "build/build_config.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_shutdown.h" +#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/printing/background_printing_manager.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" +#include "chrome/common/pref_names.h" #include "content/browser/renderer_host/render_process_host.h" #include "content/browser/tab_contents/navigation_details.h" #include "content/common/notification_registrar.h" @@ -177,6 +179,53 @@ printing::BackgroundPrintingManager* GetBackgroundPrintingManager() { return g_browser_process->background_printing_manager(); } +// Returns true if all browsers can be closed without user interaction. +// This currently checks if there is pending download, or if it needs to +// handle unload handler. +bool AreAllBrowsersCloseable() { + for (BrowserList::const_iterator i = BrowserList::begin(); + i != BrowserList::end(); ++i) { + bool normal_downloads_are_present = false; + bool incognito_downloads_are_present = false; + (*i)->CheckDownloadsInProgress(&normal_downloads_are_present, + &incognito_downloads_are_present); + if (normal_downloads_are_present || + incognito_downloads_are_present || + (*i)->TabsNeedBeforeUnloadFired()) + return false; + } + return true; +} + +#if defined(OS_CHROMEOS) + +bool signout = false; + +// Fast shutdown for ChromeOS. It tells session manager to start +// shutdown process when closing browser windows won't be canceled. +// Returns true if fast shutdown is successfully started. +bool FastShutdown() { + signout = true; + if (chromeos::CrosLibrary::Get()->EnsureLoaded() + && AreAllBrowsersCloseable()) { + BrowserList::NotifyAndTerminate(true); + return true; + } + return false; +} + +void NotifyWindowManagerAboutSignout() { + static bool notified = false; + if (!notified) { + // Let the window manager know that we're going away before we start closing + // windows so it can display a graceful transition to a black screen. + chromeos::WmIpc::instance()->NotifyAboutSignout(); + notified = true; + } +} + +#endif + } // namespace BrowserList::BrowserVector BrowserList::browsers_; @@ -212,27 +261,27 @@ void BrowserList::MarkAsCleanShutdown() { } } -#if defined(OS_CHROMEOS) -// static -void BrowserList::NotifyWindowManagerAboutSignout() { - static bool notified = false; - if (!notified) { - // Let the window manager know that we're going away before we start closing - // windows so it can display a graceful transition to a black screen. - chromeos::WmIpc::instance()->NotifyAboutSignout(); - notified = true; - } -} - -// static -bool BrowserList::signout_ = false; +void BrowserList::AttemptExitInternal() { + NotificationService::current()->Notify( + NotificationType::APP_EXITING, + NotificationService::AllSources(), + NotificationService::NoDetails()); +#if !defined(OS_MACOSX) + // On most platforms, closing all windows causes the application to exit. + CloseAllBrowsers(); +#else + // On the Mac, the application continues to run once all windows are closed. + // Terminate will result in a CloseAllBrowsers() call, and once (and if) + // that is done, will cause the application to exit cleanly. + chrome_browser_application_mac::Terminate(); #endif +} // static void BrowserList::NotifyAndTerminate(bool fast_path) { #if defined(OS_CHROMEOS) - if (!signout_) return; + if (!signout) return; NotifyWindowManagerAboutSignout(); #endif @@ -317,31 +366,6 @@ void BrowserList::RemoveObserver(BrowserList::Observer* observer) { observers_.RemoveObserver(observer); } -#if defined(OS_CHROMEOS) -// static -bool BrowserList::NeedBeforeUnloadFired() { - bool need_before_unload_fired = false; - for (const_iterator i = begin(); i != end(); ++i) { - need_before_unload_fired = need_before_unload_fired || - (*i)->TabsNeedBeforeUnloadFired(); - } - return need_before_unload_fired; -} - -// static -bool BrowserList::PendingDownloads() { - for (const_iterator i = begin(); i != end(); ++i) { - bool normal_downloads_are_present = false; - bool incognito_downloads_are_present = false; - (*i)->CheckDownloadsInProgress(&normal_downloads_are_present, - &incognito_downloads_are_present); - if (normal_downloads_are_present || incognito_downloads_are_present) - return true; - } - return false; -} -#endif - // static void BrowserList::CloseAllBrowsers() { bool session_ending = @@ -397,40 +421,72 @@ void BrowserList::CloseAllBrowsers() { } // static -void BrowserList::Exit() { +void BrowserList::AttemptUserExit() { #if defined(OS_CHROMEOS) - signout_ = true; - // Fast shutdown for ChromeOS when there's no unload processing to be done. - if (chromeos::CrosLibrary::Get()->EnsureLoaded() - && !NeedBeforeUnloadFired() - && !PendingDownloads()) { - NotifyAndTerminate(true); + chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutStarted", false); + // Write /tmp/uptime-logout-started as well. + const char kLogoutStarted[] = "logout-started"; + chromeos::BootTimesLoader::Get()->RecordCurrentStats(kLogoutStarted); + + // Login screen should show up in owner's locale. + PrefService* state = g_browser_process->local_state(); + if (state) { + std::string owner_locale = state->GetString(prefs::kOwnerLocale); + if (!owner_locale.empty() && + state->GetString(prefs::kApplicationLocale) != owner_locale && + !state->IsManagedPreference(prefs::kApplicationLocale)) { + state->SetString(prefs::kApplicationLocale, owner_locale); + state->ScheduleSavePersistentPrefs(); + } + } + if (FastShutdown()) { return; } +#else + // Reset the restart bit that might have been set in cancelled restart + // request. + PrefService* pref_service = g_browser_process->local_state(); + pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, false); #endif - CloseAllBrowsersAndExit(); + AttemptExitInternal(); } // static -void BrowserList::CloseAllBrowsersAndExit() { - MarkAsCleanShutdown(); // Don't notify users of crashes beyond this point. - NotificationService::current()->Notify( - NotificationType::APP_EXITING, - NotificationService::AllSources(), - NotificationService::NoDetails()); - -#if !defined(OS_MACOSX) - // On most platforms, closing all windows causes the application to exit. - CloseAllBrowsers(); +void BrowserList::AttemptRestart() { +#if defined(OS_CHROMEOS) + // For CrOS instead of browser restart (which is not supported) perform a full + // sign out. Session will be only restored if user has that setting set. + // Same session restore behavior happens in case of full restart after update. + AttemptUserExit(); #else - // On the Mac, the application continues to run once all windows are closed. - // Terminate will result in a CloseAllBrowsers() call, and once (and if) - // that is done, will cause the application to exit cleanly. - chrome_browser_application_mac::Terminate(); + // Set the flag to restore state after the restart. + PrefService* pref_service = g_browser_process->local_state(); + pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); + AttemptExit(); #endif } // static +void BrowserList::AttemptExit() { + // If we know that all browsers can be closed without blocking, + // don't notify users of crashes beyond this point. + // Note that MarkAsCleanShutdown does not set UMA's exit cleanly bit + // so crashes during shutdown are still reported in UMA. + if (AreAllBrowsersCloseable()) + MarkAsCleanShutdown(); + AttemptExitInternal(); +} + +#if defined(OS_CHROMEOS) +// static +void BrowserList::ExitCleanly() { + // We always mark exit cleanly. + MarkAsCleanShutdown(); + AttemptExitInternal(); +} +#endif + +// static void BrowserList::SessionEnding() { // EndSession is invoked once per frame. Only do something the first time. static bool already_ended = false; diff --git a/chrome/browser/ui/browser_list.h b/chrome/browser/ui/browser_list.h index caa2e2f..1e01924 100644 --- a/chrome/browser/ui/browser_list.h +++ b/chrome/browser/ui/browser_list.h @@ -104,14 +104,37 @@ class BrowserList { // 2. An update exe is present in the install folder. static bool CanRestartForUpdate(); - // Called from Browser::Exit. - static void Exit(); + // Starts a user initiated exit process. Called from Browser::Exit. + // On platforms other than ChromeOS, this is equivalent to + // CloseAllBrowsersAndExit. On ChromeOS, this tells session manager + // that chrome is signing out, which lets session manager send + // SIGTERM to start actual exit process. + static void AttemptUserExit(); + + // Starts a user initiated restart process. On platforms other than + // chromeos, this sets a restart bit in the preference so that + // chrome will be restarted at the end of shutdown process. On + // ChromeOS, this simply exits the chrome, which lets sesssion + // manager re-launch the browser with restore last session flag. + static void AttemptRestart(); + + // Attempt to exit by closing all browsers. This is equivalent to + // CloseAllBrowsers() on platforms where the application exits + // when no more windows are remaining. On other platforms (the Mac), + // this will additionally exit the application if all browsers are + // successfully closed. + // Note that he exit process may be interrupted by download or + // unload handler, and the browser may or may not exit. + static void AttemptExit(); - // Closes all browsers and exits. This is equivalent to - // CloseAllBrowsers(true) on platforms where the application exits when no - // more windows are remaining. On other platforms (the Mac), this will - // additionally exit the application. - static void CloseAllBrowsersAndExit(); +#if defined(OS_CHROMEOS) + // This is equivalent to AttemptUserExit, except that it always set + // exit cleanly bit. ChroemOS checks if it can exit without user + // interactions, so it will always exit the browser. This is used to + // handle SIGTERM on chromeos which is a signal to force shutdown + // the chrome. + static void ExitCleanly(); +#endif // Closes all browsers. If the session is ending the windows are closed // directly. Otherwise the windows are closed by way of posting a WM_CLOSE @@ -180,13 +203,7 @@ class BrowserList { // Helper method to remove a browser instance from a list of browsers static void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list); static void MarkAsCleanShutdown(); -#if defined(OS_CHROMEOS) - static bool NeedBeforeUnloadFired(); - static bool PendingDownloads(); - static void NotifyWindowManagerAboutSignout(); - - static bool signout_; -#endif + static void AttemptExitInternal(); static BrowserVector browsers_; static BrowserVector last_active_browsers_; diff --git a/chrome/browser/ui/cocoa/restart_browser.mm b/chrome/browser/ui/cocoa/restart_browser.mm index cc7be89..ae97a77 100644 --- a/chrome/browser/ui/cocoa/restart_browser.mm +++ b/chrome/browser/ui/cocoa/restart_browser.mm @@ -5,9 +5,7 @@ #import "chrome/browser/ui/cocoa/restart_browser.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/ui/browser_list.h" -#include "chrome/common/pref_names.h" #include "grit/app_strings.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -43,10 +41,7 @@ if (returnCode == NSAlertFirstButtonReturn) { // Nothing to do. User will restart later. } else if (returnCode == NSAlertSecondButtonReturn) { - // Set the flag to restore state after the restart. - PrefService* pref_service = g_browser_process->local_state(); - pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); - BrowserList::CloseAllBrowsersAndExit(); + BrowserList::AttemptRestart(); } else { NOTREACHED(); } diff --git a/chrome/browser/ui/gtk/update_recommended_dialog.cc b/chrome/browser/ui/gtk/update_recommended_dialog.cc index 3c57dcc..7941a2e 100644 --- a/chrome/browser/ui/gtk/update_recommended_dialog.cc +++ b/chrome/browser/ui/gtk/update_recommended_dialog.cc @@ -7,10 +7,8 @@ #include <gtk/gtk.h> #include "chrome/browser/browser_process.h" -#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/gtk/gtk_util.h" -#include "chrome/common/pref_names.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -56,11 +54,7 @@ void UpdateRecommendedDialog::OnResponse(GtkWidget* dialog, int response_id) { gtk_widget_destroy(dialog_); if (response_id == GTK_RESPONSE_ACCEPT) { - // Set the flag to restore the last session on shutdown. - PrefService* pref_service = g_browser_process->local_state(); - pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); - - BrowserList::CloseAllBrowsersAndExit(); + BrowserList::AttemptRestart(); } delete this; diff --git a/chrome/browser/ui/views/about_chrome_view.cc b/chrome/browser/ui/views/about_chrome_view.cc index b681fa3..0e005a6 100644 --- a/chrome/browser/ui/views/about_chrome_view.cc +++ b/chrome/browser/ui/views/about_chrome_view.cc @@ -18,11 +18,11 @@ #include "base/win/windows_version.h" #include "chrome/browser/google/google_util.h" #include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/platform_util.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/views/window.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_version_info.h" -#include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "chrome/installer/util/browser_distribution.h" #include "content/browser/user_metrics.h" @@ -603,13 +603,7 @@ bool AboutChromeView::IsModal() const { } bool AboutChromeView::Accept() { -#if defined(OS_WIN) - // Set the flag to restore the last session on shutdown. - PrefService* pref_service = g_browser_process->local_state(); - pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); - BrowserList::CloseAllBrowsersAndExit(); -#endif - + BrowserList::AttemptRestart(); return true; } diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 8bc2535..66c3f1d 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -1687,8 +1687,8 @@ const views::Widget* BrowserView::GetWidget() const { bool BrowserView::CanClose() { // You cannot close a frame for which there is an active originating drag // session. - if (tabstrip_ && !tabstrip_->IsTabStripCloseable()) - return false; + if (tabstrip_ && !tabstrip_->IsTabStripCloseable()) + return false; // Give beforeunload handlers the chance to cancel the close before we hide // the window below. diff --git a/chrome/browser/ui/views/update_recommended_message_box.cc b/chrome/browser/ui/views/update_recommended_message_box.cc index 7fd9a3c..ee22ba3 100644 --- a/chrome/browser/ui/views/update_recommended_message_box.cc +++ b/chrome/browser/ui/views/update_recommended_message_box.cc @@ -6,10 +6,8 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/views/window.h" -#include "chrome/common/pref_names.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -33,16 +31,11 @@ void UpdateRecommendedMessageBox::ShowMessageBox( } bool UpdateRecommendedMessageBox::Accept() { - // Set the flag to restore the last session on shutdown. - PrefService* pref_service = g_browser_process->local_state(); - pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); - #if defined(OS_CHROMEOS) chromeos::CrosLibrary::Get()->GetPowerLibrary()->RequestRestart(); // If running the Chrome OS build, but we're not on the device, fall through #endif - BrowserList::CloseAllBrowsersAndExit(); - + BrowserList::AttemptRestart(); return true; } diff --git a/chrome/browser/ui/webui/flags_ui.cc b/chrome/browser/ui/webui/flags_ui.cc index a6f8376..07c0c1f 100644 --- a/chrome/browser/ui/webui/flags_ui.cc +++ b/chrome/browser/ui/webui/flags_ui.cc @@ -179,17 +179,7 @@ void FlagsDOMHandler::HandleEnableFlagsExperimentMessage( } void FlagsDOMHandler::HandleRestartBrowser(const ListValue* args) { -#if !defined(OS_CHROMEOS) - // Set the flag to restore state after the restart. - PrefService* pref_service = g_browser_process->local_state(); - pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); - BrowserList::CloseAllBrowsersAndExit(); -#else - // For CrOS instead of browser restart (which is not supported) perform a full - // sign out. Session will be only restored is user has that setting set. - // Same session restore behavior happens in case of full restart after update. - BrowserList::GetLastActive()->Exit(); -#endif + BrowserList::AttemptRestart(); } } // namespace diff --git a/chrome/browser/ui/webui/options/language_options_handler.cc b/chrome/browser/ui/webui/options/language_options_handler.cc index 31f188b..684d78b 100644 --- a/chrome/browser/ui/webui/options/language_options_handler.cc +++ b/chrome/browser/ui/webui/options/language_options_handler.cc @@ -110,9 +110,5 @@ void LanguageOptionsHandler::SetApplicationLocale( void LanguageOptionsHandler::RestartCallback(const ListValue* args) { UserMetrics::RecordAction(UserMetricsAction("LanguageOptions_Restart")); - - // Set the flag to restore state after the restart. - PrefService* pref_service = g_browser_process->local_state(); - pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); - BrowserList::CloseAllBrowsersAndExit(); + BrowserList::AttemptRestart(); } diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc index 69c8890..77a0d63 100644 --- a/chrome/test/in_process_browser_test.cc +++ b/chrome/test/in_process_browser_test.cc @@ -349,11 +349,11 @@ void InProcessBrowserTest::QuitBrowsers() { if (BrowserList::size() == 0) return; - // Invoke CloseAllBrowsersAndExit on a running message loop. - // CloseAllBrowsersAndExit exits the message loop after everything has been + // Invoke CloseAllBrowsersAndMayExit on a running message loop. + // CloseAllBrowsersAndMayExit exits the message loop after everything has been // shut down properly. MessageLoopForUI::current()->PostTask( FROM_HERE, - NewRunnableFunction(&BrowserList::CloseAllBrowsersAndExit)); + NewRunnableFunction(&BrowserList::AttemptExit)); ui_test_utils::RunMessageLoop(); } diff --git a/content/common/notification_type.h b/content/common/notification_type.h index c51f947..806a676 100644 --- a/content/common/notification_type.h +++ b/content/common/notification_type.h @@ -240,9 +240,14 @@ class NotificationType { #endif // This is sent when the user has chosen to exit the app, but before any - // browsers have closed. This is only sent if the user chooses the exit menu - // item, not if Chrome exists by some other means (such as the user closing - // the last window). The source and details are unspecified. + // browsers have closed. This is sent if the user chooses to exit + // (via exit menu item or keyboard shortcut) or to restart the process + // (such as in flags page), not if Chrome exists by some other means + // (such as the user closing the last window). Note that receiving this + // notification does not necessarily mean the process will exit + // because the shutdown process can be cancelled by unload handler. + // Use APP_TERMINATING for such needs. + // The source and details are unspecified. APP_EXITING, // Indicates that a top window has been closed. The source is the HWND |