| 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/metrics/user_metrics_recorder.h" | 7 #include "ash/metrics/user_metrics_recorder.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/session/session_state_delegate.h" | 9 #include "ash/session/session_state_delegate.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 if (!CanSelect()) | 44 if (!CanSelect()) |
| 45 return; | 45 return; |
| 46 | 46 |
| 47 std::vector<aura::Window*> windows = ash::Shell::GetInstance()-> | 47 std::vector<aura::Window*> windows = ash::Shell::GetInstance()-> |
| 48 mru_window_tracker()->BuildMruWindowList(); | 48 mru_window_tracker()->BuildMruWindowList(); |
| 49 // Don't enter overview mode with no windows. | 49 // Don't enter overview mode with no windows. |
| 50 if (windows.empty()) | 50 if (windows.empty()) |
| 51 return; | 51 return; |
| 52 | 52 |
| 53 window_selector_.reset( | 53 window_selector_.reset( |
| 54 new WindowSelector(windows, WindowSelector::OVERVIEW, this)); | 54 new WindowSelector(windows, this)); |
| 55 OnSelectionStarted(); | 55 OnSelectionStarted(); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 void WindowSelectorController::HandleCycleWindow( | |
| 60 WindowSelector::Direction direction) { | |
| 61 if (!CanSelect()) | |
| 62 return; | |
| 63 | |
| 64 if (!IsSelecting()) { | |
| 65 std::vector<aura::Window*> windows = ash::Shell::GetInstance()-> | |
| 66 mru_window_tracker()->BuildMruWindowList(); | |
| 67 // Don't cycle with no windows. | |
| 68 if (windows.empty()) | |
| 69 return; | |
| 70 | |
| 71 window_selector_.reset( | |
| 72 new WindowSelector(windows, WindowSelector::CYCLE, this)); | |
| 73 OnSelectionStarted(); | |
| 74 } | |
| 75 window_selector_->Step(direction); | |
| 76 } | |
| 77 | |
| 78 bool WindowSelectorController::IsSelecting() { | 59 bool WindowSelectorController::IsSelecting() { |
| 79 return window_selector_.get() != NULL; | 60 return window_selector_.get() != NULL; |
| 80 } | 61 } |
| 81 | 62 |
| 82 void WindowSelectorController::OnWindowSelected(aura::Window* window) { | 63 void WindowSelectorController::OnWindowSelected(aura::Window* window) { |
| 83 wm::ActivateWindow(window); | 64 wm::ActivateWindow(window); |
| 84 window_selector_.reset(); | 65 window_selector_.reset(); |
| 85 last_selection_time_ = base::Time::Now(); | 66 last_selection_time_ = base::Time::Now(); |
| 86 Shell::GetInstance()->mru_window_tracker()->SetIgnoreActivations(false); | 67 Shell::GetInstance()->mru_window_tracker()->SetIgnoreActivations(false); |
| 87 } | 68 } |
| 88 | 69 |
| 89 void WindowSelectorController::OnSelectionCanceled() { | 70 void WindowSelectorController::OnSelectionCanceled() { |
| 90 window_selector_.reset(); | 71 window_selector_.reset(); |
| 91 last_selection_time_ = base::Time::Now(); | 72 last_selection_time_ = base::Time::Now(); |
| 92 Shell::GetInstance()->mru_window_tracker()->SetIgnoreActivations(false); | 73 Shell::GetInstance()->mru_window_tracker()->SetIgnoreActivations(false); |
| 93 } | 74 } |
| 94 | 75 |
| 95 void WindowSelectorController::OnSelectionStarted() { | 76 void WindowSelectorController::OnSelectionStarted() { |
| 96 Shell::GetInstance()->mru_window_tracker()->SetIgnoreActivations(true); | 77 Shell::GetInstance()->mru_window_tracker()->SetIgnoreActivations(true); |
| 97 Shell* shell = Shell::GetInstance(); | 78 Shell* shell = Shell::GetInstance(); |
| 98 shell->metrics()->RecordUserMetricsAction(UMA_WINDOW_SELECTION); | 79 shell->metrics()->RecordUserMetricsAction(UMA_WINDOW_SELECTION); |
| 99 if (!last_selection_time_.is_null()) { | 80 if (!last_selection_time_.is_null()) { |
| 100 UMA_HISTOGRAM_LONG_TIMES( | 81 UMA_HISTOGRAM_LONG_TIMES( |
| 101 "Ash.WindowSelector.TimeBetweenUse", | 82 "Ash.WindowSelector.TimeBetweenUse", |
| 102 base::Time::Now() - last_selection_time_); | 83 base::Time::Now() - last_selection_time_); |
| 103 } | 84 } |
| 104 } | 85 } |
| 105 | 86 |
| 106 } // namespace ash | 87 } // namespace ash |
| OLD | NEW |