[email protected] | 2e6389f | 2012-05-18 19:41:25 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_LIFETIME_APPLICATION_LIFETIME_H_ |
| 6 | #define CHROME_BROWSER_LIFETIME_APPLICATION_LIFETIME_H_ |
[email protected] | 2e6389f | 2012-05-18 19:41:25 | [diff] [blame] | 7 | |
[email protected] | b9503276a | 2013-12-05 21:44:34 | [diff] [blame] | 8 | #include "base/compiler_specific.h" |
avi | 6846aef | 2015-12-26 01:09:38 | [diff] [blame] | 9 | #include "build/build_config.h" |
[email protected] | b9503276a | 2013-12-05 21:44:34 | [diff] [blame] | 10 | |
[email protected] | 3c9185a2 | 2013-04-18 21:12:53 | [diff] [blame] | 11 | class Browser; |
| 12 | |
[email protected] | 0c98ab65 | 2013-02-18 00:39:37 | [diff] [blame] | 13 | namespace chrome { |
[email protected] | 2e6389f | 2012-05-18 19:41:25 | [diff] [blame] | 14 | |
| 15 | // Starts a user initiated exit process. Called from Browser::Exit. |
| 16 | // On platforms other than ChromeOS, this is equivalent to |
| 17 | // CloseAllBrowsers() On ChromeOS, this tells session manager |
| 18 | // that chrome is signing out, which lets session manager send |
| 19 | // SIGTERM to start actual exit process. |
| 20 | void AttemptUserExit(); |
| 21 | |
| 22 | // Starts a user initiated restart process. On platforms other than |
| 23 | // chromeos, this sets a restart bit in the preference so that |
| 24 | // chrome will be restarted at the end of shutdown process. On |
| 25 | // ChromeOS, this simply exits the chrome, which lets sesssion |
| 26 | // manager re-launch the browser with restore last session flag. |
| 27 | void AttemptRestart(); |
| 28 | |
dpapad | 374368fd | 2016-06-09 04:04:42 | [diff] [blame] | 29 | // Starts a user initiated relaunch process. On platforms other than |
| 30 | // chromeos, this is equivalent to AttemptRestart. On ChromeOS, this relaunches |
| 31 | // the entire OS, instead of just relaunching the browser. |
| 32 | void AttemptRelaunch(); |
| 33 | |
[email protected] | 2e6389f | 2012-05-18 19:41:25 | [diff] [blame] | 34 | // Attempt to exit by closing all browsers. This is equivalent to |
| 35 | // CloseAllBrowsers() on platforms where the application exits |
| 36 | // when no more windows are remaining. On other platforms (the Mac), |
| 37 | // this will additionally exit the application if all browsers are |
| 38 | // successfully closed. |
thakis | 6ae1c3d | 2016-06-16 23:40:55 | [diff] [blame] | 39 | // Note that the exit process may be interrupted by download or |
[email protected] | 2e6389f | 2012-05-18 19:41:25 | [diff] [blame] | 40 | // unload handler, and the browser may or may not exit. |
| 41 | void AttemptExit(); |
| 42 | |
| 43 | #if defined(OS_CHROMEOS) |
[email protected] | 7df2c03 | 2014-01-22 10:42:01 | [diff] [blame] | 44 | // Shutdown chrome cleanly without blocking. This is called |
| 45 | // when SIGTERM is received on Chrome OS, and always sets |
| 46 | // exit-cleanly bit and exits the browser, even if there is |
| 47 | // ongoing downloads or a page with onbeforeunload handler. |
| 48 | // |
| 49 | // If you need to exit or restart in your code on ChromeOS, |
| 50 | // use AttemptExit or AttemptRestart respectively. |
[email protected] | 2e6389f | 2012-05-18 19:41:25 | [diff] [blame] | 51 | void ExitCleanly(); |
thestig | ea81c77b5 | 2017-04-17 23:19:11 | [diff] [blame] | 52 | |
| 53 | // Returns true if any of the above Attempt calls have been called. |
| 54 | bool IsAttemptingShutdown(); |
[email protected] | 2e6389f | 2012-05-18 19:41:25 | [diff] [blame] | 55 | #endif |
| 56 | |
tzik | a2f1ff9 | 2016-02-10 22:59:54 | [diff] [blame] | 57 | #if !defined(OS_ANDROID) |
[email protected] | 0c95faf4 | 2013-10-28 06:27:20 | [diff] [blame] | 58 | // Closes all browsers and if successful, quits. |
| 59 | void CloseAllBrowsersAndQuit(); |
| 60 | |
[email protected] | 2e6389f | 2012-05-18 19:41:25 | [diff] [blame] | 61 | // Closes all browsers. If the session is ending the windows are closed |
| 62 | // directly. Otherwise the windows are closed by way of posting a WM_CLOSE |
[email protected] | 0c95faf4 | 2013-10-28 06:27:20 | [diff] [blame] | 63 | // message. This will quit the application if there is nothing other than |
| 64 | // browser windows keeping it alive or the application is quitting. |
[email protected] | 2e6389f | 2012-05-18 19:41:25 | [diff] [blame] | 65 | void CloseAllBrowsers(); |
| 66 | |
dgn | 0237778 | 2016-03-12 00:58:38 | [diff] [blame] | 67 | // If there are no browsers open and we aren't already shutting down, |
dgn | fe075c8 | 2016-03-18 11:25:35 | [diff] [blame] | 68 | // initiate a shutdown. |
| 69 | void ShutdownIfNeeded(); |
dgn | 0237778 | 2016-03-12 00:58:38 | [diff] [blame] | 70 | |
[email protected] | 2e6389f | 2012-05-18 19:41:25 | [diff] [blame] | 71 | // Begins shutdown of the application when the desktop session is ending. |
| 72 | void SessionEnding(); |
| 73 | |
[email protected] | 2e6389f | 2012-05-18 19:41:25 | [diff] [blame] | 74 | // Called once the application is exiting. |
| 75 | void OnAppExiting(); |
| 76 | |
| 77 | // Called once the application is exiting to do any platform specific |
| 78 | // processing required. |
| 79 | void HandleAppExitingForPlatform(); |
tzik | a2f1ff9 | 2016-02-10 22:59:54 | [diff] [blame] | 80 | #endif // !defined(OS_ANDROID) |
skyostil | 0becb33 | 2015-04-27 17:59:37 | [diff] [blame] | 81 | |
[email protected] | 313fce1 | 2013-01-30 17:09:04 | [diff] [blame] | 82 | } // namespace chrome |
[email protected] | 2e6389f | 2012-05-18 19:41:25 | [diff] [blame] | 83 | |
| 84 | #endif // CHROME_BROWSER_LIFETIME_APPLICATION_LIFETIME_H_ |