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

Side by Side Diff: ash/common/wm/window_cycle_controller.cc

Issue 2766543002: Move even more from WmShell to Shell (Closed)
Patch Set: Created 3 years, 9 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/window_cycle_controller.h" 5 #include "ash/common/wm/window_cycle_controller.h"
6 6
7 #include "ash/common/metrics/task_switch_source.h" 7 #include "ash/common/metrics/task_switch_source.h"
8 #include "ash/common/session/session_controller.h" 8 #include "ash/common/session/session_controller.h"
9 #include "ash/common/wm/mru_window_tracker.h" 9 #include "ash/common/wm/mru_window_tracker.h"
10 #include "ash/common/wm/window_cycle_event_filter.h" 10 #include "ash/common/wm/window_cycle_event_filter.h"
11 #include "ash/common/wm/window_cycle_list.h" 11 #include "ash/common/wm/window_cycle_list.h"
12 #include "ash/common/wm/window_state.h" 12 #include "ash/common/wm/window_state.h"
13 #include "ash/common/wm_shell.h" 13 #include "ash/common/wm_shell.h"
14 #include "ash/common/wm_window.h" 14 #include "ash/common/wm_window.h"
15 #include "ash/public/cpp/shell_window_ids.h" 15 #include "ash/public/cpp/shell_window_ids.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 namespace { 21 namespace {
21 22
22 // Returns the most recently active window from the |window_list| or nullptr 23 // Returns the most recently active window from the |window_list| or nullptr
23 // if the list is empty. 24 // if the list is empty.
24 WmWindow* GetActiveWindow(const MruWindowTracker::WindowList& window_list) { 25 WmWindow* GetActiveWindow(const MruWindowTracker::WindowList& window_list) {
25 return window_list.empty() ? nullptr : window_list[0]; 26 return window_list.empty() ? nullptr : window_list[0];
(...skipping 21 matching lines...) Expand all
47 return; 48 return;
48 49
49 if (!IsCycling()) 50 if (!IsCycling())
50 StartCycling(); 51 StartCycling();
51 52
52 Step(direction); 53 Step(direction);
53 } 54 }
54 55
55 void WindowCycleController::StartCycling() { 56 void WindowCycleController::StartCycling() {
56 MruWindowTracker::WindowList window_list = 57 MruWindowTracker::WindowList window_list =
57 WmShell::Get()->mru_window_tracker()->BuildMruWindowList(); 58 Shell::Get()->mru_window_tracker()->BuildMruWindowList();
58 // Exclude windows: 59 // Exclude windows:
59 // - non user positionable windows, such as extension popups. 60 // - non user positionable windows, such as extension popups.
60 // - windows being dragged 61 // - windows being dragged
61 // - the AppList window, which will hide as soon as cycling starts 62 // - the AppList window, which will hide as soon as cycling starts
62 // anyway. It doesn't make sense to count it as a "switchable" window, yet 63 // anyway. It doesn't make sense to count it as a "switchable" window, yet
63 // a lot of code relies on the MRU list returning the app window. If we 64 // a lot of code relies on the MRU list returning the app window. If we
64 // don't manually remove it, the window cycling UI won't crash or misbehave, 65 // don't manually remove it, the window cycling UI won't crash or misbehave,
65 // but there will be a flicker as the target window changes. Also exclude 66 // but there will be a flicker as the target window changes. Also exclude
66 // unselectable windows such as extension popups. 67 // unselectable windows such as extension popups.
67 auto window_is_ineligible = [](WmWindow* window) { 68 auto window_is_ineligible = [](WmWindow* window) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 void WindowCycleController::Step(Direction direction) { 101 void WindowCycleController::Step(Direction direction) {
101 DCHECK(window_cycle_list_.get()); 102 DCHECK(window_cycle_list_.get());
102 window_cycle_list_->Step(direction); 103 window_cycle_list_->Step(direction);
103 } 104 }
104 105
105 void WindowCycleController::StopCycling() { 106 void WindowCycleController::StopCycling() {
106 UMA_HISTOGRAM_COUNTS_100("Ash.WindowCycleController.SelectionDepth", 107 UMA_HISTOGRAM_COUNTS_100("Ash.WindowCycleController.SelectionDepth",
107 window_cycle_list_->current_index() + 1); 108 window_cycle_list_->current_index() + 1);
108 window_cycle_list_.reset(); 109 window_cycle_list_.reset();
109 110
110 WmWindow* active_window_after_window_cycle = GetActiveWindow( 111 WmWindow* active_window_after_window_cycle =
111 WmShell::Get()->mru_window_tracker()->BuildMruWindowList()); 112 GetActiveWindow(Shell::Get()->mru_window_tracker()->BuildMruWindowList());
112 113
113 // Remove our key event filter. 114 // Remove our key event filter.
114 event_filter_.reset(); 115 event_filter_.reset();
115 UMA_HISTOGRAM_MEDIUM_TIMES("Ash.WindowCycleController.CycleTime", 116 UMA_HISTOGRAM_MEDIUM_TIMES("Ash.WindowCycleController.CycleTime",
116 base::Time::Now() - cycle_start_time_); 117 base::Time::Now() - cycle_start_time_);
117 118
118 if (active_window_after_window_cycle != nullptr && 119 if (active_window_after_window_cycle != nullptr &&
119 active_window_before_window_cycle_ != active_window_after_window_cycle) { 120 active_window_before_window_cycle_ != active_window_after_window_cycle) {
120 WmShell::Get()->RecordTaskSwitchMetric( 121 WmShell::Get()->RecordTaskSwitchMetric(
121 TaskSwitchSource::WINDOW_CYCLE_CONTROLLER); 122 TaskSwitchSource::WINDOW_CYCLE_CONTROLLER);
122 } 123 }
123 active_window_before_window_cycle_ = nullptr; 124 active_window_before_window_cycle_ = nullptr;
124 } 125 }
125 126
126 } // namespace ash 127 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/overview/window_selector_controller.cc ('k') | ash/common/wm/window_cycle_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698