OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 static void StartKeepAlive(); | 163 static void StartKeepAlive(); |
164 | 164 |
165 // Stops keeping the application alive after the last Browser is closed. | 165 // Stops keeping the application alive after the last Browser is closed. |
166 // Should match a previous call to StartKeepAlive(). | 166 // Should match a previous call to StartKeepAlive(). |
167 static void EndKeepAlive(); | 167 static void EndKeepAlive(); |
168 | 168 |
169 // Returns true if application will continue running after the last Browser | 169 // Returns true if application will continue running after the last Browser |
170 // closes. | 170 // closes. |
171 static bool WillKeepAlive(); | 171 static bool WillKeepAlive(); |
172 | 172 |
173 // Browsers are added to |browsers_| before they have constructed windows, | 173 // Browsers are added to the list before they have constructed windows, |
174 // so the |window()| member function may return NULL. | 174 // so the |window()| member function may return NULL. |
175 static const_iterator begin() { return browsers_.begin(); } | 175 static const_iterator begin(); |
176 static const_iterator end() { return browsers_.end(); } | 176 static const_iterator end(); |
177 | 177 |
178 static bool empty() { return browsers_.empty(); } | 178 static bool empty(); |
179 static size_t size() { return browsers_.size(); } | 179 static size_t size(); |
180 | 180 |
181 // Returns iterated access to list of open browsers ordered by when | 181 // Returns iterated access to list of open browsers ordered by when |
182 // they were last active. The underlying data structure is a vector | 182 // they were last active. The underlying data structure is a vector |
183 // and we push_back on recent access so a reverse iterator gives the | 183 // and we push_back on recent access so a reverse iterator gives the |
184 // latest accessed browser first. | 184 // latest accessed browser first. |
185 static const_reverse_iterator begin_last_active() { | 185 static const_reverse_iterator begin_last_active(); |
186 return last_active_browsers_.rbegin(); | 186 static const_reverse_iterator end_last_active(); |
187 } | |
188 | |
189 static const_reverse_iterator end_last_active() { | |
190 return last_active_browsers_.rend(); | |
191 } | |
192 | 187 |
193 // Return the number of browsers with the following profile which are | 188 // Return the number of browsers with the following profile which are |
194 // currently open. | 189 // currently open. |
195 static size_t GetBrowserCount(Profile* profile); | 190 static size_t GetBrowserCount(Profile* profile); |
196 | 191 |
197 // Return the number of browsers with the following profile and type which are | 192 // Return the number of browsers with the following profile and type which are |
198 // currently open. | 193 // currently open. |
199 static size_t GetBrowserCountForType(Profile* profile, bool match_tabbed); | 194 static size_t GetBrowserCountForType(Profile* profile, bool match_tabbed); |
200 | 195 |
201 // Returns true if at least one incognito session is active. | 196 // Returns true if at least one incognito session is active. |
202 static bool IsOffTheRecordSessionActive(); | 197 static bool IsOffTheRecordSessionActive(); |
203 | 198 |
204 // Returns true if at least one incognito session is active for |profile|. | 199 // Returns true if at least one incognito session is active for |profile|. |
205 static bool IsOffTheRecordSessionActiveForProfile(Profile* profile); | 200 static bool IsOffTheRecordSessionActiveForProfile(Profile* profile); |
206 | 201 |
207 // Send out notifications. | 202 // Send out notifications. |
208 // For ChromeOS, also request session manager to end the session. | 203 // For ChromeOS, also request session manager to end the session. |
209 static void NotifyAndTerminate(bool fast_path); | 204 static void NotifyAndTerminate(bool fast_path); |
210 | 205 |
211 // Called once there are no more browsers open and the application is exiting. | 206 // Called once there are no more browsers open and the application is exiting. |
212 static void AllBrowsersClosedAndAppExiting(); | 207 static void AllBrowsersClosedAndAppExiting(); |
213 | 208 |
214 private: | 209 private: |
215 // Helper method to remove a browser instance from a list of browsers | 210 // Helper method to remove a browser instance from a list of browsers |
216 static void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list); | 211 static void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list); |
217 static void MarkAsCleanShutdown(); | 212 static void MarkAsCleanShutdown(); |
218 static void AttemptExitInternal(); | 213 static void AttemptExitInternal(); |
219 | 214 |
220 static BrowserVector browsers_; | |
221 static BrowserVector last_active_browsers_; | |
222 static ObserverList<Observer> observers_; | |
223 | |
224 // Counter of calls to StartKeepAlive(). If non-zero, the application will | 215 // Counter of calls to StartKeepAlive(). If non-zero, the application will |
225 // continue running after the last browser has exited. | 216 // continue running after the last browser has exited. |
226 static int keep_alive_count_; | 217 static int keep_alive_count_; |
227 }; | 218 }; |
228 | 219 |
229 class TabContentsWrapper; | 220 class TabContentsWrapper; |
230 | 221 |
231 // Iterates through all web view hosts in all browser windows. Because the | 222 // Iterates through all web view hosts in all browser windows. Because the |
232 // renderers act asynchronously, getting a host through this interface does | 223 // renderers act asynchronously, getting a host through this interface does |
233 // not guarantee that the renderer is ready to go. Doing anything to affect | 224 // not guarantee that the renderer is ready to go. Doing anything to affect |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // iterator over the TabContentsWrappers doing background printing. | 282 // iterator over the TabContentsWrappers doing background printing. |
292 std::set<TabContentsWrapper*>::const_iterator bg_printing_iterator_; | 283 std::set<TabContentsWrapper*>::const_iterator bg_printing_iterator_; |
293 | 284 |
294 // Current TabContents, or NULL if we're at the end of the list. This can | 285 // Current TabContents, or NULL if we're at the end of the list. This can |
295 // be extracted given the browser iterator and index, but it's nice to cache | 286 // be extracted given the browser iterator and index, but it's nice to cache |
296 // this since the caller may access the current host many times. | 287 // this since the caller may access the current host many times. |
297 TabContentsWrapper* cur_; | 288 TabContentsWrapper* cur_; |
298 }; | 289 }; |
299 | 290 |
300 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ | 291 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ |
OLD | NEW |