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

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

Issue 2099443002: Migrate simple ash Shell metrics users. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix win compile error. 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
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/common/session/session_state_delegate.h" 7 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/common/wm/mru_window_tracker.h" 8 #include "ash/common/wm/mru_window_tracker.h"
9 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
10 #include "ash/metrics/user_metrics_recorder.h"
11 #include "ash/shell.h" 10 #include "ash/shell.h"
12 #include "ash/wm/window_cycle_list.h" 11 #include "ash/wm/window_cycle_list.h"
13 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.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
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // WindowCycleController, public: 63 // WindowCycleController, public:
65 64
66 WindowCycleController::WindowCycleController() { 65 WindowCycleController::WindowCycleController() {
67 } 66 }
68 67
69 WindowCycleController::~WindowCycleController() { 68 WindowCycleController::~WindowCycleController() {
70 } 69 }
71 70
72 // static 71 // static
73 bool WindowCycleController::CanCycle() { 72 bool WindowCycleController::CanCycle() {
74 // Don't allow window cycling if the screen is locked or a modal dialog is 73 // Prevent window cycling if the screen is locked or a modal dialog is open.
75 // open. 74 WmShell* wm_shell = WmShell::Get();
76 return !Shell::GetInstance()->session_state_delegate()->IsScreenLocked() && 75 return !wm_shell->GetSessionStateDelegate()->IsScreenLocked() &&
77 !WmShell::Get()->IsSystemModalWindowOpen() && 76 !wm_shell->IsSystemModalWindowOpen() && !wm_shell->IsPinned();
78 !WmShell::Get()->IsPinned();
79 } 77 }
80 78
81 void WindowCycleController::HandleCycleWindow(Direction direction) { 79 void WindowCycleController::HandleCycleWindow(Direction direction) {
82 if (!CanCycle()) 80 if (!CanCycle())
83 return; 81 return;
84 82
85 if (!IsCycling()) 83 if (!IsCycling())
86 StartCycling(); 84 StartCycling();
87 85
88 Step(direction); 86 Step(direction);
89 } 87 }
90 88
91 void WindowCycleController::StartCycling() { 89 void WindowCycleController::StartCycling() {
92 MruWindowTracker::WindowList window_list = 90 MruWindowTracker::WindowList window_list =
93 Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList(); 91 Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList();
94 92
95 active_window_before_window_cycle_ = GetActiveWindow(window_list); 93 active_window_before_window_cycle_ = GetActiveWindow(window_list);
96 94
97 window_cycle_list_.reset(new WindowCycleList(window_list)); 95 window_cycle_list_.reset(new WindowCycleList(window_list));
98 event_handler_.reset(new WindowCycleEventFilter()); 96 event_handler_.reset(new WindowCycleEventFilter());
99 cycle_start_time_ = base::Time::Now(); 97 cycle_start_time_ = base::Time::Now();
100 Shell::GetInstance()->metrics()->RecordUserMetricsAction(UMA_WINDOW_CYCLE); 98 WmShell::Get()->RecordUserMetricsAction(UMA_WINDOW_CYCLE);
101 } 99 }
102 100
103 ////////////////////////////////////////////////////////////////////////////// 101 //////////////////////////////////////////////////////////////////////////////
104 // WindowCycleController, private: 102 // WindowCycleController, private:
105 103
106 void WindowCycleController::Step(Direction direction) { 104 void WindowCycleController::Step(Direction direction) {
107 DCHECK(window_cycle_list_.get()); 105 DCHECK(window_cycle_list_.get());
108 window_cycle_list_->Step(direction); 106 window_cycle_list_->Step(direction);
109 } 107 }
110 108
(...skipping 12 matching lines...) Expand all
123 active_window_before_window_cycle_ != active_window_after_window_cycle) { 121 active_window_before_window_cycle_ != active_window_after_window_cycle) {
124 Shell::GetInstance() 122 Shell::GetInstance()
125 ->metrics() 123 ->metrics()
126 ->task_switch_metrics_recorder() 124 ->task_switch_metrics_recorder()
127 .OnTaskSwitch(TaskSwitchMetricsRecorder::WINDOW_CYCLE_CONTROLLER); 125 .OnTaskSwitch(TaskSwitchMetricsRecorder::WINDOW_CYCLE_CONTROLLER);
128 } 126 }
129 active_window_before_window_cycle_ = nullptr; 127 active_window_before_window_cycle_ = nullptr;
130 } 128 }
131 129
132 } // namespace ash 130 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/panels/panel_window_event_handler.cc ('k') | ash/wm/workspace/workspace_event_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698