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 339 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. |
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 |