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_ 7 8 class Browser; 9 10 namespace chrome { 11 12 // Starts a user initiated exit process. Called from Browser::Exit. 13 // On platforms other than ChromeOS, this is equivalent to 14 // CloseAllBrowsers() On ChromeOS, this tells session manager 15 // that chrome is signing out, which lets session manager send 16 // SIGTERM to start actual exit process. 17 void AttemptUserExit(); 18 19 // Starts a user initiated restart process. On platforms other than 20 // chromeos, this sets a restart bit in the preference so that 21 // chrome will be restarted at the end of shutdown process. On 22 // ChromeOS, this simply exits the chrome, which lets sesssion 23 // manager re-launch the browser with restore last session flag. 24 void AttemptRestart(); 25 26 #if defined(OS_WIN) 27 // Windows 8 specific: Like AttemptRestart but if chrome is running 28 // in desktop mode it starts in metro mode and vice-versa. The switching like 29 // the restarting is controlled by a preference. 30 void AttemptRestartWithModeSwitch(); 31 #endif 32 33 // Attempt to exit by closing all browsers. This is equivalent to 34 // CloseAllBrowsers() on platforms where the application exits 35 // when no more windows are remaining. On other platforms (the Mac), 36 // this will additionally exit the application if all browsers are 37 // successfully closed. 38 // Note that he exit process may be interrupted by download or 39 // unload handler, and the browser may or may not exit. 40 void AttemptExit(); 41 42 #if defined(OS_CHROMEOS) 43 // This is equivalent to AttemptUserExit, except that it always set 44 // exit cleanly bit. ChromeOS checks if it can exit without user 45 // interactions, so it will always exit the browser. This is used to 46 // handle SIGTERM on chromeos which is a signal to force shutdown 47 // the chrome. 48 void ExitCleanly(); 49 #endif 50 51 // Closes all browsers. If the session is ending the windows are closed 52 // directly. Otherwise the windows are closed by way of posting a WM_CLOSE 53 // message. 54 void CloseAllBrowsers(); 55 56 // Begins shutdown of the application when the desktop session is ending. 57 void SessionEnding(); 58 59 // Tells the BrowserList to keep the application alive after the last Browser 60 // closes. This is implemented as a count, so callers should pair their calls 61 // to StartKeepAlive() with matching calls to EndKeepAlive() when they no 62 // longer need to keep the application running. 63 void StartKeepAlive(); 64 65 // Stops keeping the application alive after the last Browser is closed. 66 // Should match a previous call to StartKeepAlive(). 67 void EndKeepAlive(); 68 69 // Returns true if application will continue running after the last Browser 70 // closes. 71 bool WillKeepAlive(); 72 73 // Emits APP_TERMINATING notification. It is guaranteed that the 74 // notification is sent only once. 75 void NotifyAppTerminating(); 76 77 // Send out notifications. 78 // For ChromeOS, also request session manager to end the session. 79 void NotifyAndTerminate(bool fast_path); 80 81 // Called once the application is exiting. 82 void OnAppExiting(); 83 84 // Called once the application is exiting to do any platform specific 85 // processing required. 86 void HandleAppExitingForPlatform(); 87 88 // Returns true if we can start the shutdown sequence for the browser, i.e. the 89 // last browser window is being closed. 90 bool ShouldStartShutdown(Browser* browser); 91 92 } // namespace chrome 93 94 #endif // CHROME_BROWSER_LIFETIME_APPLICATION_LIFETIME_H_ 95