OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_BROWSER_LIST_H_ | 5 #ifndef CHROME_BROWSER_BROWSER_LIST_H__ |
6 #define CHROME_BROWSER_BROWSER_LIST_H_ | 6 #define CHROME_BROWSER_BROWSER_LIST_H__ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
11 | 11 |
12 // Stores a list of all Browser objects. | 12 // Stores a list of all Browser objects. |
13 class BrowserList { | 13 class BrowserList { |
14 public: | 14 public: |
15 typedef std::vector<Browser*> list_type; | 15 typedef std::vector<Browser*> list_type; |
16 typedef list_type::iterator iterator; | 16 typedef list_type::iterator iterator; |
17 typedef list_type::const_iterator const_iterator; | 17 typedef list_type::const_iterator const_iterator; |
18 typedef list_type::const_reverse_iterator const_reverse_iterator; | 18 typedef list_type::const_reverse_iterator const_reverse_iterator; |
19 | 19 |
20 // It is not allowed to change the global window list (add or remove any | 20 // It is not allowed to change the global window list (add or remove any |
21 // browser windows while handling observer callbacks. | 21 // browser windows while handling observer callbacks. |
22 class Observer { | 22 class Observer { |
23 public: | 23 public: |
24 // Called immediately after a browser is added to the list | 24 // Called immediately after a browser is added to the list |
25 virtual void OnBrowserAdded(const Browser* browser) = 0; | 25 virtual void OnBrowserAdded(const Browser* browser) = 0; |
26 | 26 |
27 // Called immediately before a browser is removed from the list | 27 // Called immediately before a browser is removed from the list |
28 virtual void OnBrowserRemoving(const Browser* browser) = 0; | 28 virtual void OnBrowserRemoving(const Browser* browser) = 0; |
29 | 29 |
30 // Called immediately after a browser is set active (SetLastActive) | 30 // Called immediately after a browser is set active (SetLastActive) |
31 virtual void OnBrowserSetLastActive(const Browser* browser) {}; | 31 virtual void OnBrowserSetLastActive(const Browser* browser) { }; |
32 | |
33 protected: | |
34 ~Observer() {}; | |
35 }; | 32 }; |
36 | 33 |
37 // Adds and removes browsers from the global list. The browser object should | 34 // Adds and removes browsers from the global list. The browser object should |
38 // be valid BEFORE these calls (for the benefit of observers), so notify and | 35 // be valid BEFORE these calls (for the benefit of observers), so notify and |
39 // THEN delete the object. | 36 // THEN delete the object. |
40 static void AddBrowser(Browser* browser); | 37 static void AddBrowser(Browser* browser); |
41 static void RemoveBrowser(Browser* browser); | 38 static void RemoveBrowser(Browser* browser); |
42 | 39 |
43 static void AddObserver(Observer* observer); | 40 static void AddObserver(Observer* observer); |
44 static void RemoveObserver(Observer* observer); | 41 static void RemoveObserver(Observer* observer); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 184 |
188 // tab index into the current Browser of the current web view | 185 // tab index into the current Browser of the current web view |
189 int web_view_index_; | 186 int web_view_index_; |
190 | 187 |
191 // Current TabContents, or NULL if we're at the end of the list. This can | 188 // Current TabContents, or NULL if we're at the end of the list. This can |
192 // be extracted given the browser iterator and index, but it's nice to cache | 189 // be extracted given the browser iterator and index, but it's nice to cache |
193 // this since the caller may access the current host many times. | 190 // this since the caller may access the current host many times. |
194 TabContents* cur_; | 191 TabContents* cur_; |
195 }; | 192 }; |
196 | 193 |
197 #endif // CHROME_BROWSER_BROWSER_LIST_H_ | 194 #endif // CHROME_BROWSER_BROWSER_LIST_H__ |
OLD | NEW |