| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/metrics/user_metrics_recorder.h" | |
| 10 #include "ash/root_window_controller.h" | |
| 11 #include "ash/session/session_state_delegate.h" | 9 #include "ash/session/session_state_delegate.h" |
| 12 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 13 #include "ash/system/tray/system_tray_delegate.h" | 11 #include "ash/system/tray/system_tray_delegate.h" |
| 14 #include "ash/wm/common/window_state.h" | 12 #include "ash/wm/common/window_state.h" |
| 15 #include "ash/wm/mru_window_tracker.h" | 13 #include "ash/wm/common/wm_globals.h" |
| 14 #include "ash/wm/common/wm_window.h" |
| 16 #include "ash/wm/overview/window_selector.h" | 15 #include "ash/wm/overview/window_selector.h" |
| 17 #include "ash/wm/window_util.h" | |
| 18 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 19 #include "ui/aura/window.h" | |
| 20 | 17 |
| 21 namespace ash { | 18 namespace ash { |
| 22 | 19 |
| 23 WindowSelectorController::WindowSelectorController() { | 20 WindowSelectorController::WindowSelectorController() { |
| 24 } | 21 } |
| 25 | 22 |
| 26 WindowSelectorController::~WindowSelectorController() { | 23 WindowSelectorController::~WindowSelectorController() { |
| 27 } | 24 } |
| 28 | 25 |
| 29 // static | 26 // static |
| 30 bool WindowSelectorController::CanSelect() { | 27 bool WindowSelectorController::CanSelect() { |
| 31 // Don't allow a window overview if the screen is locked or a modal dialog is | 28 // Don't allow a window overview if the screen is locked or a modal dialog is |
| 32 // open or running in kiosk app session. | 29 // open or running in kiosk app session. |
| 33 return Shell::GetInstance()->session_state_delegate()-> | 30 return Shell::GetInstance()->session_state_delegate()-> |
| 34 IsActiveUserSessionStarted() && | 31 IsActiveUserSessionStarted() && |
| 35 !Shell::GetInstance()->session_state_delegate()->IsScreenLocked() && | 32 !Shell::GetInstance()->session_state_delegate()->IsScreenLocked() && |
| 36 !Shell::GetInstance()->IsSystemModalWindowOpen() && | 33 !Shell::GetInstance()->IsSystemModalWindowOpen() && |
| 37 Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus() != | 34 Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus() != |
| 38 user::LOGGED_IN_KIOSK_APP; | 35 user::LOGGED_IN_KIOSK_APP; |
| 39 } | 36 } |
| 40 | 37 |
| 41 void WindowSelectorController::ToggleOverview() { | 38 void WindowSelectorController::ToggleOverview() { |
| 42 if (IsSelecting()) { | 39 if (IsSelecting()) { |
| 43 OnSelectionEnded(); | 40 OnSelectionEnded(); |
| 44 } else { | 41 } else { |
| 45 // Don't start overview if window selection is not allowed. | 42 // Don't start overview if window selection is not allowed. |
| 46 if (!CanSelect()) | 43 if (!CanSelect()) |
| 47 return; | 44 return; |
| 48 | 45 |
| 49 aura::Window::Windows windows = | 46 std::vector<wm::WmWindow*> windows = |
| 50 ash::Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList(); | 47 wm::WmGlobals::Get()->GetMruWindowList(); |
| 51 auto end = | 48 auto end = |
| 52 std::remove_if(windows.begin(), windows.end(), | 49 std::remove_if(windows.begin(), windows.end(), |
| 53 std::not1(std::ptr_fun(&WindowSelector::IsSelectable))); | 50 std::not1(std::ptr_fun(&WindowSelector::IsSelectable))); |
| 54 windows.resize(end - windows.begin()); | 51 windows.resize(end - windows.begin()); |
| 55 | 52 |
| 56 // Don't enter overview mode with no windows. | 53 // Don't enter overview mode with no windows. |
| 57 if (windows.empty()) | 54 if (windows.empty()) |
| 58 return; | 55 return; |
| 59 | 56 |
| 60 Shell::GetInstance()->OnOverviewModeStarting(); | 57 Shell::GetInstance()->OnOverviewModeStarting(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 84 | 81 |
| 85 void WindowSelectorController::OnSelectionStarted() { | 82 void WindowSelectorController::OnSelectionStarted() { |
| 86 if (!last_selection_time_.is_null()) { | 83 if (!last_selection_time_.is_null()) { |
| 87 UMA_HISTOGRAM_LONG_TIMES( | 84 UMA_HISTOGRAM_LONG_TIMES( |
| 88 "Ash.WindowSelector.TimeBetweenUse", | 85 "Ash.WindowSelector.TimeBetweenUse", |
| 89 base::Time::Now() - last_selection_time_); | 86 base::Time::Now() - last_selection_time_); |
| 90 } | 87 } |
| 91 } | 88 } |
| 92 | 89 |
| 93 } // namespace ash | 90 } // namespace ash |
| OLD | NEW |