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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // Don't start overview if window selection is not allowed. | 43 // Don't start overview if window selection is not allowed. |
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(new WindowSelector(windows, this)); |
54 new WindowSelector(windows, WindowSelector::OVERVIEW, this)); | |
55 OnSelectionStarted(); | 54 OnSelectionStarted(); |
56 } | 55 } |
57 } | 56 } |
58 | 57 |
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() { | 58 bool WindowSelectorController::IsSelecting() { |
79 return window_selector_.get() != NULL; | 59 return window_selector_.get() != NULL; |
80 } | 60 } |
81 | 61 |
82 void WindowSelectorController::OnWindowSelected(aura::Window* window) { | 62 void WindowSelectorController::OnWindowSelected(aura::Window* window) { |
83 wm::ActivateWindow(window); | 63 wm::ActivateWindow(window); |
84 window_selector_.reset(); | 64 window_selector_.reset(); |
85 last_selection_time_ = base::Time::Now(); | 65 last_selection_time_ = base::Time::Now(); |
86 Shell::GetInstance()->mru_window_tracker()->SetIgnoreActivations(false); | 66 Shell::GetInstance()->mru_window_tracker()->SetIgnoreActivations(false); |
87 } | 67 } |
88 | 68 |
89 void WindowSelectorController::OnSelectionCanceled() { | 69 void WindowSelectorController::OnSelectionCanceled() { |
90 window_selector_.reset(); | 70 window_selector_.reset(); |
91 last_selection_time_ = base::Time::Now(); | 71 last_selection_time_ = base::Time::Now(); |
92 Shell::GetInstance()->mru_window_tracker()->SetIgnoreActivations(false); | 72 Shell::GetInstance()->mru_window_tracker()->SetIgnoreActivations(false); |
93 } | 73 } |
94 | 74 |
95 void WindowSelectorController::OnSelectionStarted() { | 75 void WindowSelectorController::OnSelectionStarted() { |
96 Shell::GetInstance()->mru_window_tracker()->SetIgnoreActivations(true); | 76 Shell::GetInstance()->mru_window_tracker()->SetIgnoreActivations(true); |
97 Shell* shell = Shell::GetInstance(); | 77 Shell* shell = Shell::GetInstance(); |
98 shell->metrics()->RecordUserMetricsAction(UMA_WINDOW_SELECTION); | 78 shell->metrics()->RecordUserMetricsAction(UMA_WINDOW_SELECTION); |
99 if (!last_selection_time_.is_null()) { | 79 if (!last_selection_time_.is_null()) { |
100 UMA_HISTOGRAM_LONG_TIMES( | 80 UMA_HISTOGRAM_LONG_TIMES( |
101 "Ash.WindowSelector.TimeBetweenUse", | 81 "Ash.WindowSelector.TimeBetweenUse", |
102 base::Time::Now() - last_selection_time_); | 82 base::Time::Now() - last_selection_time_); |
103 } | 83 } |
104 } | 84 } |
105 | 85 |
106 } // namespace ash | 86 } // namespace ash |
OLD | NEW |