OLD | NEW |
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 ++itr; | 69 ++itr; |
70 } | 70 } |
71 | 71 |
72 // Put the windows in the mru_windows list at the head, if it's available. | 72 // Put the windows in the mru_windows list at the head, if it's available. |
73 if (mru_windows) { | 73 if (mru_windows) { |
74 // Iterate through the list backwards, so that we can move each window to | 74 // Iterate through the list backwards, so that we can move each window to |
75 // the front of the windows list as we find them. | 75 // the front of the windows list as we find them. |
76 for (auto ix = mru_windows->rbegin(); ix != mru_windows->rend(); ++ix) { | 76 for (auto ix = mru_windows->rbegin(); ix != mru_windows->rend(); ++ix) { |
77 // Exclude windows in non-switchable containers and those which cannot | 77 // Exclude windows in non-switchable containers and those which cannot |
78 // be activated. | 78 // be activated. |
79 if (!wm::IsSwitchableContainer((*ix)->GetParent()) || | 79 if (((*ix)->GetParent() && |
| 80 !wm::IsSwitchableContainer((*ix)->GetParent()->aura_window())) || |
80 !should_include_window_predicate.Run(*ix)) { | 81 !should_include_window_predicate.Run(*ix)) { |
81 continue; | 82 continue; |
82 } | 83 } |
83 | 84 |
84 MruWindowTracker::WindowList::iterator window = | 85 MruWindowTracker::WindowList::iterator window = |
85 std::find(windows.begin(), windows.end(), *ix); | 86 std::find(windows.begin(), windows.end(), *ix); |
86 if (window != windows.end()) { | 87 if (window != windows.end()) { |
87 windows.erase(window); | 88 windows.erase(window); |
88 windows.push_back(*ix); | 89 windows.push_back(*ix); |
89 } | 90 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 157 |
157 void MruWindowTracker::OnWindowDestroyed(aura::Window* window) { | 158 void MruWindowTracker::OnWindowDestroyed(aura::Window* window) { |
158 // It's possible for OnWindowActivated() to be called after | 159 // It's possible for OnWindowActivated() to be called after |
159 // OnWindowDestroying(). This means we need to override OnWindowDestroyed() | 160 // OnWindowDestroying(). This means we need to override OnWindowDestroyed() |
160 // else we may end up with a deleted window in |mru_windows_|. | 161 // else we may end up with a deleted window in |mru_windows_|. |
161 mru_windows_.remove(WmWindow::Get(window)); | 162 mru_windows_.remove(WmWindow::Get(window)); |
162 window->RemoveObserver(this); | 163 window->RemoveObserver(this); |
163 } | 164 } |
164 | 165 |
165 } // namespace ash | 166 } // namespace ash |
OLD | NEW |