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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 | 67 |
| 68 // Called by Browser objects when their window is activated (focused). This | 68 // Called by Browser objects when their window is activated (focused). This |
| 69 // allows us to determine what the last active Browser was on each desktop. | 69 // allows us to determine what the last active Browser was on each desktop. |
| 70 // Note: This only takes effect on the appropriate browser list as determined | 70 // Note: This only takes effect on the appropriate browser list as determined |
| 71 // by |browser->host_desktop_type()|. | 71 // by |browser->host_desktop_type()|. |
| 72 static void SetLastActive(Browser* browser); | 72 static void SetLastActive(Browser* browser); |
| 73 | 73 |
| 74 // Closes all browsers for |profile| across all desktops. | 74 // Closes all browsers for |profile| across all desktops. |
| 75 static void CloseAllBrowsersWithProfile(Profile* profile); | 75 static void CloseAllBrowsersWithProfile(Profile* profile); |
| 76 | 76 |
| 77 // Closes all browsers for |profile| across all desktops. If an OnBeforeUnload | |
|
noms (inactive)
2014/08/26 20:17:32
nit: maybe add "event"?
Mike Lerman
2014/08/27 14:11:39
Done.
| |
| 78 // causes any browser to not be closed, |on_close_aborted| is called. | |
| 79 // Otherwise, |on_close_success| is called. | |
| 80 static void CloseAllBrowsersWithProfile(Profile* profile, | |
|
Peter Kasting
2014/08/26 20:26:15
Nit: Align all args. (Several places)
Mike Lerman
2014/08/27 14:11:39
Done (several places).
| |
| 81 const base::Callback<void(size_t)>& on_close_success, | |
| 82 const base::Callback<void(size_t)>& on_close_aborted); | |
| 83 | |
| 77 // Returns true if at least one incognito session is active across all | 84 // Returns true if at least one incognito session is active across all |
| 78 // desktops. | 85 // desktops. |
| 79 static bool IsOffTheRecordSessionActive(); | 86 static bool IsOffTheRecordSessionActive(); |
| 80 | 87 |
| 81 // Returns true if at least one incognito session is active for |profile| | 88 // Returns true if at least one incognito session is active for |profile| |
| 82 // across all desktops. | 89 // across all desktops. |
| 83 static bool IsOffTheRecordSessionActiveForProfile(Profile* profile); | 90 static bool IsOffTheRecordSessionActiveForProfile(Profile* profile); |
| 84 | 91 |
| 92 // Null operation method for use with CloseAllBrowsersWithProfile. | |
| 93 static void DoNothing(size_t var) {} | |
|
noms (inactive)
2014/08/26 20:17:32
Hmm, I'm not super keen on this going in the publi
Peter Kasting
2014/08/26 20:26:15
Yeah, don't define something like this in the clas
Mike Lerman
2014/08/27 14:11:38
I'll remove the on_close_aborted parameter of Clos
| |
| 94 | |
| 85 private: | 95 private: |
| 86 BrowserList(); | 96 BrowserList(); |
| 87 ~BrowserList(); | 97 ~BrowserList(); |
| 88 | 98 |
| 89 // Helper method to remove a browser instance from a list of browsers | 99 // Helper method to remove a browser instance from a list of browsers |
| 90 static void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list); | 100 static void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list); |
| 91 | 101 |
| 102 // Attempts to close |browser_to_close| while respecting OnBeforeUnloads. | |
|
noms (inactive)
2014/08/26 20:17:32
nit: OnBeforeUnload events?
Mike Lerman
2014/08/27 14:11:38
Done.
| |
| 103 static void TryToCloseBrowserList(const BrowserVector& browsers_to_close, | |
| 104 const base::Callback<void(size_t)>& on_close_confirmed, | |
| 105 const base::Callback<void(size_t)>& on_close_aborted, | |
| 106 const size_t profile_index); | |
| 107 | |
| 108 // Called after handling an OnBeforeUnload. Will either try to close more | |
|
noms (inactive)
2014/08/26 20:17:32
nit: an OnBeforeUnload event?
Mike Lerman
2014/08/27 14:11:39
Done.
| |
| 109 // browsers or will call |on_close_aborted|. | |
| 110 static void PostBeforeUnloadHandlers(const BrowserVector& browsers_to_close, | |
| 111 const base::Callback<void(size_t)>& on_close_confirmed, | |
| 112 const base::Callback<void(size_t)>& on_close_aborted, | |
| 113 const size_t profile_index, | |
| 114 bool proceed); | |
|
noms (inactive)
2014/08/26 20:17:32
Please document all parameters
Mike Lerman
2014/08/27 14:11:38
Done.
| |
| 115 | |
| 92 // A vector of the browsers in this list, in the order they were added. | 116 // A vector of the browsers in this list, in the order they were added. |
| 93 BrowserVector browsers_; | 117 BrowserVector browsers_; |
| 94 // A vector of the browsers in this list that have been activated, in the | 118 // A vector of the browsers in this list that have been activated, in the |
| 95 // reverse order in which they were last activated. | 119 // reverse order in which they were last activated. |
| 96 BrowserVector last_active_browsers_; | 120 BrowserVector last_active_browsers_; |
| 97 | 121 |
| 98 // A list of observers which will be notified of every browser addition and | 122 // A list of observers which will be notified of every browser addition and |
| 99 // removal across all BrowserLists. | 123 // removal across all BrowserLists. |
| 100 static base::LazyInstance<ObserverList<chrome::BrowserListObserver> >::Leaky | 124 static base::LazyInstance<ObserverList<chrome::BrowserListObserver> >::Leaky |
| 101 observers_; | 125 observers_; |
| 102 | 126 |
| 103 // Nothing fancy, since we only have two HDTs. | 127 // Nothing fancy, since we only have two HDTs. |
| 104 static BrowserList* native_instance_; | 128 static BrowserList* native_instance_; |
| 105 static BrowserList* ash_instance_; | 129 static BrowserList* ash_instance_; |
| 106 | 130 |
| 107 DISALLOW_COPY_AND_ASSIGN(BrowserList); | 131 DISALLOW_COPY_AND_ASSIGN(BrowserList); |
| 108 }; | 132 }; |
| 109 | 133 |
| 110 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ | 134 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ |
| OLD | NEW |