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

Side by Side Diff: ash/wm/mru_window_tracker.cc

Issue 2886253002: mash: remove more shell/shelf WmWindow usage. (Closed)
Patch Set: Fix WmShelf::ForWindow. Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « ash/wm/immersive_context_ash.cc ('k') | ash/wm/overview/window_grid.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "ash/wm/mru_window_tracker.h" 5 #include "ash/wm/mru_window_tracker.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/public/cpp/shell_window_ids.h" 9 #include "ash/public/cpp/shell_window_ids.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 // Returns a list of windows ordered by their stacking order. 41 // Returns a list of windows ordered by their stacking order.
42 // If |mru_windows| is passed, these windows are moved to the front of the list. 42 // If |mru_windows| is passed, these windows are moved to the front of the list.
43 // It uses the given |should_include_window_predicate| to determine whether to 43 // It uses the given |should_include_window_predicate| to determine whether to
44 // include a window in the returned list or not. 44 // include a window in the returned list or not.
45 MruWindowTracker::WindowList BuildWindowListInternal( 45 MruWindowTracker::WindowList BuildWindowListInternal(
46 const std::list<WmWindow*>* mru_windows, 46 const std::list<WmWindow*>* mru_windows,
47 const CanActivateWindowPredicate& should_include_window_predicate) { 47 const CanActivateWindowPredicate& should_include_window_predicate) {
48 MruWindowTracker::WindowList windows; 48 MruWindowTracker::WindowList windows;
49 WmWindow* active_root = Shell::GetWmRootWindowForNewWindows(); 49 aura::Window* active_root = Shell::GetRootWindowForNewWindows();
50 for (WmWindow* window : ShellPort::Get()->GetAllRootWindows()) { 50 for (WmWindow* window : ShellPort::Get()->GetAllRootWindows()) {
51 if (window == active_root) 51 if (window->aura_window() == active_root)
52 continue; 52 continue;
53 for (size_t i = 0; i < wm::kSwitchableWindowContainerIdsLength; ++i) 53 for (size_t i = 0; i < wm::kSwitchableWindowContainerIdsLength; ++i)
54 AddTrackedWindows(window, wm::kSwitchableWindowContainerIds[i], &windows); 54 AddTrackedWindows(window, wm::kSwitchableWindowContainerIds[i], &windows);
55 } 55 }
56 56
57 // Add windows in the active root windows last so that the topmost window 57 // Add windows in the active root windows last so that the topmost window
58 // in the active root window becomes the front of the list. 58 // in the active root window becomes the front of the list.
59 for (size_t i = 0; i < wm::kSwitchableWindowContainerIdsLength; ++i) 59 for (size_t i = 0; i < wm::kSwitchableWindowContainerIdsLength; ++i) {
60 AddTrackedWindows(active_root, wm::kSwitchableWindowContainerIds[i], 60 AddTrackedWindows(WmWindow::Get(active_root),
61 &windows); 61 wm::kSwitchableWindowContainerIds[i], &windows);
62 }
62 63
63 // Removes unfocusable windows. 64 // Removes unfocusable windows.
64 std::vector<WmWindow*>::iterator itr = windows.begin(); 65 std::vector<WmWindow*>::iterator itr = windows.begin();
65 while (itr != windows.end()) { 66 while (itr != windows.end()) {
66 if (!should_include_window_predicate.Run(*itr)) 67 if (!should_include_window_predicate.Run(*itr))
67 itr = windows.erase(itr); 68 itr = windows.erase(itr);
68 else 69 else
69 ++itr; 70 ++itr;
70 } 71 }
71 72
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 158
158 void MruWindowTracker::OnWindowDestroyed(aura::Window* window) { 159 void MruWindowTracker::OnWindowDestroyed(aura::Window* window) {
159 // It's possible for OnWindowActivated() to be called after 160 // It's possible for OnWindowActivated() to be called after
160 // OnWindowDestroying(). This means we need to override OnWindowDestroyed() 161 // OnWindowDestroying(). This means we need to override OnWindowDestroyed()
161 // else we may end up with a deleted window in |mru_windows_|. 162 // else we may end up with a deleted window in |mru_windows_|.
162 mru_windows_.remove(WmWindow::Get(window)); 163 mru_windows_.remove(WmWindow::Get(window));
163 window->RemoveObserver(this); 164 window->RemoveObserver(this);
164 } 165 }
165 166
166 } // namespace ash 167 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/immersive_context_ash.cc ('k') | ash/wm/overview/window_grid.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698