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 "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
17 | 17 |
18 namespace ash { | 18 namespace ash { |
19 | 19 |
20 WindowSelectorController::WindowSelectorController() {} | 20 WindowSelectorController::WindowSelectorController() {} |
21 | 21 |
22 WindowSelectorController::~WindowSelectorController() {} | 22 WindowSelectorController::~WindowSelectorController() { |
23 // Destroy widgets that may be still animating if shell shuts down soon after | |
24 // exiting overview mode. | |
25 for (std::unique_ptr<DelayedAnimationObserver>& animation_observer : | |
26 delayed_animations_) { | |
27 animation_observer->Shutdown(); | |
28 } | |
29 } | |
23 | 30 |
24 // static | 31 // static |
25 bool WindowSelectorController::CanSelect() { | 32 bool WindowSelectorController::CanSelect() { |
26 // Don't allow a window overview if the screen is locked or a modal dialog is | 33 // Don't allow a window overview if the screen is locked or a modal dialog is |
27 // open or running in kiosk app session. | 34 // open or running in kiosk app session. |
28 SessionStateDelegate* session_state_delegate = | 35 SessionStateDelegate* session_state_delegate = |
29 WmShell::Get()->GetSessionStateDelegate(); | 36 WmShell::Get()->GetSessionStateDelegate(); |
30 return session_state_delegate->IsActiveUserSessionStarted() && | 37 return session_state_delegate->IsActiveUserSessionStarted() && |
31 !session_state_delegate->IsScreenLocked() && | 38 !session_state_delegate->IsScreenLocked() && |
32 !WmShell::Get()->IsSystemModalWindowOpen() && | 39 !WmShell::Get()->IsSystemModalWindowOpen() && |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 | 79 |
73 // TODO(flackr): Make WindowSelectorController observe the activation of | 80 // TODO(flackr): Make WindowSelectorController observe the activation of |
74 // windows, so we can remove WindowSelectorDelegate. | 81 // windows, so we can remove WindowSelectorDelegate. |
75 void WindowSelectorController::OnSelectionEnded() { | 82 void WindowSelectorController::OnSelectionEnded() { |
76 window_selector_->Shutdown(); | 83 window_selector_->Shutdown(); |
77 window_selector_.reset(); | 84 window_selector_.reset(); |
78 last_selection_time_ = base::Time::Now(); | 85 last_selection_time_ = base::Time::Now(); |
79 WmShell::Get()->OnOverviewModeEnded(); | 86 WmShell::Get()->OnOverviewModeEnded(); |
80 } | 87 } |
81 | 88 |
89 void WindowSelectorController::AddDelayedAnimationObserver( | |
90 std::unique_ptr<DelayedAnimationObserver> animation_observer) { | |
91 animation_observer->SetDelegate(this); | |
92 delayed_animations_.push_back(std::move(animation_observer)); | |
93 } | |
94 | |
95 void WindowSelectorController::RemoveDelayedAnimationObserver( | |
bruthig
2016/07/15 17:05:38
This is only implemented correctly if called from
varkha
2016/07/15 18:53:36
Done (Added some comment in the RemoveDelayedAnima
| |
96 DelayedAnimationObserver* animation_observer) { | |
97 class IsEqual { | |
98 public: | |
99 explicit IsEqual(DelayedAnimationObserver* animation_observer) | |
100 : animation_observer_(animation_observer) {} | |
101 bool operator()(const std::unique_ptr<DelayedAnimationObserver>& other) { | |
102 return (other.get() == animation_observer_); | |
103 } | |
104 | |
105 private: | |
106 const DelayedAnimationObserver* animation_observer_; | |
107 }; | |
108 delayed_animations_.erase( | |
109 std::remove_if(delayed_animations_.begin(), delayed_animations_.end(), | |
110 IsEqual(animation_observer)), | |
111 delayed_animations_.end()); | |
112 } | |
113 | |
82 void WindowSelectorController::OnSelectionStarted() { | 114 void WindowSelectorController::OnSelectionStarted() { |
83 if (!last_selection_time_.is_null()) { | 115 if (!last_selection_time_.is_null()) { |
84 UMA_HISTOGRAM_LONG_TIMES("Ash.WindowSelector.TimeBetweenUse", | 116 UMA_HISTOGRAM_LONG_TIMES("Ash.WindowSelector.TimeBetweenUse", |
85 base::Time::Now() - last_selection_time_); | 117 base::Time::Now() - last_selection_time_); |
86 } | 118 } |
87 } | 119 } |
88 | 120 |
89 } // namespace ash | 121 } // namespace ash |
OLD | NEW |