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

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

Issue 2042913002: Converts MruWindowTracker to work with common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: not equal 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
« no previous file with comments | « ash/wm/window_cycle_controller.h ('k') | ash/wm/window_cycle_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/wm/window_cycle_controller.h" 5 #include "ash/wm/window_cycle_controller.h"
6 6
7 #include "ash/metrics/user_metrics_recorder.h" 7 #include "ash/metrics/user_metrics_recorder.h"
8 #include "ash/session/session_state_delegate.h" 8 #include "ash/session/session_state_delegate.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/mru_window_tracker.h" 10 #include "ash/wm/mru_window_tracker.h"
11 #include "ash/wm/window_cycle_list.h" 11 #include "ash/wm/window_cycle_list.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "ui/aura/window.h"
14 #include "ui/events/event.h" 13 #include "ui/events/event.h"
15 #include "ui/events/event_handler.h" 14 #include "ui/events/event_handler.h"
16 15
17 namespace ash { 16 namespace ash {
18 17
19 namespace { 18 namespace {
20 19
21 // Returns the most recently active window from the |window_list| or nullptr 20 // Returns the most recently active window from the |window_list| or nullptr
22 // if the list is empty. 21 // if the list is empty.
23 aura::Window* GetActiveWindow(const MruWindowTracker::WindowList& window_list) { 22 WmWindow* GetActiveWindow(const MruWindowTracker::WindowList& window_list) {
24 return window_list.empty() ? nullptr : window_list[0]; 23 return window_list.empty() ? nullptr : window_list[0];
25 } 24 }
26 25
27 // Filter to watch for the termination of a keyboard gesture to cycle through 26 // Filter to watch for the termination of a keyboard gesture to cycle through
28 // multiple windows. 27 // multiple windows.
29 class WindowCycleEventFilter : public ui::EventHandler { 28 class WindowCycleEventFilter : public ui::EventHandler {
30 public: 29 public:
31 WindowCycleEventFilter(); 30 WindowCycleEventFilter();
32 ~WindowCycleEventFilter() override; 31 ~WindowCycleEventFilter() override;
33 32
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // WindowCycleController, private: 102 // WindowCycleController, private:
104 103
105 void WindowCycleController::Step(Direction direction) { 104 void WindowCycleController::Step(Direction direction) {
106 DCHECK(window_cycle_list_.get()); 105 DCHECK(window_cycle_list_.get());
107 window_cycle_list_->Step(direction); 106 window_cycle_list_->Step(direction);
108 } 107 }
109 108
110 void WindowCycleController::StopCycling() { 109 void WindowCycleController::StopCycling() {
111 window_cycle_list_.reset(); 110 window_cycle_list_.reset();
112 111
113 aura::Window* active_window_after_window_cycle = GetActiveWindow( 112 WmWindow* active_window_after_window_cycle = GetActiveWindow(
114 Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList()); 113 Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList());
115 114
116 // Remove our key event filter. 115 // Remove our key event filter.
117 event_handler_.reset(); 116 event_handler_.reset();
118 UMA_HISTOGRAM_MEDIUM_TIMES("Ash.WindowCycleController.CycleTime", 117 UMA_HISTOGRAM_MEDIUM_TIMES("Ash.WindowCycleController.CycleTime",
119 base::Time::Now() - cycle_start_time_); 118 base::Time::Now() - cycle_start_time_);
120 119
121 if (active_window_after_window_cycle != nullptr && 120 if (active_window_after_window_cycle != nullptr &&
122 active_window_before_window_cycle_ != active_window_after_window_cycle) { 121 active_window_before_window_cycle_ != active_window_after_window_cycle) {
123 Shell::GetInstance() 122 Shell::GetInstance()
124 ->metrics() 123 ->metrics()
125 ->task_switch_metrics_recorder() 124 ->task_switch_metrics_recorder()
126 .OnTaskSwitch(TaskSwitchMetricsRecorder::WINDOW_CYCLE_CONTROLLER); 125 .OnTaskSwitch(TaskSwitchMetricsRecorder::WINDOW_CYCLE_CONTROLLER);
127 } 126 }
128 active_window_before_window_cycle_ = nullptr; 127 active_window_before_window_cycle_ = nullptr;
129 } 128 }
130 129
131 } // namespace ash 130 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_cycle_controller.h ('k') | ash/wm/window_cycle_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698