• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2006-2008 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_BROWSER_SHUTDOWN_H__
6 #define CHROME_BROWSER_BROWSER_SHUTDOWN_H__
7 #pragma once
8 
9 class PrefService;
10 
11 namespace browser_shutdown {
12 
13 // Should Shutdown() delete the ResourceBundle? This is normally true, but set
14 // to false for in process unit tests.
15 extern bool delete_resources_on_shutdown;
16 
17 enum ShutdownType {
18   // an uninitialized value
19   NOT_VALID = 0,
20   // the last browser window was closed
21   WINDOW_CLOSE,
22   // user clicked on the Exit menu item
23   BROWSER_EXIT,
24   // windows is logging off or shutting down
25   END_SESSION
26 };
27 
28 void RegisterPrefs(PrefService* local_state);
29 
30 // Called when the browser starts shutting down so that we can measure shutdown
31 // time.
32 void OnShutdownStarting(ShutdownType type);
33 
34 // Get the current shutdown type.
35 ShutdownType GetShutdownType();
36 
37 // Invoked in two ways:
38 // . When the last browser has been deleted and the message loop has finished
39 //   running.
40 // . When ChromeFrame::EndSession is invoked and we need to do cleanup.
41 //   NOTE: in this case the message loop is still running, but will die soon
42 //         after this returns.
43 void Shutdown();
44 
45 // Called at startup to create a histogram from our previous shutdown time.
46 void ReadLastShutdownInfo();
47 
48 // There are various situations where the browser process should continue to
49 // run after the last browser window has closed - the Mac always continues
50 // running until the user explicitly quits, and on Windows/Linux the application
51 // should not shutdown when the last browser window closes if there are any
52 // BackgroundContents running.
53 // When the user explicitly chooses to shutdown the app (via the "Exit" or
54 // "Quit" menu items) BrowserList will call SetTryingToQuit() to tell itself to
55 // initiate a shutdown when the last window closes.
56 // If the quit is aborted, then the flag should be reset.
57 
58 // This is a low-level mutator; in general, don't call SetTryingToQuit(true),
59 // except from appropriate places in BrowserList. To quit, use usual means,
60 // e.g., using |chrome_browser_application_mac::Terminate()| on the Mac, or
61 // |BrowserList::CloseAllWindowsAndExit()| on other platforms. To stop quitting,
62 // use |chrome_browser_application_mac::CancelTerminate()| on the Mac; other
63 // platforms can call SetTryingToQuit(false) directly.
64 void SetTryingToQuit(bool quitting);
65 
66 // General accessor.
67 bool IsTryingToQuit();
68 
69 // This is true on X during an END_SESSION, when we can no longer depend
70 // on the X server to be running. As a result we don't explicitly close the
71 // browser windows, which can lead to conditions which would fail checks.
72 bool ShuttingDownWithoutClosingBrowsers();
73 
74 }  // namespace browser_shutdown
75 
76 #endif  // CHROME_BROWSER_BROWSER_SHUTDOWN_H__
77