| 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_IMPL_H_ | 5 #ifndef CHROME_BROWSER_UI_BROWSER_LIST_IMPL_H_ |
| 6 #define CHROME_BROWSER_UI_BROWSER_LIST_IMPL_H_ | 6 #define CHROME_BROWSER_UI_BROWSER_LIST_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
| 9 #include "chrome/browser/ui/host_desktop.h" | 9 #include "chrome/browser/ui/host_desktop.h" |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 void AddBrowser(Browser* browser); | 33 void AddBrowser(Browser* browser); |
| 34 void RemoveBrowser(Browser* browser); | 34 void RemoveBrowser(Browser* browser); |
| 35 | 35 |
| 36 void AddObserver(BrowserListObserver* observer); | 36 void AddObserver(BrowserListObserver* observer); |
| 37 void RemoveObserver(BrowserListObserver* observer); | 37 void RemoveObserver(BrowserListObserver* observer); |
| 38 | 38 |
| 39 // Called by Browser objects when their window is activated (focused). This | 39 // Called by Browser objects when their window is activated (focused). This |
| 40 // allows us to determine what the last active Browser was. | 40 // allows us to determine what the last active Browser was. |
| 41 void SetLastActive(Browser* browser); | 41 void SetLastActive(Browser* browser); |
| 42 | 42 |
| 43 Browser* GetLastActive(); | 43 Browser* GetLastActive() const; |
| 44 | 44 |
| 45 // Browsers are added to the list before they have constructed windows, | 45 // Browsers are added to the list before they have constructed windows, |
| 46 // so the |window()| member function may return NULL. | 46 // so the |window()| member function may return NULL. |
| 47 const_iterator begin() const { return browsers_.begin(); } | 47 const_iterator begin() const { return browsers_.begin(); } |
| 48 const_iterator end() const { return browsers_.end(); } | 48 const_iterator end() const { return browsers_.end(); } |
| 49 | 49 |
| 50 bool empty() const { return browsers_.empty(); } | 50 bool empty() const { return browsers_.empty(); } |
| 51 size_t size() const { return browsers_.size(); } | 51 size_t size() const { return browsers_.size(); } |
| 52 | 52 |
| 53 Browser* get(size_t index) const { return browsers_[index]; } | 53 Browser* get(size_t index) const { return browsers_[index]; } |
| 54 | 54 |
| 55 // Returns iterated access to list of open browsers ordered by when | 55 // Returns iterated access to list of open browsers ordered by when |
| 56 // they were last active. The underlying data structure is a vector | 56 // they were last active. The underlying data structure is a vector |
| 57 // and we push_back on recent access so a reverse iterator gives the | 57 // and we push_back on recent access so a reverse iterator gives the |
| 58 // latest accessed browser first. | 58 // latest accessed browser first. |
| 59 const_reverse_iterator begin_last_active() { | 59 const_reverse_iterator begin_last_active() const { |
| 60 return last_active_browsers_.rbegin(); | 60 return last_active_browsers_.rbegin(); |
| 61 } | 61 } |
| 62 const_reverse_iterator end_last_active() { | 62 const_reverse_iterator end_last_active() const { |
| 63 return last_active_browsers_.rend(); | 63 return last_active_browsers_.rend(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 // Returns true if at least one incognito window is open. | 66 // Returns true if at least one incognito window is open. |
| 67 bool IsIncognitoWindowOpen(); | 67 bool IsIncognitoWindowOpen() const; |
| 68 | 68 |
| 69 // Returns true if at least one incognito window is open for |profile|. | 69 // Returns true if at least one incognito window is open for |profile|. |
| 70 bool IsIncognitoWindowOpenForProfile(Profile* profile); | 70 bool IsIncognitoWindowOpenForProfile(Profile* profile) const; |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 BrowserListImpl(); | 73 BrowserListImpl(); |
| 74 ~BrowserListImpl(); | 74 ~BrowserListImpl(); |
| 75 | 75 |
| 76 // Helper method to remove a browser instance from a list of browsers | 76 // Helper method to remove a browser instance from a list of browsers |
| 77 void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list); | 77 void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list); |
| 78 | 78 |
| 79 ObserverList<BrowserListObserver> observers_; | 79 ObserverList<BrowserListObserver> observers_; |
| 80 | 80 |
| 81 BrowserVector browsers_; | 81 BrowserVector browsers_; |
| 82 BrowserVector last_active_browsers_; | 82 BrowserVector last_active_browsers_; |
| 83 | 83 |
| 84 // Nothing fancy, since we only have two HDTs. | 84 // Nothing fancy, since we only have two HDTs. |
| 85 static BrowserListImpl* native_instance_; | 85 static BrowserListImpl* native_instance_; |
| 86 static BrowserListImpl* ash_instance_; | 86 static BrowserListImpl* ash_instance_; |
| 87 | 87 |
| 88 DISALLOW_COPY_AND_ASSIGN(BrowserListImpl); | 88 DISALLOW_COPY_AND_ASSIGN(BrowserListImpl); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 } // namespace chrome | 91 } // namespace chrome |
| 92 | 92 |
| 93 #endif // CHROME_BROWSER_UI_BROWSER_LIST_IMPL_H_ | 93 #endif // CHROME_BROWSER_UI_BROWSER_LIST_IMPL_H_ |
| OLD | NEW |