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