| 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/common/wm/overview/window_selector_controller.h" | 5 #include "ash/common/wm/overview/window_selector_controller.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
| 10 #include "ash/common/system/tray/system_tray_delegate.h" | 10 #include "ash/common/system/tray/system_tray_delegate.h" |
| 11 #include "ash/common/wm/mru_window_tracker.h" | 11 #include "ash/common/wm/mru_window_tracker.h" |
| 12 #include "ash/common/wm/overview/window_selector.h" | 12 #include "ash/common/wm/overview/window_selector.h" |
| 13 #include "ash/common/wm/window_state.h" | 13 #include "ash/common/wm/window_state.h" |
| 14 #include "ash/common/wm_shell.h" | 14 #include "ash/common/wm_shell.h" |
| 15 #include "ash/common/wm_window.h" | 15 #include "ash/common/wm_window.h" |
| 16 #include "ash/shell.h" |
| 16 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
| 17 | 18 |
| 18 namespace ash { | 19 namespace ash { |
| 19 | 20 |
| 20 WindowSelectorController::WindowSelectorController() {} | 21 WindowSelectorController::WindowSelectorController() {} |
| 21 | 22 |
| 22 WindowSelectorController::~WindowSelectorController() { | 23 WindowSelectorController::~WindowSelectorController() { |
| 23 // Destroy widgets that may be still animating if shell shuts down soon after | 24 // Destroy widgets that may be still animating if shell shuts down soon after |
| 24 // exiting overview mode. | 25 // exiting overview mode. |
| 25 for (std::unique_ptr<DelayedAnimationObserver>& animation_observer : | 26 for (std::unique_ptr<DelayedAnimationObserver>& animation_observer : |
| (...skipping 30 matching lines...) Expand all Loading... |
| 56 WmShell::Get()->mru_window_tracker()->BuildMruWindowList(); | 57 WmShell::Get()->mru_window_tracker()->BuildMruWindowList(); |
| 57 auto end = | 58 auto end = |
| 58 std::remove_if(windows.begin(), windows.end(), | 59 std::remove_if(windows.begin(), windows.end(), |
| 59 std::not1(std::ptr_fun(&WindowSelector::IsSelectable))); | 60 std::not1(std::ptr_fun(&WindowSelector::IsSelectable))); |
| 60 windows.resize(end - windows.begin()); | 61 windows.resize(end - windows.begin()); |
| 61 | 62 |
| 62 // Don't enter overview mode with no windows. | 63 // Don't enter overview mode with no windows. |
| 63 if (windows.empty()) | 64 if (windows.empty()) |
| 64 return false; | 65 return false; |
| 65 | 66 |
| 66 WmShell::Get()->OnOverviewModeStarting(); | 67 Shell::GetInstance()->OnOverviewModeStarting(); |
| 67 window_selector_.reset(new WindowSelector(this)); | 68 window_selector_.reset(new WindowSelector(this)); |
| 68 window_selector_->Init(windows); | 69 window_selector_->Init(windows); |
| 69 OnSelectionStarted(); | 70 OnSelectionStarted(); |
| 70 } | 71 } |
| 71 return true; | 72 return true; |
| 72 } | 73 } |
| 73 | 74 |
| 74 bool WindowSelectorController::IsSelecting() const { | 75 bool WindowSelectorController::IsSelecting() const { |
| 75 return window_selector_.get() != NULL; | 76 return window_selector_.get() != NULL; |
| 76 } | 77 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 89 return window_selector_.get() != NULL && | 90 return window_selector_.get() != NULL && |
| 90 window_selector_->restoring_minimized_windows(); | 91 window_selector_->restoring_minimized_windows(); |
| 91 } | 92 } |
| 92 | 93 |
| 93 // TODO(flackr): Make WindowSelectorController observe the activation of | 94 // TODO(flackr): Make WindowSelectorController observe the activation of |
| 94 // windows, so we can remove WindowSelectorDelegate. | 95 // windows, so we can remove WindowSelectorDelegate. |
| 95 void WindowSelectorController::OnSelectionEnded() { | 96 void WindowSelectorController::OnSelectionEnded() { |
| 96 window_selector_->Shutdown(); | 97 window_selector_->Shutdown(); |
| 97 window_selector_.reset(); | 98 window_selector_.reset(); |
| 98 last_selection_time_ = base::Time::Now(); | 99 last_selection_time_ = base::Time::Now(); |
| 99 WmShell::Get()->OnOverviewModeEnded(); | 100 Shell::GetInstance()->OnOverviewModeEnded(); |
| 100 } | 101 } |
| 101 | 102 |
| 102 void WindowSelectorController::AddDelayedAnimationObserver( | 103 void WindowSelectorController::AddDelayedAnimationObserver( |
| 103 std::unique_ptr<DelayedAnimationObserver> animation_observer) { | 104 std::unique_ptr<DelayedAnimationObserver> animation_observer) { |
| 104 animation_observer->SetOwner(this); | 105 animation_observer->SetOwner(this); |
| 105 delayed_animations_.push_back(std::move(animation_observer)); | 106 delayed_animations_.push_back(std::move(animation_observer)); |
| 106 } | 107 } |
| 107 | 108 |
| 108 void WindowSelectorController::RemoveAndDestroyAnimationObserver( | 109 void WindowSelectorController::RemoveAndDestroyAnimationObserver( |
| 109 DelayedAnimationObserver* animation_observer) { | 110 DelayedAnimationObserver* animation_observer) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 125 } | 126 } |
| 126 | 127 |
| 127 void WindowSelectorController::OnSelectionStarted() { | 128 void WindowSelectorController::OnSelectionStarted() { |
| 128 if (!last_selection_time_.is_null()) { | 129 if (!last_selection_time_.is_null()) { |
| 129 UMA_HISTOGRAM_LONG_TIMES("Ash.WindowSelector.TimeBetweenUse", | 130 UMA_HISTOGRAM_LONG_TIMES("Ash.WindowSelector.TimeBetweenUse", |
| 130 base::Time::Now() - last_selection_time_); | 131 base::Time::Now() - last_selection_time_); |
| 131 } | 132 } |
| 132 } | 133 } |
| 133 | 134 |
| 134 } // namespace ash | 135 } // namespace ash |
| OLD | NEW |