| 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 #include "ash/wm/window_cycle_list.h" | 5 #include "ash/wm/window_cycle_list.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/wm/mru_window_tracker.h" | 8 #include "ash/wm/mru_window_tracker.h" |
| 9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
| 10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 int WindowCycleList::GetWindowIndex(aura::Window* window) { | 66 int WindowCycleList::GetWindowIndex(aura::Window* window) { |
| 67 WindowList::const_iterator it = | 67 WindowList::const_iterator it = |
| 68 std::find(windows_.begin(), windows_.end(), window); | 68 std::find(windows_.begin(), windows_.end(), window); |
| 69 if (it == windows_.end()) | 69 if (it == windows_.end()) |
| 70 return -1; // Not found. | 70 return -1; // Not found. |
| 71 return it - windows_.begin(); | 71 return it - windows_.begin(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void WindowCycleList::OnWindowDestroyed(aura::Window* window) { | 74 void WindowCycleList::OnWindowDestroyed(aura::Window* window) { |
| 75 window->RemoveObserver(this); | |
| 76 | |
| 77 WindowList::iterator i = std::find(windows_.begin(), windows_.end(), window); | 75 WindowList::iterator i = std::find(windows_.begin(), windows_.end(), window); |
| 78 DCHECK(i != windows_.end()); | 76 DCHECK(i != windows_.end()); |
| 79 int removed_index = static_cast<int>(i - windows_.begin()); | 77 int removed_index = static_cast<int>(i - windows_.begin()); |
| 80 windows_.erase(i); | 78 windows_.erase(i); |
| 81 if (current_index_ > removed_index) | 79 if (current_index_ > removed_index) |
| 82 current_index_--; | 80 current_index_--; |
| 83 else if (current_index_ == static_cast<int>(windows_.size())) | 81 else if (current_index_ == static_cast<int>(windows_.size())) |
| 84 current_index_--; | 82 current_index_--; |
| 85 } | 83 } |
| 86 | 84 |
| 87 } // namespace ash | 85 } // namespace ash |
| OLD | NEW |