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 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "chrome/browser/ui/host_desktop.h" | 13 #include "chrome/browser/ui/host_desktop.h" |
14 | 14 |
15 class Browser; | 15 class Browser; |
16 class Profile; | 16 class Profile; |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class FilePath; | 19 class FilePath; |
20 } | 20 } |
21 | 21 |
22 namespace chrome { | 22 namespace chrome { |
23 class BrowserListObserver; | 23 class BrowserListObserver; |
24 } | 24 } |
25 | 25 |
26 // Maintains a list of Browser objects present in a given HostDesktop (see | 26 // Maintains a list of Browser objects present in a given HostDesktop (see |
27 // HostDesktopType). | 27 // ui::HostDesktopType). |
28 class BrowserList { | 28 class BrowserList { |
29 public: | 29 public: |
30 typedef std::vector<Browser*> BrowserVector; | 30 typedef std::vector<Browser*> BrowserVector; |
31 typedef BrowserVector::const_iterator const_iterator; | 31 typedef BrowserVector::const_iterator const_iterator; |
32 typedef BrowserVector::const_reverse_iterator const_reverse_iterator; | 32 typedef BrowserVector::const_reverse_iterator const_reverse_iterator; |
33 | 33 |
34 // Returns the last active browser for this list. | 34 // Returns the last active browser for this list. |
35 Browser* GetLastActive() const; | 35 Browser* GetLastActive() const; |
36 | 36 |
37 // Browsers are added to the list before they have constructed windows, | 37 // Browsers are added to the list before they have constructed windows, |
(...skipping 10 matching lines...) Expand all Loading... |
48 // they were last active. The underlying data structure is a vector | 48 // they were last active. The underlying data structure is a vector |
49 // and we push_back on recent access so a reverse iterator gives the | 49 // and we push_back on recent access so a reverse iterator gives the |
50 // latest accessed browser first. | 50 // latest accessed browser first. |
51 const_reverse_iterator begin_last_active() const { | 51 const_reverse_iterator begin_last_active() const { |
52 return last_active_browsers_.rbegin(); | 52 return last_active_browsers_.rbegin(); |
53 } | 53 } |
54 const_reverse_iterator end_last_active() const { | 54 const_reverse_iterator end_last_active() const { |
55 return last_active_browsers_.rend(); | 55 return last_active_browsers_.rend(); |
56 } | 56 } |
57 | 57 |
58 static BrowserList* GetInstance(chrome::HostDesktopType type); | 58 static BrowserList* GetInstance(ui::HostDesktopType type); |
59 | 59 |
60 // Adds or removes |browser| from the list it is associated with. The browser | 60 // Adds or removes |browser| from the list it is associated with. The browser |
61 // object should be valid BEFORE these calls (for the benefit of observers), | 61 // object should be valid BEFORE these calls (for the benefit of observers), |
62 // so notify and THEN delete the object. | 62 // so notify and THEN delete the object. |
63 static void AddBrowser(Browser* browser); | 63 static void AddBrowser(Browser* browser); |
64 static void RemoveBrowser(Browser* browser); | 64 static void RemoveBrowser(Browser* browser); |
65 | 65 |
66 // Adds and removes |observer| from the observer list for all desktops. | 66 // Adds and removes |observer| from the observer list for all desktops. |
67 // Observers are responsible for making sure the notifying browser is relevant | 67 // Observers are responsible for making sure the notifying browser is relevant |
68 // to them (e.g., on the specific desktop they care about if any). | 68 // to them (e.g., on the specific desktop they care about if any). |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 base::ObserverList<chrome::BrowserListObserver>>::Leaky observers_; | 137 base::ObserverList<chrome::BrowserListObserver>>::Leaky observers_; |
138 | 138 |
139 // Nothing fancy, since we only have two HDTs. | 139 // Nothing fancy, since we only have two HDTs. |
140 static BrowserList* native_instance_; | 140 static BrowserList* native_instance_; |
141 static BrowserList* ash_instance_; | 141 static BrowserList* ash_instance_; |
142 | 142 |
143 DISALLOW_COPY_AND_ASSIGN(BrowserList); | 143 DISALLOW_COPY_AND_ASSIGN(BrowserList); |
144 }; | 144 }; |
145 | 145 |
146 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ | 146 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ |
OLD | NEW |