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" | 9 #include "ash/metrics/user_metrics_recorder.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
11 #include "ash/session/session_state_delegate.h" | 11 #include "ash/session/session_state_delegate.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "ash/system/tray/system_tray_delegate.h" | 13 #include "ash/system/tray/system_tray_delegate.h" |
14 #include "ash/wm/mru_window_tracker.h" | 14 #include "ash/wm/mru_window_tracker.h" |
15 #include "ash/wm/overview/window_selector.h" | 15 #include "ash/wm/overview/window_selector.h" |
16 #include "ash/wm/window_state.h" | 16 #include "ash/wm/window_state.h" |
17 #include "ash/wm/window_util.h" | 17 #include "ash/wm/window_util.h" |
18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
19 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
20 | 20 |
21 namespace ash { | 21 namespace ash { |
22 | 22 |
23 WindowSelectorController::WindowSelectorController() { | 23 WindowSelectorController::WindowSelectorController() |
24 : initially_active_window_(nullptr) { | |
24 } | 25 } |
25 | 26 |
26 WindowSelectorController::~WindowSelectorController() { | 27 WindowSelectorController::~WindowSelectorController() { |
27 } | 28 } |
28 | 29 |
29 // static | 30 // static |
30 bool WindowSelectorController::CanSelect() { | 31 bool WindowSelectorController::CanSelect() { |
31 // Don't allow a window overview if the screen is locked or a modal dialog is | 32 // Don't allow a window overview if the screen is locked or a modal dialog is |
32 // open or running in kiosk app session. | 33 // open or running in kiosk app session. |
33 return Shell::GetInstance()->session_state_delegate()-> | 34 return Shell::GetInstance()->session_state_delegate()-> |
(...skipping 16 matching lines...) Expand all Loading... | |
50 ash::Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList(); | 51 ash::Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList(); |
51 auto end = | 52 auto end = |
52 std::remove_if(windows.begin(), windows.end(), | 53 std::remove_if(windows.begin(), windows.end(), |
53 std::not1(std::ptr_fun(&WindowSelector::IsSelectable))); | 54 std::not1(std::ptr_fun(&WindowSelector::IsSelectable))); |
54 windows.resize(end - windows.begin()); | 55 windows.resize(end - windows.begin()); |
55 | 56 |
56 // Don't enter overview mode with no windows. | 57 // Don't enter overview mode with no windows. |
57 if (windows.empty()) | 58 if (windows.empty()) |
58 return; | 59 return; |
59 | 60 |
61 OnSelectionStarting(); | |
60 Shell::GetInstance()->OnOverviewModeStarting(); | 62 Shell::GetInstance()->OnOverviewModeStarting(); |
61 window_selector_.reset(new WindowSelector(this)); | 63 window_selector_.reset(new WindowSelector(this)); |
62 window_selector_->Init(windows); | 64 window_selector_->Init(windows); |
63 OnSelectionStarted(); | 65 OnSelectionStarted(); |
64 } | 66 } |
65 } | 67 } |
66 | 68 |
67 bool WindowSelectorController::IsSelecting() { | 69 bool WindowSelectorController::IsSelecting() { |
68 return window_selector_.get() != NULL; | 70 return window_selector_.get() != NULL; |
69 } | 71 } |
70 | 72 |
71 bool WindowSelectorController::IsRestoringMinimizedWindows() const { | 73 bool WindowSelectorController::IsRestoringMinimizedWindows() const { |
72 return window_selector_.get() != NULL && | 74 return window_selector_.get() != NULL && |
73 window_selector_->restoring_minimized_windows(); | 75 window_selector_->restoring_minimized_windows(); |
74 } | 76 } |
75 | 77 |
76 // TODO(flackr): Make WindowSelectorController observe the activation of | 78 // TODO(flackr): Make WindowSelectorController observe the activation of |
77 // windows, so we can remove WindowSelectorDelegate. | 79 // windows, so we can remove WindowSelectorDelegate. |
78 void WindowSelectorController::OnSelectionEnded() { | 80 void WindowSelectorController::OnSelectionEnded() { |
79 window_selector_->Shutdown(); | 81 window_selector_->Shutdown(); |
80 window_selector_.reset(); | 82 window_selector_.reset(); |
81 last_selection_time_ = base::Time::Now(); | 83 last_selection_time_ = base::Time::Now(); |
82 Shell::GetInstance()->OnOverviewModeEnded(); | 84 Shell::GetInstance()->OnOverviewModeEnded(); |
85 | |
86 // Record UMA_WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED if the active window | |
87 // is different from the window that was active upon entering overview | |
88 // mode. | |
89 aura::Window* active = wm::GetActiveWindow(); | |
bruthig
2015/05/12 17:37:38
I feel like this metric should only be recorded if
oshima
2015/05/12 20:25:13
This may also change if the window is closed or an
tdanderson
2015/05/14 01:36:32
In patch set 2 the user action won't be recorded w
| |
90 if (initially_active_window_ && active && | |
91 active != initially_active_window_) { | |
92 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | |
93 UMA_WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED); | |
94 } | |
95 initially_active_window_ = nullptr; | |
96 } | |
97 | |
98 void WindowSelectorController::OnSelectionStarting() { | |
bruthig
2015/05/12 17:37:38
It would be less invasive to WindowSelectorControl
tdanderson
2015/05/14 01:36:32
Not pursuing this as per in-person discussion.
| |
99 aura::Window* active = wm::GetActiveWindow(); | |
100 if (active && WindowSelector::IsSelectable(active)) | |
101 initially_active_window_ = active; | |
83 } | 102 } |
84 | 103 |
85 void WindowSelectorController::OnSelectionStarted() { | 104 void WindowSelectorController::OnSelectionStarted() { |
86 if (!last_selection_time_.is_null()) { | 105 if (!last_selection_time_.is_null()) { |
87 UMA_HISTOGRAM_LONG_TIMES( | 106 UMA_HISTOGRAM_LONG_TIMES( |
88 "Ash.WindowSelector.TimeBetweenUse", | 107 "Ash.WindowSelector.TimeBetweenUse", |
89 base::Time::Now() - last_selection_time_); | 108 base::Time::Now() - last_selection_time_); |
90 } | 109 } |
91 } | 110 } |
92 | 111 |
93 } // namespace ash | 112 } // namespace ash |
OLD | NEW |