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