summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-22 10:42:01 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-22 10:42:01 +0000
commit7df2c03338f66618fd790bc959ae58e4e5cfaa8b (patch)
tree85fe293832102cca4412f64c4d20742d85881e32
parent0135aa172211433181e1cdaf009ff77716e87ff7 (diff)
downloadchromium_src-7df2c03338f66618fd790bc959ae58e4e5cfaa8b.zip
chromium_src-7df2c03338f66618fd790bc959ae58e4e5cfaa8b.tar.gz
chromium_src-7df2c03338f66618fd790bc959ae58e4e5cfaa8b.tar.bz2
* Make AttemptExit/AttemptRestart do the right thing on chromeos
AttemptExit now simply calls AttemptUserExit. They're the same on ChromeOS. AttemptRestart simply exists so that the session manager will restart the chrome. * Don't use ExitCleanly to restart the browser, as this is meant for SIGTERM. * Minior cleanup: rename g_session_manager_requested_shutdown to g_send_stop_request_to_sesion_manager. BUG=335195 Review URL: https://codereview.chromium.org/141143002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246279 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.cc2
-rw-r--r--chrome/browser/chromeos/login/login_utils.cc18
-rw-r--r--chrome/browser/extensions/api/autotest_private/autotest_private_api.cc7
-rw-r--r--chrome/browser/lifetime/application_lifetime.cc33
-rw-r--r--chrome/browser/lifetime/application_lifetime.h12
-rw-r--r--chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc2
-rw-r--r--chrome/browser/ui/webui/flags_ui.cc6
7 files changed, 41 insertions, 39 deletions
diff --git a/chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.cc b/chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.cc
index 846fccc..7a94e04 100644
--- a/chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.cc
+++ b/chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.cc
@@ -195,7 +195,7 @@ void KioskModeSettings::VerifyModeIsKnown(
base::TimeDelta::FromMilliseconds(kDeviceModeFetchRetryDelayMs));
break;
case policy::DEVICE_MODE_RETAIL_KIOSK:
- chrome::ExitCleanly();
+ chrome::AttemptRestart();
break;
default:
break;
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc
index b0b104b..57df965 100644
--- a/chrome/browser/chromeos/login/login_utils.cc
+++ b/chrome/browser/chromeos/login/login_utils.cc
@@ -197,9 +197,9 @@ class LoginUtilsImpl
// Initializes RLZ. If |disabled| is true, RLZ pings are disabled.
void InitRlz(Profile* user_profile, bool disabled);
- // Attempts exiting browser process and esures this does not happen
- // while we are still fetching new OAuth refresh tokens.
- void AttemptExit(Profile* profile);
+ // Attempts restarting the browser process and esures that this does
+ // not happen while we are still fetching new OAuth refresh tokens.
+ void AttemptRestart(Profile* profile);
UserContext user_context_;
@@ -308,7 +308,7 @@ void LoginUtilsImpl::DoBrowserLaunchOnLocaleLoadedImpl(
VLOG(1) << "Restarting to apply per-session flags...";
DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser(
UserManager::Get()->GetActiveUser()->email(), flags);
- AttemptExit(profile);
+ AttemptRestart(profile);
return;
}
@@ -794,9 +794,9 @@ void LoginUtilsImpl::OnNewRefreshTokenAvaiable(Profile* user_profile) {
User::OAUTH2_TOKEN_STATUS_VALID);
LOG(WARNING) << "Exiting after new refresh token fetched";
- // We need to exit cleanly in this case to make sure OAuth2 RT is actually
+ // We need to restart cleanly in this case to make sure OAuth2 RT is actually
// saved.
- chrome::ExitCleanly();
+ chrome::AttemptRestart();
}
void LoginUtilsImpl::OnConnectionTypeChanged(
@@ -828,10 +828,10 @@ void LoginUtilsImpl::OnConnectionTypeChanged(
}
}
-void LoginUtilsImpl::AttemptExit(Profile* profile) {
+void LoginUtilsImpl::AttemptRestart(Profile* profile) {
if (session_restore_strategy_ !=
OAuth2LoginManager::RESTORE_FROM_COOKIE_JAR) {
- chrome::AttemptExit();
+ chrome::AttemptRestart();
return;
}
@@ -843,7 +843,7 @@ void LoginUtilsImpl::AttemptExit(Profile* profile) {
OAuth2LoginManager::SESSION_RESTORE_PREPARING &&
login_manager->state() !=
OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS) {
- chrome::AttemptExit();
+ chrome::AttemptRestart();
return;
}
diff --git a/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc b/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
index 0fff430..3c6cf24 100644
--- a/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
+++ b/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
@@ -81,13 +81,6 @@ bool AutotestPrivateShutdownFunction::RunImpl() {
DVLOG(1) << "AutotestPrivateShutdownFunction " << params->force;
-#if defined(OS_CHROMEOS)
- if (params->force) {
- if (!AutotestPrivateAPIFactory::GetForProfile(GetProfile())->test_mode())
- chrome::ExitCleanly();
- return true;
- }
-#endif
if (!AutotestPrivateAPIFactory::GetForProfile(GetProfile())->test_mode())
chrome::AttemptExit();
return true;
diff --git a/chrome/browser/lifetime/application_lifetime.cc b/chrome/browser/lifetime/application_lifetime.cc
index 60df0480..cc1c33e 100644
--- a/chrome/browser/lifetime/application_lifetime.cc
+++ b/chrome/browser/lifetime/application_lifetime.cc
@@ -79,8 +79,8 @@ bool AreAllBrowsersCloseable() {
int g_keep_alive_count = 0;
#if defined(OS_CHROMEOS)
-// Whether a session manager requested to shutdown.
-bool g_session_manager_requested_shutdown = true;
+// Whether chrome should send stop request to a session manager.
+bool g_send_stop_request_to_session_manager = false;
#endif
} // namespace
@@ -168,7 +168,7 @@ void AttemptUserExit() {
state->CommitPendingWrite();
}
}
- g_session_manager_requested_shutdown = false;
+ g_send_stop_request_to_session_manager = true;
// On ChromeOS, always terminate the browser, regardless of the result of
// AreAllBrowsersCloseable(). See crbug.com/123107.
chrome::NotifyAndTerminate(true);
@@ -205,10 +205,12 @@ void AttemptRestart() {
pref_service->SetBoolean(prefs::kWasRestarted, true);
#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();
+ DCHECK(!g_send_stop_request_to_session_manager);
+ // Make sure we don't send stop request to the session manager.
+ g_send_stop_request_to_session_manager = false;
+ // Run exit process in clean stack.
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&ExitCleanly));
#else
// Set the flag to restore state after the restart.
pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true);
@@ -218,6 +220,10 @@ void AttemptRestart() {
#endif
void AttemptExit() {
+#if defined(OS_CHROMEOS)
+ // On ChromeOS, user exit and system exits are the same.
+ AttemptUserExit();
+#else
// 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
@@ -228,6 +234,7 @@ void AttemptExit() {
MarkAsCleanShutdown();
#endif
AttemptExitInternal(true);
+#endif
}
#if defined(OS_CHROMEOS)
@@ -360,17 +367,19 @@ void NotifyAndTerminate(bool fast_path) {
if (update_engine_client->GetLastStatus().status ==
chromeos::UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT) {
update_engine_client->RebootAfterUpdate();
- } else if (!g_session_manager_requested_shutdown) {
+ } else if (g_send_stop_request_to_session_manager) {
// Don't ask SessionManager to stop session if the shutdown request comes
// from session manager.
chromeos::DBusThreadManager::Get()->GetSessionManagerClient()
->StopSession();
}
} else {
- // If running the Chrome OS build, but we're not on the device, act
- // as if we received signal from SessionManager.
- content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
- base::Bind(&ExitCleanly));
+ if (g_send_stop_request_to_session_manager) {
+ // If running the Chrome OS build, but we're not on the device, act
+ // as if we received signal from SessionManager.
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&ExitCleanly));
+ }
}
#endif
}
diff --git a/chrome/browser/lifetime/application_lifetime.h b/chrome/browser/lifetime/application_lifetime.h
index 51638cd..2e526df 100644
--- a/chrome/browser/lifetime/application_lifetime.h
+++ b/chrome/browser/lifetime/application_lifetime.h
@@ -59,11 +59,13 @@ void AttemptRestartToMetroMode();
void AttemptExit();
#if defined(OS_CHROMEOS)
-// This is equivalent to AttemptUserExit, except that it always set
-// exit cleanly bit. ChromeOS 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.
+// Shutdown chrome cleanly without blocking. This is called
+// when SIGTERM is received on Chrome OS, and always sets
+// exit-cleanly bit and exits the browser, even if there is
+// ongoing downloads or a page with onbeforeunload handler.
+//
+// If you need to exit or restart in your code on ChromeOS,
+// use AttemptExit or AttemptRestart respectively.
void ExitCleanly();
#endif
diff --git a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
index eaa5dac..4d3cba0 100644
--- a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
@@ -239,7 +239,7 @@ void CoreOobeHandler::HandleSetDeviceRequisition(
g_browser_process->platform_part()->browser_policy_connector_chromeos();
connector->GetDeviceCloudPolicyManager()->SetDeviceRequisition(requisition);
// Exit Chrome to force the restart as soon as a new requisition is set.
- chrome::ExitCleanly();
+ chrome::AttemptRestart();
}
void CoreOobeHandler::HandleScreenAssetsLoaded(
diff --git a/chrome/browser/ui/webui/flags_ui.cc b/chrome/browser/ui/webui/flags_ui.cc
index c058268..aca6d1b 100644
--- a/chrome/browser/ui/webui/flags_ui.cc
+++ b/chrome/browser/ui/webui/flags_ui.cc
@@ -218,9 +218,7 @@ void FlagsDOMHandler::HandleEnableFlagsExperimentMessage(
void FlagsDOMHandler::HandleRestartBrowser(const base::ListValue* args) {
DCHECK(flags_storage_);
-#if !defined(OS_CHROMEOS)
- chrome::AttemptRestart();
-#else
+#if defined(OS_CHROMEOS)
// On ChromeOS be less intrusive and restart inside the user session after
// we apply the newly selected flags.
CommandLine user_flags(CommandLine::NO_PROGRAM);
@@ -234,8 +232,8 @@ void FlagsDOMHandler::HandleRestartBrowser(const base::ListValue* args) {
chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
SetFlagsForUser(chromeos::UserManager::Get()->GetActiveUser()->email(),
flags);
- chrome::ExitCleanly();
#endif
+ chrome::AttemptRestart();
}
void FlagsDOMHandler::HandleResetAllFlags(const base::ListValue* args) {