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

Side by Side Diff: ash/wm/maximize_mode/maximize_mode_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
« no previous file with comments | « ash/wm/lock_state_controller.cc ('k') | ash/wm/panels/panel_window_event_handler.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/maximize_mode/maximize_mode_controller.h" 5 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/accelerators/accelerator_controller.h" 9 #include "ash/accelerators/accelerator_controller.h"
10 #include "ash/accelerators/accelerator_table.h" 10 #include "ash/accelerators/accelerator_table.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 MaximizeModeController::MaximizeModeController() 102 MaximizeModeController::MaximizeModeController()
103 : have_seen_accelerometer_data_(false), 103 : have_seen_accelerometer_data_(false),
104 touchview_usage_interval_start_time_(base::Time::Now()), 104 touchview_usage_interval_start_time_(base::Time::Now()),
105 tick_clock_(new base::DefaultTickClock()), 105 tick_clock_(new base::DefaultTickClock()),
106 #if defined(OS_CHROMEOS) 106 #if defined(OS_CHROMEOS)
107 tablet_mode_switch_is_on_(false), 107 tablet_mode_switch_is_on_(false),
108 #endif 108 #endif
109 lid_is_closed_(false) { 109 lid_is_closed_(false) {
110 WmShell::Get()->AddShellObserver(this); 110 WmShell::Get()->AddShellObserver(this);
111 Shell* shell = Shell::GetInstance(); 111 WmShell::Get()->RecordUserMetricsAction(UMA_MAXIMIZE_MODE_INITIALLY_DISABLED);
112 shell->metrics()->RecordUserMetricsAction(
113 ash::UMA_MAXIMIZE_MODE_INITIALLY_DISABLED);
114 112
115 #if defined(OS_CHROMEOS) 113 #if defined(OS_CHROMEOS)
116 // TODO(jonross): Do not create MaximizeModeController if the flag is 114 // TODO(jonross): Do not create MaximizeModeController if the flag is
117 // unavailable. This will require refactoring 115 // unavailable. This will require refactoring
118 // IsMaximizeModeWindowManagerEnabled to check for the existance of the 116 // IsMaximizeModeWindowManagerEnabled to check for the existance of the
119 // controller. 117 // controller.
120 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 118 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
121 switches::kAshEnableTouchView)) { 119 switches::kAshEnableTouchView)) {
122 chromeos::AccelerometerReader::GetInstance()->AddObserver(this); 120 chromeos::AccelerometerReader::GetInstance()->AddObserver(this);
123 shell->window_tree_host_manager()->AddObserver(this); 121 Shell::GetInstance()->window_tree_host_manager()->AddObserver(this);
124 } 122 }
125 chromeos::DBusThreadManager::Get()-> 123 chromeos::DBusThreadManager::Get()->
126 GetPowerManagerClient()->AddObserver(this); 124 GetPowerManagerClient()->AddObserver(this);
127 #endif // OS_CHROMEOS 125 #endif // OS_CHROMEOS
128 } 126 }
129 127
130 MaximizeModeController::~MaximizeModeController() { 128 MaximizeModeController::~MaximizeModeController() {
131 WmShell::Get()->RemoveShellObserver(this); 129 WmShell::Get()->RemoveShellObserver(this);
132 #if defined(OS_CHROMEOS) 130 #if defined(OS_CHROMEOS)
133 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 131 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 27 matching lines...) Expand all
161 bool is_enabled = !!maximize_mode_window_manager_.get(); 159 bool is_enabled = !!maximize_mode_window_manager_.get();
162 if (should_enable == is_enabled) 160 if (should_enable == is_enabled)
163 return; 161 return;
164 162
165 Shell* shell = Shell::GetInstance(); 163 Shell* shell = Shell::GetInstance();
166 164
167 if (should_enable) { 165 if (should_enable) {
168 maximize_mode_window_manager_.reset(new MaximizeModeWindowManager()); 166 maximize_mode_window_manager_.reset(new MaximizeModeWindowManager());
169 // TODO(jonross): Move the maximize mode notifications from ShellObserver 167 // TODO(jonross): Move the maximize mode notifications from ShellObserver
170 // to MaximizeModeController::Observer 168 // to MaximizeModeController::Observer
171 shell->metrics()->RecordUserMetricsAction(ash::UMA_MAXIMIZE_MODE_ENABLED); 169 WmShell::Get()->RecordUserMetricsAction(UMA_MAXIMIZE_MODE_ENABLED);
172 shell->OnMaximizeModeStarted(); 170 shell->OnMaximizeModeStarted();
173 } else { 171 } else {
174 maximize_mode_window_manager_.reset(); 172 maximize_mode_window_manager_.reset();
175 shell->metrics()->RecordUserMetricsAction(ash::UMA_MAXIMIZE_MODE_DISABLED); 173 WmShell::Get()->RecordUserMetricsAction(UMA_MAXIMIZE_MODE_DISABLED);
176 shell->OnMaximizeModeEnded(); 174 shell->OnMaximizeModeEnded();
177 } 175 }
178 } 176 }
179 177
180 bool MaximizeModeController::IsMaximizeModeWindowManagerEnabled() const { 178 bool MaximizeModeController::IsMaximizeModeWindowManagerEnabled() const {
181 return maximize_mode_window_manager_.get() != NULL; 179 return maximize_mode_window_manager_.get() != NULL;
182 } 180 }
183 181
184 void MaximizeModeController::AddWindow(aura::Window* window) { 182 void MaximizeModeController::AddWindow(aura::Window* window) {
185 if (IsMaximizeModeWindowManagerEnabled()) 183 if (IsMaximizeModeWindowManagerEnabled())
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 return elapsed_time.InSeconds() <= kLidRecentlyOpenedDurationSeconds; 431 return elapsed_time.InSeconds() <= kLidRecentlyOpenedDurationSeconds;
434 } 432 }
435 433
436 void MaximizeModeController::SetTickClockForTest( 434 void MaximizeModeController::SetTickClockForTest(
437 std::unique_ptr<base::TickClock> tick_clock) { 435 std::unique_ptr<base::TickClock> tick_clock) {
438 DCHECK(tick_clock_); 436 DCHECK(tick_clock_);
439 tick_clock_ = std::move(tick_clock); 437 tick_clock_ = std::move(tick_clock);
440 } 438 }
441 439
442 } // namespace ash 440 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/lock_state_controller.cc ('k') | ash/wm/panels/panel_window_event_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698