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_BROWSER_SHUTDOWN_H__ 6#define CHROME_BROWSER_BROWSER_SHUTDOWN_H__ 7 8class PrefRegistrySimple; 9 10namespace browser_shutdown { 11 12enum ShutdownType { 13 // an uninitialized value 14 NOT_VALID = 0, 15 // the last browser window was closed 16 WINDOW_CLOSE, 17 // user clicked on the Exit menu item 18 BROWSER_EXIT, 19 // windows is logging off or shutting down 20 END_SESSION 21}; 22 23void RegisterPrefs(PrefRegistrySimple* registry); 24 25// Called when the browser starts shutting down so that we can measure shutdown 26// time. 27void OnShutdownStarting(ShutdownType type); 28 29// Get the current shutdown type. 30ShutdownType GetShutdownType(); 31 32// Performs the shutdown tasks that need to be done before 33// BrowserProcess and the various threads go away. 34// 35// Returns true if the session should be restarted. 36bool ShutdownPreThreadsStop(); 37 38// Performs the remaining shutdown tasks after all threads but the 39// main thread have been stopped. This includes deleting g_browser_process. 40// 41// The provided parameter indicates whether a preference to restart 42// the session was present. 43void ShutdownPostThreadsStop(bool restart_last_session); 44 45// Called at startup to create a histogram from our previous shutdown time. 46void 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. 64void SetTryingToQuit(bool quitting); 65 66// General accessor. 67bool IsTryingToQuit(); 68 69} // namespace browser_shutdown 70 71#endif // CHROME_BROWSER_BROWSER_SHUTDOWN_H__ 72