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/overview/window_selector_controller.h" | 5 #include "ash/wm/overview/window_selector_controller.h" |
6 | 6 |
7 #include "ash/session_state_delegate.h" | 7 #include "ash/session_state_delegate.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/wm/mru_window_tracker.h" | 9 #include "ash/wm/mru_window_tracker.h" |
10 #include "ash/wm/overview/window_selector.h" | 10 #include "ash/wm/overview/window_selector.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 | 44 |
45 void WindowSelectorController::HandleCycleWindow( | 45 void WindowSelectorController::HandleCycleWindow( |
46 WindowSelector::Direction direction) { | 46 WindowSelector::Direction direction) { |
47 if (!CanSelect()) | 47 if (!CanSelect()) |
48 return; | 48 return; |
49 | 49 |
50 if (!IsSelecting()) { | 50 if (!IsSelecting()) { |
51 std::vector<aura::Window*> windows = ash::Shell::GetInstance()-> | 51 std::vector<aura::Window*> windows = ash::Shell::GetInstance()-> |
52 mru_window_tracker()->BuildMruWindowList(); | 52 mru_window_tracker()->BuildMruWindowList(); |
| 53 // Don't cycle with no windows. |
| 54 if (windows.empty()) |
| 55 return; |
| 56 |
53 // Removing focus will hide popup windows like the omnibar or open menus. | 57 // Removing focus will hide popup windows like the omnibar or open menus. |
54 window_selector_.reset( | 58 window_selector_.reset( |
55 new WindowSelector(windows, WindowSelector::CYCLE, this)); | 59 new WindowSelector(windows, WindowSelector::CYCLE, this)); |
56 window_selector_->Step(direction); | 60 window_selector_->Step(direction); |
57 } else if (window_selector_->mode() == WindowSelector::CYCLE) { | 61 } else if (window_selector_->mode() == WindowSelector::CYCLE) { |
58 window_selector_->Step(direction); | 62 window_selector_->Step(direction); |
59 } | 63 } |
60 } | 64 } |
61 | 65 |
62 bool WindowSelectorController::IsSelecting() { | 66 bool WindowSelectorController::IsSelecting() { |
63 return window_selector_.get() != NULL; | 67 return window_selector_.get() != NULL; |
64 } | 68 } |
65 | 69 |
66 void WindowSelectorController::OnWindowSelected(aura::Window* window) { | 70 void WindowSelectorController::OnWindowSelected(aura::Window* window) { |
67 window_selector_.reset(); | 71 window_selector_.reset(); |
68 wm::ActivateWindow(window); | 72 wm::ActivateWindow(window); |
69 } | 73 } |
70 | 74 |
71 void WindowSelectorController::OnSelectionCanceled() { | 75 void WindowSelectorController::OnSelectionCanceled() { |
72 window_selector_.reset(); | 76 window_selector_.reset(); |
73 } | 77 } |
74 | 78 |
75 } // namespace ash | 79 } // namespace ash |
OLD | NEW |