OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/lifetime/application_lifetime.h" | 5 #include "chrome/browser/lifetime/application_lifetime.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 // Tell everyone that we are shutting down. | 125 // Tell everyone that we are shutting down. |
126 browser_shutdown::SetTryingToQuit(true); | 126 browser_shutdown::SetTryingToQuit(true); |
127 | 127 |
128 #if BUILDFLAG(ENABLE_SESSION_SERVICE) | 128 #if BUILDFLAG(ENABLE_SESSION_SERVICE) |
129 // If ShuttingDownWithoutClosingBrowsers() returns true, the session | 129 // If ShuttingDownWithoutClosingBrowsers() returns true, the session |
130 // services may not get a chance to shut down normally, so explicitly shut | 130 // services may not get a chance to shut down normally, so explicitly shut |
131 // them down here to ensure they have a chance to persist their data. | 131 // them down here to ensure they have a chance to persist their data. |
132 ProfileManager::ShutdownSessionServices(); | 132 ProfileManager::ShutdownSessionServices(); |
133 #endif | 133 #endif |
134 | 134 |
135 chrome::NotifyAndTerminate(true); | 135 chrome::NotifyAndTerminate(/*fast_path=*/true,/*always_reboot=*/false); |
James Cook
2016/11/30 23:01:41
ditto, and throughout
Greg K
2016/12/01 19:44:43
Done.
| |
136 chrome::OnAppExiting(); | 136 chrome::OnAppExiting(); |
137 } | 137 } |
138 | 138 |
139 void CloseAllBrowsers() { | 139 void CloseAllBrowsers() { |
140 // If there are no browsers and closing the last browser would quit the | 140 // If there are no browsers and closing the last browser would quit the |
141 // application, send the APP_TERMINATING action here. Otherwise, it will be | 141 // application, send the APP_TERMINATING action here. Otherwise, it will be |
142 // sent by RemoveBrowser() when the last browser has closed. | 142 // sent by RemoveBrowser() when the last browser has closed. |
143 if (chrome::GetTotalBrowserCount() == 0 && | 143 if (chrome::GetTotalBrowserCount() == 0 && |
144 (browser_shutdown::IsTryingToQuit() || | 144 (browser_shutdown::IsTryingToQuit() || |
145 !KeepAliveRegistry::GetInstance()->IsKeepingAlive())) { | 145 !KeepAliveRegistry::GetInstance()->IsKeepingAlive())) { |
(...skipping 28 matching lines...) Expand all Loading... | |
174 state->GetString(prefs::kApplicationLocale) != owner_locale && | 174 state->GetString(prefs::kApplicationLocale) != owner_locale && |
175 !state->IsManagedPreference(prefs::kApplicationLocale)) { | 175 !state->IsManagedPreference(prefs::kApplicationLocale)) { |
176 state->SetString(prefs::kApplicationLocale, owner_locale); | 176 state->SetString(prefs::kApplicationLocale, owner_locale); |
177 TRACE_EVENT0("shutdown", "CommitPendingWrite"); | 177 TRACE_EVENT0("shutdown", "CommitPendingWrite"); |
178 state->CommitPendingWrite(); | 178 state->CommitPendingWrite(); |
179 } | 179 } |
180 } | 180 } |
181 g_send_stop_request_to_session_manager = true; | 181 g_send_stop_request_to_session_manager = true; |
182 // On ChromeOS, always terminate the browser, regardless of the result of | 182 // On ChromeOS, always terminate the browser, regardless of the result of |
183 // AreAllBrowsersCloseable(). See crbug.com/123107. | 183 // AreAllBrowsersCloseable(). See crbug.com/123107. |
184 chrome::NotifyAndTerminate(true); | 184 chrome::NotifyAndTerminate(/*fast_path=*/true,/*always_reboot=*/false); |
185 #else | 185 #else |
186 // Reset the restart bit that might have been set in cancelled restart | 186 // Reset the restart bit that might have been set in cancelled restart |
187 // request. | 187 // request. |
188 #if !defined(OS_ANDROID) | 188 #if !defined(OS_ANDROID) |
189 UserManager::Hide(); | 189 UserManager::Hide(); |
190 #endif | 190 #endif |
191 PrefService* pref_service = g_browser_process->local_state(); | 191 PrefService* pref_service = g_browser_process->local_state(); |
192 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, false); | 192 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, false); |
193 AttemptExitInternal(false); | 193 AttemptExitInternal(false); |
194 #endif // defined(OS_CHROMEOS) | 194 #endif // defined(OS_CHROMEOS) |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 static bool notified = false; | 350 static bool notified = false; |
351 if (notified) | 351 if (notified) |
352 return; | 352 return; |
353 notified = true; | 353 notified = true; |
354 content::NotificationService::current()->Notify( | 354 content::NotificationService::current()->Notify( |
355 chrome::NOTIFICATION_APP_TERMINATING, | 355 chrome::NOTIFICATION_APP_TERMINATING, |
356 content::NotificationService::AllSources(), | 356 content::NotificationService::AllSources(), |
357 content::NotificationService::NoDetails()); | 357 content::NotificationService::NoDetails()); |
358 } | 358 } |
359 | 359 |
360 void NotifyAndTerminate(bool fast_path) { | 360 void NotifyAndTerminate(bool fast_path, bool always_reboot) { |
361 #if defined(OS_CHROMEOS) | 361 #if defined(OS_CHROMEOS) |
362 static bool notified = false; | 362 static bool notified = false; |
363 // Return if a shutdown request has already been sent. | 363 // Return if a shutdown request has already been sent. |
364 if (notified) | 364 if (notified) |
365 return; | 365 return; |
366 notified = true; | 366 notified = true; |
367 #endif | 367 #endif |
368 | 368 |
369 if (fast_path) | 369 if (fast_path) |
370 NotifyAppTerminating(); | 370 NotifyAppTerminating(); |
371 | 371 |
372 #if defined(OS_CHROMEOS) | 372 #if defined(OS_CHROMEOS) |
373 if (chromeos::PowerPolicyController::IsInitialized()) | 373 if (chromeos::PowerPolicyController::IsInitialized()) |
374 chromeos::PowerPolicyController::Get()->NotifyChromeIsExiting(); | 374 chromeos::PowerPolicyController::Get()->NotifyChromeIsExiting(); |
375 | 375 |
376 if (base::SysInfo::IsRunningOnChromeOS()) { | 376 if (base::SysInfo::IsRunningOnChromeOS()) { |
377 // If we're on a ChromeOS device, reboot if an update has been applied, | 377 // If we're on a ChromeOS device, reboot if an update has been applied, |
378 // or else signal the session manager to log out. | 378 // // or else signal the session manager to log out. |
James Cook
2016/11/30 23:01:41
fix formatting please
Greg K
2016/12/01 19:44:43
Done.
| |
379 chromeos::UpdateEngineClient* update_engine_client | 379 chromeos::UpdateEngineClient* update_engine_client = |
380 = chromeos::DBusThreadManager::Get()->GetUpdateEngineClient(); | 380 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient(); |
381 if (update_engine_client->GetLastStatus().status == | 381 if (update_engine_client->GetLastStatus().status == |
382 chromeos::UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT) { | 382 chromeos::UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT || |
383 always_reboot) { | |
383 update_engine_client->RebootAfterUpdate(); | 384 update_engine_client->RebootAfterUpdate(); |
384 } else if (g_send_stop_request_to_session_manager) { | 385 } else if (g_send_stop_request_to_session_manager) { |
385 // Don't ask SessionManager to stop session if the shutdown request comes | 386 // Don't ask SessionManager to stop session if the shutdown request comes |
386 // from session manager. | 387 // from session manager. |
387 chromeos::DBusThreadManager::Get()->GetSessionManagerClient() | 388 chromeos::DBusThreadManager::Get() |
389 ->GetSessionManagerClient() | |
388 ->StopSession(); | 390 ->StopSession(); |
389 } | 391 } |
390 } else { | 392 } else { |
391 if (g_send_stop_request_to_session_manager) { | 393 if (g_send_stop_request_to_session_manager) { |
392 // If running the Chrome OS build, but we're not on the device, act | 394 // If running the Chrome OS build, but we're not on the device, act |
393 // as if we received signal from SessionManager. | 395 // as if we received signal from SessionManager. |
394 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 396 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
395 base::Bind(&ExitCleanly)); | 397 base::Bind(&ExitCleanly)); |
396 } | 398 } |
397 } | 399 } |
398 #endif | 400 #endif |
399 } | 401 } |
400 | 402 |
401 #if !defined(OS_ANDROID) | 403 #if !defined(OS_ANDROID) |
402 void OnAppExiting() { | 404 void OnAppExiting() { |
403 static bool notified = false; | 405 static bool notified = false; |
404 if (notified) | 406 if (notified) |
405 return; | 407 return; |
406 notified = true; | 408 notified = true; |
407 HandleAppExitingForPlatform(); | 409 HandleAppExitingForPlatform(); |
408 } | 410 } |
409 #endif // !defined(OS_ANDROID) | 411 #endif // !defined(OS_ANDROID) |
410 | 412 |
411 } // namespace chrome | 413 } // namespace chrome |
OLD | NEW |