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

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

Issue 2234233002: Enable ash window cycle UI by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sky review Created 4 years, 4 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/common/ash_switches.cc ('k') | ash/common/wm/window_cycle_list.h » ('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/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
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 remove it, the window cycling UI won't crash or misbehave,
61 // but there will be a flicker as the target window changes.
62 window_list.erase(std::remove_if(window_list.begin(), window_list.end(),
63 [](WmWindow* window) {
64 return window->GetRootWindow()
65 ->GetChildByShellWindowId(
66 kShellWindowId_AppListContainer)
67 ->Contains(window);
68 }),
69 window_list.end());
55 70
56 active_window_before_window_cycle_ = GetActiveWindow(window_list); 71 active_window_before_window_cycle_ = GetActiveWindow(window_list);
57 72
58 window_cycle_list_.reset(new WindowCycleList(window_list)); 73 window_cycle_list_.reset(new WindowCycleList(window_list));
59 event_filter_ = WmShell::Get()->CreateWindowCycleEventFilter(); 74 event_filter_ = WmShell::Get()->CreateWindowCycleEventFilter();
60 cycle_start_time_ = base::Time::Now(); 75 cycle_start_time_ = base::Time::Now();
61 WmShell::Get()->RecordUserMetricsAction(UMA_WINDOW_CYCLE); 76 WmShell::Get()->RecordUserMetricsAction(UMA_WINDOW_CYCLE);
62 UMA_HISTOGRAM_COUNTS_100("Ash.WindowCycleController.Items", 77 UMA_HISTOGRAM_COUNTS_100("Ash.WindowCycleController.Items",
63 window_list.size()); 78 window_list.size());
64 } 79 }
(...skipping 21 matching lines...) Expand all
86 101
87 if (active_window_after_window_cycle != nullptr && 102 if (active_window_after_window_cycle != nullptr &&
88 active_window_before_window_cycle_ != active_window_after_window_cycle) { 103 active_window_before_window_cycle_ != active_window_after_window_cycle) {
89 WmShell::Get()->RecordTaskSwitchMetric( 104 WmShell::Get()->RecordTaskSwitchMetric(
90 TaskSwitchSource::WINDOW_CYCLE_CONTROLLER); 105 TaskSwitchSource::WINDOW_CYCLE_CONTROLLER);
91 } 106 }
92 active_window_before_window_cycle_ = nullptr; 107 active_window_before_window_cycle_ = nullptr;
93 } 108 }
94 109
95 } // namespace ash 110 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/ash_switches.cc ('k') | ash/common/wm/window_cycle_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698