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> |
11 | 11 |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "ui/display/desktop_observer.h" | |
15 | 16 |
16 class Browser; | 17 class Browser; |
17 class Profile; | 18 class Profile; |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class FilePath; | 21 class FilePath; |
21 } | 22 } |
22 | 23 |
23 namespace chrome { | 24 namespace chrome { |
24 class BrowserListObserver; | 25 class BrowserListObserver; |
25 } | 26 } |
26 | 27 |
27 // Maintains a list of Browser objects. | 28 // Maintains a list of Browser objects. |
28 class BrowserList { | 29 class BrowserList : private display::desktop::DesktopObserver { |
Lei Zhang
2016/06/29 20:51:01
This stays public, but you can leave the overrides
Tom (Use chromium acct)
2016/06/29 21:12:50
Done.
| |
29 public: | 30 public: |
30 typedef std::vector<Browser*> BrowserVector; | 31 typedef std::vector<Browser*> BrowserVector; |
31 typedef BrowserVector::const_iterator const_iterator; | 32 typedef BrowserVector::const_iterator const_iterator; |
32 typedef BrowserVector::const_reverse_iterator const_reverse_iterator; | 33 typedef BrowserVector::const_reverse_iterator const_reverse_iterator; |
33 | 34 |
34 // Returns the last active browser for this list. | 35 // Returns the last active browser for this list. |
35 Browser* GetLastActive() const; | 36 Browser* GetLastActive() const; |
36 | 37 |
37 // Browsers are added to the list before they have constructed windows, | 38 // Browsers are added to the list before they have constructed windows, |
38 // so the |window()| member function may return NULL. | 39 // so the |window()| member function may return NULL. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 // Returns true if at least one incognito session is active across all | 90 // Returns true if at least one incognito session is active across all |
90 // desktops. | 91 // desktops. |
91 static bool IsOffTheRecordSessionActive(); | 92 static bool IsOffTheRecordSessionActive(); |
92 | 93 |
93 // Returns true if at least one incognito session is active for |profile| | 94 // Returns true if at least one incognito session is active for |profile| |
94 // across all desktops. | 95 // across all desktops. |
95 static bool IsOffTheRecordSessionActiveForProfile(Profile* profile); | 96 static bool IsOffTheRecordSessionActiveForProfile(Profile* profile); |
96 | 97 |
97 private: | 98 private: |
98 BrowserList(); | 99 BrowserList(); |
99 ~BrowserList(); | 100 ~BrowserList() override; |
101 | |
102 // display::DesktopObserver: | |
103 void OnWorkspaceChanged(const std::string& new_workspace) override; | |
100 | 104 |
101 // Helper method to remove a browser instance from a list of browsers | 105 // Helper method to remove a browser instance from a list of browsers |
102 static void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list); | 106 static void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list); |
103 | 107 |
104 // Attempts to close |browsers_to_close| while respecting OnBeforeUnload | 108 // Attempts to close |browsers_to_close| while respecting OnBeforeUnload |
105 // events. If there are no OnBeforeUnload events to be called, | 109 // events. If there are no OnBeforeUnload events to be called, |
106 // |on_close_confirmed| will be called, with a parameter of |profile_path|, | 110 // |on_close_confirmed| will be called, with a parameter of |profile_path|, |
107 // and the Browsers will then be closed. If at least one unfired | 111 // and the Browsers will then be closed. If at least one unfired |
108 // OnBeforeUnload event is found, handle it with a callback to | 112 // OnBeforeUnload event is found, handle it with a callback to |
109 // PostBeforeUnloadHandlers, which upon success will recursively call this | 113 // PostBeforeUnloadHandlers, which upon success will recursively call this |
(...skipping 23 matching lines...) Expand all Loading... | |
133 // removal across all BrowserLists. | 137 // removal across all BrowserLists. |
134 static base::LazyInstance< | 138 static base::LazyInstance< |
135 base::ObserverList<chrome::BrowserListObserver>>::Leaky observers_; | 139 base::ObserverList<chrome::BrowserListObserver>>::Leaky observers_; |
136 | 140 |
137 static BrowserList* instance_; | 141 static BrowserList* instance_; |
138 | 142 |
139 DISALLOW_COPY_AND_ASSIGN(BrowserList); | 143 DISALLOW_COPY_AND_ASSIGN(BrowserList); |
140 }; | 144 }; |
141 | 145 |
142 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ | 146 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ |
OLD | NEW |