Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2326)

Unified Diff: chrome/browser/ui/browser_list.cc

Issue 2108933003: Reorder browser list on workspace switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed endl Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/browser_list.cc
diff --git a/chrome/browser/ui/browser_list.cc b/chrome/browser/ui/browser_list.cc
index 5516e79a2d661b03360ed12af48582c656e1ed4b..26fc7a2eb564bbf189b7ee425bbf8deec8c6a7b6 100644
--- a/chrome/browser/ui/browser_list.cc
+++ b/chrome/browser/ui/browser_list.cc
@@ -186,6 +186,36 @@ void BrowserList::PostBeforeUnloadHandlers(
}
// static
+void BrowserList::MoveBrowsersInWorkspaceToFront(
+ const std::string& new_workspace) {
+ DCHECK(!new_workspace.empty());
+
+ BrowserList* instance = GetInstance();
+
+ Browser* old_last_active = instance->GetLastActive();
+ BrowserVector& last_active_browsers = instance->last_active_browsers_;
+
+ // Perform a stable partition on the browsers in the list so that the browsers
+ // in the new workspace appear after the browsers in the other workspaces.
+ //
+ // For example, if we have a list of browser-workspace pairs
+ // [{b1, 0}, {b2, 1}, {b3, 0}, {b4, 1}]
+ // and we switch to workspace 1, we want the resulting browser list to look
+ // like [{b1, 0}, {b3, 0}, {b2, 1}, {b4, 1}].
+ std::stable_partition(
+ last_active_browsers.begin(), last_active_browsers.end(),
+ [&new_workspace](Browser* browser) {
+ return browser->window()->GetWorkspace() != new_workspace;
+ });
+
+ Browser* new_last_active = instance->GetLastActive();
+ if (old_last_active != new_last_active) {
+ FOR_EACH_OBSERVER(chrome::BrowserListObserver, observers_.Get(),
+ OnBrowserSetLastActive(new_last_active));
+ }
+}
+
+// static
void BrowserList::SetLastActive(Browser* browser) {
content::RecordAction(UserMetricsAction("ActiveBrowserChanged"));
« no previous file with comments | « chrome/browser/ui/browser_list.h ('k') | chrome/browser/ui/views/chrome_browser_main_extra_parts_views_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698