Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: chrome/browser/ui/browser_list.h

Issue 10409022: Move application lifetime functionality off BrowserList. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/browser_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_BROWSER_LIST_H_ 5 #ifndef CHROME_BROWSER_UI_BROWSER_LIST_H_
6 #define CHROME_BROWSER_UI_BROWSER_LIST_H_ 6 #define CHROME_BROWSER_UI_BROWSER_LIST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // most recently open Browser's window was closed, returns the first Browser 57 // most recently open Browser's window was closed, returns the first Browser
58 // in the list. If no Browsers exist, returns NULL. 58 // in the list. If no Browsers exist, returns NULL.
59 // 59 //
60 // WARNING: this is NULL until a browser becomes active. If during startup 60 // WARNING: this is NULL until a browser becomes active. If during startup
61 // a browser does not become active (perhaps the user launches Chrome, then 61 // a browser does not become active (perhaps the user launches Chrome, then
62 // clicks on another app before the first browser window appears) then this 62 // clicks on another app before the first browser window appears) then this
63 // returns NULL. 63 // returns NULL.
64 // WARNING #2: this will always be NULL in unit tests run on the bots. 64 // WARNING #2: this will always be NULL in unit tests run on the bots.
65 static Browser* GetLastActive(); 65 static Browser* GetLastActive();
66 66
67 // Checks if the browser can be automatically restarted to install upgrades
68 // The browser can be automatically restarted when:
69 // 1. It's in the background mode (no visible windows).
70 // 2. An update exe is present in the install folder.
71 static bool CanRestartForUpdate();
72
73 // Starts a user initiated exit process. Called from Browser::Exit.
74 // On platforms other than ChromeOS, this is equivalent to
75 // CloseAllBrowsers() On ChromeOS, this tells session manager
76 // that chrome is signing out, which lets session manager send
77 // SIGTERM to start actual exit process.
78 static void AttemptUserExit();
79
80 // Starts a user initiated restart process. On platforms other than
81 // chromeos, this sets a restart bit in the preference so that
82 // chrome will be restarted at the end of shutdown process. On
83 // ChromeOS, this simply exits the chrome, which lets sesssion
84 // manager re-launch the browser with restore last session flag.
85 static void AttemptRestart();
86
87 // Attempt to exit by closing all browsers. This is equivalent to
88 // CloseAllBrowsers() on platforms where the application exits
89 // when no more windows are remaining. On other platforms (the Mac),
90 // this will additionally exit the application if all browsers are
91 // successfully closed.
92 // Note that he exit process may be interrupted by download or
93 // unload handler, and the browser may or may not exit.
94 static void AttemptExit();
95
96 #if defined(OS_CHROMEOS)
97 // This is equivalent to AttemptUserExit, except that it always set
98 // exit cleanly bit. ChromeOS checks if it can exit without user
99 // interactions, so it will always exit the browser. This is used to
100 // handle SIGTERM on chromeos which is a signal to force shutdown
101 // the chrome.
102 static void ExitCleanly();
103 #endif
104
105 // Closes all browsers. If the session is ending the windows are closed
106 // directly. Otherwise the windows are closed by way of posting a WM_CLOSE
107 // message.
108 static void CloseAllBrowsers();
109
110 // Closes all browsers for |profile|. 67 // Closes all browsers for |profile|.
111 static void CloseAllBrowsersWithProfile(Profile* profile); 68 static void CloseAllBrowsersWithProfile(Profile* profile);
112 69
113 // Begins shutdown of the application when the desktop session is ending.
114 static void SessionEnding();
115
116 // Tells the BrowserList to keep the application alive after the last Browser
117 // closes. This is implemented as a count, so callers should pair their calls
118 // to StartKeepAlive() with matching calls to EndKeepAlive() when they no
119 // longer need to keep the application running.
120 static void StartKeepAlive();
121
122 // Stops keeping the application alive after the last Browser is closed.
123 // Should match a previous call to StartKeepAlive().
124 static void EndKeepAlive();
125
126 // Returns true if application will continue running after the last Browser
127 // closes.
128 static bool WillKeepAlive();
129
130 // Browsers are added to the list before they have constructed windows, 70 // Browsers are added to the list before they have constructed windows,
131 // so the |window()| member function may return NULL. 71 // so the |window()| member function may return NULL.
132 static const_iterator begin(); 72 static const_iterator begin();
133 static const_iterator end(); 73 static const_iterator end();
134 74
135 static bool empty(); 75 static bool empty();
136 static size_t size(); 76 static size_t size();
137 77
138 // Returns iterated access to list of open browsers ordered by when 78 // Returns iterated access to list of open browsers ordered by when
139 // they were last active. The underlying data structure is a vector 79 // they were last active. The underlying data structure is a vector
140 // and we push_back on recent access so a reverse iterator gives the 80 // and we push_back on recent access so a reverse iterator gives the
141 // latest accessed browser first. 81 // latest accessed browser first.
142 static const_reverse_iterator begin_last_active(); 82 static const_reverse_iterator begin_last_active();
143 static const_reverse_iterator end_last_active(); 83 static const_reverse_iterator end_last_active();
144 84
145 // Returns true if at least one incognito session is active. 85 // Returns true if at least one incognito session is active.
146 static bool IsOffTheRecordSessionActive(); 86 static bool IsOffTheRecordSessionActive();
147 87
148 // Returns true if at least one incognito session is active for |profile|. 88 // Returns true if at least one incognito session is active for |profile|.
149 static bool IsOffTheRecordSessionActiveForProfile(Profile* profile); 89 static bool IsOffTheRecordSessionActiveForProfile(Profile* profile);
150 90
151 // Send out notifications.
152 // For ChromeOS, also request session manager to end the session.
153 static void NotifyAndTerminate(bool fast_path);
154
155 // Called once the application is exiting.
156 static void OnAppExiting();
157
158 // Called once the application is exiting to do any platform specific
159 // processing required.
160 static void HandleAppExitingForPlatform();
161
162 private: 91 private:
163 // Helper method to remove a browser instance from a list of browsers 92 // Helper method to remove a browser instance from a list of browsers
164 static void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list); 93 static void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list);
165 static void MarkAsCleanShutdown();
166 static void AttemptExitInternal();
167
168 // Counter of calls to StartKeepAlive(). If non-zero, the application will
169 // continue running after the last browser has exited.
170 static int keep_alive_count_;
171 }; 94 };
172 95
173 class TabContentsWrapper; 96 class TabContentsWrapper;
174 97
175 // Iterates through all web view hosts in all browser windows. Because the 98 // Iterates through all web view hosts in all browser windows. Because the
176 // renderers act asynchronously, getting a host through this interface does 99 // renderers act asynchronously, getting a host through this interface does
177 // not guarantee that the renderer is ready to go. Doing anything to affect 100 // not guarantee that the renderer is ready to go. Doing anything to affect
178 // browser windows or tabs while iterating may cause incorrect behavior. 101 // browser windows or tabs while iterating may cause incorrect behavior.
179 // 102 //
180 // Example: 103 // Example:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // iterator over the TabContentsWrappers doing background printing. 158 // iterator over the TabContentsWrappers doing background printing.
236 std::set<TabContentsWrapper*>::const_iterator bg_printing_iterator_; 159 std::set<TabContentsWrapper*>::const_iterator bg_printing_iterator_;
237 160
238 // Current TabContentsWrapper, or NULL if we're at the end of the list. This 161 // Current TabContentsWrapper, or NULL if we're at the end of the list. This
239 // can be extracted given the browser iterator and index, but it's nice to 162 // can be extracted given the browser iterator and index, but it's nice to
240 // cache this since the caller may access the current host many times. 163 // cache this since the caller may access the current host many times.
241 TabContentsWrapper* cur_; 164 TabContentsWrapper* cur_;
242 }; 165 };
243 166
244 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ 167 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/browser_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698