OLD | NEW |
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 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 | 11 |
12 class Browser; | 12 class Browser; |
13 class Profile; | 13 class Profile; |
14 | 14 |
15 namespace chrome { | 15 namespace chrome { |
16 class BrowserListObserver; | 16 class BrowserListObserver; |
17 } | 17 } |
18 | 18 |
19 // Stores a list of all Browser objects. | 19 // Stores a list of all Browser objects. |
20 class BrowserList { | 20 class BrowserList { |
21 public: | 21 public: |
22 typedef std::vector<Browser*> BrowserVector; | 22 typedef std::vector<Browser*> BrowserVector; |
23 typedef BrowserVector::const_reverse_iterator const_reverse_iterator; | |
24 | 23 |
25 // Adds and removes browsers from the list they are associated with. The | 24 // Adds and removes browsers from the list they are associated with. The |
26 // browser object should be valid BEFORE these calls (for the benefit of | 25 // browser object should be valid BEFORE these calls (for the benefit of |
27 // observers), so notify and THEN delete the object. | 26 // observers), so notify and THEN delete the object. |
28 static void AddBrowser(Browser* browser); | 27 static void AddBrowser(Browser* browser); |
29 static void RemoveBrowser(Browser* browser); | 28 static void RemoveBrowser(Browser* browser); |
30 | 29 |
31 // Adds and removes |observer| from the observer list of each desktop. | 30 // Adds and removes |observer| from the observer list of each desktop. |
32 static void AddObserver(chrome::BrowserListObserver* observer); | 31 static void AddObserver(chrome::BrowserListObserver* observer); |
33 static void RemoveObserver(chrome::BrowserListObserver* observer); | 32 static void RemoveObserver(chrome::BrowserListObserver* observer); |
34 | 33 |
35 // Called by Browser objects when their window is activated (focused). This | 34 // Called by Browser objects when their window is activated (focused). This |
36 // allows us to determine what the last active Browser was. | 35 // allows us to determine what the last active Browser was. |
37 static void SetLastActive(Browser* browser); | 36 static void SetLastActive(Browser* browser); |
38 | 37 |
39 // Closes all browsers for |profile| across all desktops. | 38 // Closes all browsers for |profile| across all desktops. |
40 static void CloseAllBrowsersWithProfile(Profile* profile); | 39 static void CloseAllBrowsersWithProfile(Profile* profile); |
41 | 40 |
42 // Returns iterated access to list of open browsers ordered by when | |
43 // they were last active. The underlying data structure is a vector | |
44 // and we push_back on recent access so a reverse iterator gives the | |
45 // latest accessed browser first. | |
46 static const_reverse_iterator begin_last_active(); | |
47 static const_reverse_iterator end_last_active(); | |
48 | |
49 // Returns true if at least one incognito session is active. | 41 // Returns true if at least one incognito session is active. |
50 static bool IsOffTheRecordSessionActive(); | 42 static bool IsOffTheRecordSessionActive(); |
51 | 43 |
52 // Returns true if at least one incognito session is active for |profile|. | 44 // Returns true if at least one incognito session is active for |profile|. |
53 static bool IsOffTheRecordSessionActiveForProfile(Profile* profile); | 45 static bool IsOffTheRecordSessionActiveForProfile(Profile* profile); |
54 }; | 46 }; |
55 | 47 |
56 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ | 48 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ |
OLD | NEW |