Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
| 9 #include "ash/common/shell_window_ids.h" | |
| 9 #include "ash/common/wm/mru_window_tracker.h" | 10 #include "ash/common/wm/mru_window_tracker.h" |
| 10 #include "ash/common/wm/window_cycle_event_filter.h" | 11 #include "ash/common/wm/window_cycle_event_filter.h" |
| 11 #include "ash/common/wm/window_cycle_list.h" | 12 #include "ash/common/wm/window_cycle_list.h" |
| 12 #include "ash/common/wm_shell.h" | 13 #include "ash/common/wm_shell.h" |
| 14 #include "ash/common/wm_window.h" | |
| 13 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 14 | 16 |
| 15 namespace ash { | 17 namespace ash { |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 | 20 |
| 19 // Returns the most recently active window from the |window_list| or nullptr | 21 // Returns the most recently active window from the |window_list| or nullptr |
| 20 // if the list is empty. | 22 // if the list is empty. |
| 21 WmWindow* GetActiveWindow(const MruWindowTracker::WindowList& window_list) { | 23 WmWindow* GetActiveWindow(const MruWindowTracker::WindowList& window_list) { |
| 22 return window_list.empty() ? nullptr : window_list[0]; | 24 return window_list.empty() ? nullptr : window_list[0]; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 45 | 47 |
| 46 if (!IsCycling()) | 48 if (!IsCycling()) |
| 47 StartCycling(); | 49 StartCycling(); |
| 48 | 50 |
| 49 Step(direction); | 51 Step(direction); |
| 50 } | 52 } |
| 51 | 53 |
| 52 void WindowCycleController::StartCycling() { | 54 void WindowCycleController::StartCycling() { |
| 53 MruWindowTracker::WindowList window_list = | 55 MruWindowTracker::WindowList window_list = |
| 54 WmShell::Get()->mru_window_tracker()->BuildMruWindowList(); | 56 WmShell::Get()->mru_window_tracker()->BuildMruWindowList(); |
| 57 // Exclude the AppList window, which will hide as soon as cycling starts | |
| 58 // anyway. It doesn't make sense to count it as a "switchable" window, yet | |
| 59 // a lot of code relies on the MRU list returning the app window. If we | |
| 60 // don't manually do this, the window cycling UI won't crash or misbehave, but | |
| 61 // there will be a flicker as the target window changes. | |
|
Evan Stade
2016/08/12 22:51:57
this is really annoying and gross. See ash/common/
| |
| 62 window_list.erase( | |
| 63 std::remove_if(window_list.begin(), window_list.end(), | |
| 64 [](WmWindow* window) { | |
| 65 bool foo = window->GetRootWindow() | |
| 66 ->GetChildByShellWindowId( | |
| 67 kShellWindowId_AppListContainer) | |
| 68 ->Contains(window); | |
| 69 return foo; | |
| 70 }), | |
| 71 window_list.end()); | |
| 55 | 72 |
| 56 active_window_before_window_cycle_ = GetActiveWindow(window_list); | 73 active_window_before_window_cycle_ = GetActiveWindow(window_list); |
| 57 | 74 |
| 58 window_cycle_list_.reset(new WindowCycleList(window_list)); | 75 window_cycle_list_.reset(new WindowCycleList(window_list)); |
| 59 event_filter_ = WmShell::Get()->CreateWindowCycleEventFilter(); | 76 event_filter_ = WmShell::Get()->CreateWindowCycleEventFilter(); |
| 60 cycle_start_time_ = base::Time::Now(); | 77 cycle_start_time_ = base::Time::Now(); |
| 61 WmShell::Get()->RecordUserMetricsAction(UMA_WINDOW_CYCLE); | 78 WmShell::Get()->RecordUserMetricsAction(UMA_WINDOW_CYCLE); |
| 62 UMA_HISTOGRAM_COUNTS_100("Ash.WindowCycleController.Items", | 79 UMA_HISTOGRAM_COUNTS_100("Ash.WindowCycleController.Items", |
| 63 window_list.size()); | 80 window_list.size()); |
| 64 } | 81 } |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 86 | 103 |
| 87 if (active_window_after_window_cycle != nullptr && | 104 if (active_window_after_window_cycle != nullptr && |
| 88 active_window_before_window_cycle_ != active_window_after_window_cycle) { | 105 active_window_before_window_cycle_ != active_window_after_window_cycle) { |
| 89 WmShell::Get()->RecordTaskSwitchMetric( | 106 WmShell::Get()->RecordTaskSwitchMetric( |
| 90 TaskSwitchSource::WINDOW_CYCLE_CONTROLLER); | 107 TaskSwitchSource::WINDOW_CYCLE_CONTROLLER); |
| 91 } | 108 } |
| 92 active_window_before_window_cycle_ = nullptr; | 109 active_window_before_window_cycle_ = nullptr; |
| 93 } | 110 } |
| 94 | 111 |
| 95 } // namespace ash | 112 } // namespace ash |
| OLD | NEW |