Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: ash/wm/overview/window_selector_controller.cc

Issue 2087153003: Moves common code in ash/wm/overview to ash/common/wm/overview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/wm/overview/window_selector_controller.h"
6
7 #include <vector>
8
9 #include "ash/common/session/session_state_delegate.h"
10 #include "ash/common/system/tray/system_tray_delegate.h"
11 #include "ash/common/wm/mru_window_tracker.h"
12 #include "ash/common/wm/window_state.h"
13 #include "ash/common/wm_shell.h"
14 #include "ash/common/wm_window.h"
15 #include "ash/wm/overview/window_selector.h"
16 #include "base/metrics/histogram.h"
17
18 namespace ash {
19
20 WindowSelectorController::WindowSelectorController() {
21 }
22
23 WindowSelectorController::~WindowSelectorController() {
24 }
25
26 // static
27 bool WindowSelectorController::CanSelect() {
28 // Don't allow a window overview if the screen is locked or a modal dialog is
29 // open or running in kiosk app session.
30 SessionStateDelegate* session_state_delegate =
31 WmShell::Get()->GetSessionStateDelegate();
32 return session_state_delegate->IsActiveUserSessionStarted() &&
33 !session_state_delegate->IsScreenLocked() &&
34 !WmShell::Get()->IsSystemModalWindowOpen() &&
35 !WmShell::Get()->IsPinned() &&
36 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() !=
37 LoginStatus::KIOSK_APP;
38 }
39
40 void WindowSelectorController::ToggleOverview() {
41 if (IsSelecting()) {
42 OnSelectionEnded();
43 } else {
44 // Don't start overview if window selection is not allowed.
45 if (!CanSelect())
46 return;
47
48 std::vector<WmWindow*> windows =
49 WmShell::Get()->GetMruWindowTracker()->BuildMruWindowList();
50 auto end =
51 std::remove_if(windows.begin(), windows.end(),
52 std::not1(std::ptr_fun(&WindowSelector::IsSelectable)));
53 windows.resize(end - windows.begin());
54
55 // Don't enter overview mode with no windows.
56 if (windows.empty())
57 return;
58
59 WmShell::Get()->OnOverviewModeStarting();
60 window_selector_.reset(new WindowSelector(this));
61 window_selector_->Init(windows);
62 OnSelectionStarted();
63 }
64 }
65
66 bool WindowSelectorController::IsSelecting() {
67 return window_selector_.get() != NULL;
68 }
69
70 bool WindowSelectorController::IsRestoringMinimizedWindows() const {
71 return window_selector_.get() != NULL &&
72 window_selector_->restoring_minimized_windows();
73 }
74
75 // TODO(flackr): Make WindowSelectorController observe the activation of
76 // windows, so we can remove WindowSelectorDelegate.
77 void WindowSelectorController::OnSelectionEnded() {
78 window_selector_->Shutdown();
79 window_selector_.reset();
80 last_selection_time_ = base::Time::Now();
81 WmShell::Get()->OnOverviewModeEnded();
82 }
83
84 void WindowSelectorController::OnSelectionStarted() {
85 if (!last_selection_time_.is_null()) {
86 UMA_HISTOGRAM_LONG_TIMES(
87 "Ash.WindowSelector.TimeBetweenUse",
88 base::Time::Now() - last_selection_time_);
89 }
90 }
91
92 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/overview/window_selector_controller.h ('k') | ash/wm/overview/window_selector_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698