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

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

Issue 2808723004: Renames WmShell to ShellPort (Closed)
Patch Set: cleanup Created 3 years, 8 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/wm/window_cycle_controller.h" 5 #include "ash/wm/window_cycle_controller.h"
6 6
7 #include "ash/metrics/task_switch_source.h" 7 #include "ash/metrics/task_switch_source.h"
8 #include "ash/public/cpp/shell_window_ids.h" 8 #include "ash/public/cpp/shell_window_ids.h"
9 #include "ash/session/session_controller.h" 9 #include "ash/session/session_controller.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/shell_port.h"
11 #include "ash/wm/mru_window_tracker.h" 12 #include "ash/wm/mru_window_tracker.h"
12 #include "ash/wm/screen_pinning_controller.h" 13 #include "ash/wm/screen_pinning_controller.h"
13 #include "ash/wm/window_cycle_event_filter.h" 14 #include "ash/wm/window_cycle_event_filter.h"
14 #include "ash/wm/window_cycle_list.h" 15 #include "ash/wm/window_cycle_list.h"
15 #include "ash/wm/window_state.h" 16 #include "ash/wm/window_state.h"
16 #include "ash/wm_shell.h"
17 #include "ash/wm_window.h" 17 #include "ash/wm_window.h"
18 #include "base/metrics/histogram_macros.h" 18 #include "base/metrics/histogram_macros.h"
19 19
20 namespace ash { 20 namespace ash {
21 21
22 namespace { 22 namespace {
23 23
24 // Returns the most recently active window from the |window_list| or nullptr 24 // Returns the most recently active window from the |window_list| or nullptr
25 // if the list is empty. 25 // if the list is empty.
26 WmWindow* GetActiveWindow(const MruWindowTracker::WindowList& window_list) { 26 WmWindow* GetActiveWindow(const MruWindowTracker::WindowList& window_list) {
27 return window_list.empty() ? nullptr : window_list[0]; 27 return window_list.empty() ? nullptr : window_list[0];
28 } 28 }
29 29
30 } // namespace 30 } // namespace
31 31
32 ////////////////////////////////////////////////////////////////////////////// 32 //////////////////////////////////////////////////////////////////////////////
33 // WindowCycleController, public: 33 // WindowCycleController, public:
34 34
35 WindowCycleController::WindowCycleController() {} 35 WindowCycleController::WindowCycleController() {}
36 36
37 WindowCycleController::~WindowCycleController() {} 37 WindowCycleController::~WindowCycleController() {}
38 38
39 // static 39 // static
40 bool WindowCycleController::CanCycle() { 40 bool WindowCycleController::CanCycle() {
41 // Prevent window cycling if the screen is locked or a modal dialog is open. 41 // Prevent window cycling if the screen is locked or a modal dialog is open.
42 WmShell* wm_shell = WmShell::Get();
43 return !Shell::Get()->session_controller()->IsScreenLocked() && 42 return !Shell::Get()->session_controller()->IsScreenLocked() &&
44 !wm_shell->IsSystemModalWindowOpen() && 43 !ShellPort::Get()->IsSystemModalWindowOpen() &&
45 !Shell::Get()->screen_pinning_controller()->IsPinned(); 44 !Shell::Get()->screen_pinning_controller()->IsPinned();
46 } 45 }
47 46
48 void WindowCycleController::HandleCycleWindow(Direction direction) { 47 void WindowCycleController::HandleCycleWindow(Direction direction) {
49 if (!CanCycle()) 48 if (!CanCycle())
50 return; 49 return;
51 50
52 if (!IsCycling()) 51 if (!IsCycling())
53 StartCycling(); 52 StartCycling();
54 53
(...skipping 19 matching lines...) Expand all
74 ->GetChildByShellWindowId(kShellWindowId_AppListContainer) 73 ->GetChildByShellWindowId(kShellWindowId_AppListContainer)
75 ->Contains(window); 74 ->Contains(window);
76 }; 75 };
77 window_list.erase(std::remove_if(window_list.begin(), window_list.end(), 76 window_list.erase(std::remove_if(window_list.begin(), window_list.end(),
78 window_is_ineligible), 77 window_is_ineligible),
79 window_list.end()); 78 window_list.end());
80 79
81 active_window_before_window_cycle_ = GetActiveWindow(window_list); 80 active_window_before_window_cycle_ = GetActiveWindow(window_list);
82 81
83 window_cycle_list_.reset(new WindowCycleList(window_list)); 82 window_cycle_list_.reset(new WindowCycleList(window_list));
84 event_filter_ = WmShell::Get()->CreateWindowCycleEventFilter(); 83 event_filter_ = ShellPort::Get()->CreateWindowCycleEventFilter();
85 cycle_start_time_ = base::Time::Now(); 84 cycle_start_time_ = base::Time::Now();
86 WmShell::Get()->RecordUserMetricsAction(UMA_WINDOW_CYCLE); 85 ShellPort::Get()->RecordUserMetricsAction(UMA_WINDOW_CYCLE);
87 UMA_HISTOGRAM_COUNTS_100("Ash.WindowCycleController.Items", 86 UMA_HISTOGRAM_COUNTS_100("Ash.WindowCycleController.Items",
88 window_list.size()); 87 window_list.size());
89 } 88 }
90 89
91 void WindowCycleController::CompleteCycling() { 90 void WindowCycleController::CompleteCycling() {
92 window_cycle_list_->set_user_did_accept(true); 91 window_cycle_list_->set_user_did_accept(true);
93 StopCycling(); 92 StopCycling();
94 } 93 }
95 94
96 void WindowCycleController::CancelCycling() { 95 void WindowCycleController::CancelCycling() {
(...skipping 16 matching lines...) Expand all
113 WmWindow* active_window_after_window_cycle = 112 WmWindow* active_window_after_window_cycle =
114 GetActiveWindow(Shell::Get()->mru_window_tracker()->BuildMruWindowList()); 113 GetActiveWindow(Shell::Get()->mru_window_tracker()->BuildMruWindowList());
115 114
116 // Remove our key event filter. 115 // Remove our key event filter.
117 event_filter_.reset(); 116 event_filter_.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 WmShell::Get()->RecordTaskSwitchMetric( 122 ShellPort::Get()->RecordTaskSwitchMetric(
124 TaskSwitchSource::WINDOW_CYCLE_CONTROLLER); 123 TaskSwitchSource::WINDOW_CYCLE_CONTROLLER);
125 } 124 }
126 active_window_before_window_cycle_ = nullptr; 125 active_window_before_window_cycle_ = nullptr;
127 } 126 }
128 127
129 } // namespace ash 128 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698