Chromium Code Reviews| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 // they were last active. The underlying data structure is a vector | 50 // they were last active. The underlying data structure is a vector |
| 51 // and we push_back on recent access so a reverse iterator gives the | 51 // and we push_back on recent access so a reverse iterator gives the |
| 52 // latest accessed browser first. | 52 // latest accessed browser first. |
| 53 const_reverse_iterator begin_last_active() const { | 53 const_reverse_iterator begin_last_active() const { |
| 54 return last_active_browsers_.rbegin(); | 54 return last_active_browsers_.rbegin(); |
| 55 } | 55 } |
| 56 const_reverse_iterator end_last_active() const { | 56 const_reverse_iterator end_last_active() const { |
| 57 return last_active_browsers_.rend(); | 57 return last_active_browsers_.rend(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 size_t currently_closing_browsers_count() const { | |
| 61 return currently_closing_browsers_.size(); | |
| 62 } | |
| 63 | |
| 60 static BrowserList* GetInstance(); | 64 static BrowserList* GetInstance(); |
| 61 | 65 |
| 62 // Adds or removes |browser| from the list it is associated with. The browser | 66 // Adds or removes |browser| from the list it is associated with. The browser |
| 63 // object should be valid BEFORE these calls (for the benefit of observers), | 67 // object should be valid BEFORE these calls (for the benefit of observers), |
| 64 // so notify and THEN delete the object. | 68 // so notify and THEN delete the object. |
| 65 static void AddBrowser(Browser* browser); | 69 static void AddBrowser(Browser* browser); |
| 66 static void RemoveBrowser(Browser* browser); | 70 static void RemoveBrowser(Browser* browser); |
| 67 | 71 |
| 68 // Adds and removes |observer| from the observer list for all desktops. | 72 // Adds and removes |observer| from the observer list for all desktops. |
| 69 // Observers are responsible for making sure the notifying browser is relevant | 73 // Observers are responsible for making sure the notifying browser is relevant |
| 70 // to them (e.g., on the specific desktop they care about if any). | 74 // to them (e.g., on the specific desktop they care about if any). |
| 71 static void AddObserver(chrome::BrowserListObserver* observer); | 75 static void AddObserver(chrome::BrowserListObserver* observer); |
| 72 static void RemoveObserver(chrome::BrowserListObserver* observer); | 76 static void RemoveObserver(chrome::BrowserListObserver* observer); |
| 73 | 77 |
| 74 // Moves all the browsers that show on workspace |new_workspace| to the end of | 78 // Moves all the browsers that show on workspace |new_workspace| to the end of |
| 75 // the browser list (i.e. the browsers that were "activated" most recently). | 79 // the browser list (i.e. the browsers that were "activated" most recently). |
| 76 static void MoveBrowsersInWorkspaceToFront(const std::string& new_workspace); | 80 static void MoveBrowsersInWorkspaceToFront(const std::string& new_workspace); |
| 77 | 81 |
| 78 // Called by Browser objects when their window is activated (focused). This | 82 // Called by Browser objects when their window is activated (focused). This |
| 79 // allows us to determine what the last active Browser was on each desktop. | 83 // allows us to determine what the last active Browser was on each desktop. |
| 80 static void SetLastActive(Browser* browser); | 84 static void SetLastActive(Browser* browser); |
| 81 | 85 |
| 82 // Notifies the observers when the current active browser becomes not active. | 86 // Notifies the observers when the current active browser becomes not active. |
| 83 static void NotifyBrowserNoLongerActive(Browser* browser); | 87 static void NotifyBrowserNoLongerActive(Browser* browser); |
| 84 | 88 |
| 89 // Notifies the observers when browser window is closing. | |
| 90 static void NotifyBrowserWindowClosing(Browser* browser); | |
| 91 | |
| 92 // Notifies the observers when browser window close is cancelled. | |
| 93 static void NotifyBrowserCloseCancelled(Browser* browser); | |
| 94 | |
| 85 // Closes all browsers for |profile| across all desktops. | 95 // Closes all browsers for |profile| across all desktops. |
| 86 // TODO(mlerman): Move the Profile Deletion flow to use the overloaded | 96 // TODO(mlerman): Move the Profile Deletion flow to use the overloaded |
| 87 // version of this method with a callback, then remove this method. | 97 // version of this method with a callback, then remove this method. |
| 88 static void CloseAllBrowsersWithProfile(Profile* profile); | 98 static void CloseAllBrowsersWithProfile(Profile* profile); |
| 89 | 99 |
| 90 // Closes all browsers for |profile| across all desktops. Uses | 100 // Closes all browsers for |profile| across all desktops. Uses |
| 91 // TryToCloseBrowserList() to do the actual closing. Trigger any | 101 // TryToCloseBrowserList() to do the actual closing. Trigger any |
| 92 // OnBeforeUnload events if |if_force| is false. If all OnBeforeUnload events | 102 // OnBeforeUnload events if |if_force| is false. If all OnBeforeUnload events |
| 93 // are confirmed or |skip_beforeunload| is true, |on_close_success| is called, | 103 // are confirmed or |skip_beforeunload| is true, |on_close_success| is called, |
| 94 // otherwise |on_close_aborted| is called. | 104 // otherwise |on_close_aborted| is called. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 const CloseCallback& on_close_aborted, | 151 const CloseCallback& on_close_aborted, |
| 142 const base::FilePath& profile_path, | 152 const base::FilePath& profile_path, |
| 143 const bool skip_beforeunload, | 153 const bool skip_beforeunload, |
| 144 bool tab_close_confirmed); | 154 bool tab_close_confirmed); |
| 145 | 155 |
| 146 // A vector of the browsers in this list, in the order they were added. | 156 // A vector of the browsers in this list, in the order they were added. |
| 147 BrowserVector browsers_; | 157 BrowserVector browsers_; |
| 148 // A vector of the browsers in this list that have been activated, in the | 158 // A vector of the browsers in this list that have been activated, in the |
| 149 // reverse order in which they were last activated. | 159 // reverse order in which they were last activated. |
| 150 BrowserVector last_active_browsers_; | 160 BrowserVector last_active_browsers_; |
| 161 // A vector of the browsers that is currently in closing state. | |
|
sky
2017/03/31 14:23:41
are currently in the
Alexey Seren
2017/04/02 12:02:35
Acknowledged.
| |
| 162 BrowserVector currently_closing_browsers_; | |
| 151 | 163 |
| 152 // A list of observers which will be notified of every browser addition and | 164 // A list of observers which will be notified of every browser addition and |
| 153 // removal across all BrowserLists. | 165 // removal across all BrowserLists. |
| 154 static base::LazyInstance< | 166 static base::LazyInstance< |
| 155 base::ObserverList<chrome::BrowserListObserver>>::Leaky observers_; | 167 base::ObserverList<chrome::BrowserListObserver>>::Leaky observers_; |
| 156 | 168 |
| 157 static BrowserList* instance_; | 169 static BrowserList* instance_; |
| 158 | 170 |
| 159 DISALLOW_COPY_AND_ASSIGN(BrowserList); | 171 DISALLOW_COPY_AND_ASSIGN(BrowserList); |
| 160 }; | 172 }; |
| 161 | 173 |
| 162 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ | 174 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ |
| OLD | NEW |