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

Side by Side Diff: ash/wm/lock_state_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/touch/touch_uma.cc ('k') | ash/wm/maximize_mode/maximize_mode_controller.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/lock_state_controller.h" 5 #include "ash/wm/lock_state_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "ash/cancel_mode.h" 11 #include "ash/cancel_mode.h"
12 #include "ash/common/accessibility_delegate.h" 12 #include "ash/common/accessibility_delegate.h"
13 #include "ash/common/ash_switches.h" 13 #include "ash/common/ash_switches.h"
14 #include "ash/common/shell_window_ids.h" 14 #include "ash/common/shell_window_ids.h"
15 #include "ash/metrics/user_metrics_recorder.h" 15 #include "ash/common/wm_shell.h"
16 #include "ash/shell.h" 16 #include "ash/shell.h"
17 #include "ash/shell_delegate.h" 17 #include "ash/shell_delegate.h"
18 #include "ash/wm/session_state_animator.h" 18 #include "ash/wm/session_state_animator.h"
19 #include "ash/wm/session_state_animator_impl.h" 19 #include "ash/wm/session_state_animator_impl.h"
20 #include "base/bind.h" 20 #include "base/bind.h"
21 #include "base/bind_helpers.h" 21 #include "base/bind_helpers.h"
22 #include "base/command_line.h" 22 #include "base/command_line.h"
23 #include "base/location.h" 23 #include "base/location.h"
24 #include "base/logging.h" 24 #include "base/logging.h"
25 #include "base/metrics/histogram_macros.h" 25 #include "base/metrics/histogram_macros.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 return; 188 return;
189 StartImmediatePreLockAnimation(false /* request_lock_on_completion */); 189 StartImmediatePreLockAnimation(false /* request_lock_on_completion */);
190 } 190 }
191 191
192 void LockStateController::RequestShutdown() { 192 void LockStateController::RequestShutdown() {
193 if (shutting_down_) 193 if (shutting_down_)
194 return; 194 return;
195 195
196 shutting_down_ = true; 196 shutting_down_ = true;
197 197
198 Shell* shell = ash::Shell::GetInstance(); 198 Shell* shell = Shell::GetInstance();
199 shell->cursor_manager()->HideCursor(); 199 shell->cursor_manager()->HideCursor();
200 shell->cursor_manager()->LockCursor(); 200 shell->cursor_manager()->LockCursor();
201 201
202 animator_->StartAnimation( 202 animator_->StartAnimation(
203 SessionStateAnimator::ROOT_CONTAINER, 203 SessionStateAnimator::ROOT_CONTAINER,
204 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, 204 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS,
205 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); 205 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
206 StartRealShutdownTimer(true); 206 StartRealShutdownTimer(true);
207 } 207 }
208 208
(...skipping 17 matching lines...) Expand all
226 login_status_ = status; 226 login_status_ = status;
227 system_is_locked_ = (status == LoginStatus::LOCKED); 227 system_is_locked_ = (status == LoginStatus::LOCKED);
228 } 228 }
229 229
230 void LockStateController::OnAppTerminating() { 230 void LockStateController::OnAppTerminating() {
231 // If we hear that Chrome is exiting but didn't request it ourselves, all we 231 // If we hear that Chrome is exiting but didn't request it ourselves, all we
232 // can really hope for is that we'll have time to clear the screen. 232 // can really hope for is that we'll have time to clear the screen.
233 // This is also the case when the user signs off. 233 // This is also the case when the user signs off.
234 if (!shutting_down_) { 234 if (!shutting_down_) {
235 shutting_down_ = true; 235 shutting_down_ = true;
236 Shell* shell = ash::Shell::GetInstance(); 236 Shell* shell = Shell::GetInstance();
237 shell->cursor_manager()->HideCursor(); 237 shell->cursor_manager()->HideCursor();
238 shell->cursor_manager()->LockCursor(); 238 shell->cursor_manager()->LockCursor();
239 animator_->StartAnimation(SessionStateAnimator::kAllNonRootContainersMask, 239 animator_->StartAnimation(SessionStateAnimator::kAllNonRootContainersMask,
240 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, 240 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY,
241 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); 241 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE);
242 } 242 }
243 } 243 }
244 244
245 void LockStateController::OnLockStateChanged(bool locked) { 245 void LockStateController::OnLockStateChanged(bool locked) {
246 DCHECK((lock_fail_timer_.IsRunning() && lock_duration_timer_ != nullptr) || 246 DCHECK((lock_fail_timer_.IsRunning() && lock_duration_timer_ != nullptr) ||
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 FROM_HERE, 299 FROM_HERE,
300 animator_->GetDuration(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN), 300 animator_->GetDuration(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN),
301 this, 301 this,
302 &LockStateController::OnPreShutdownAnimationTimeout); 302 &LockStateController::OnPreShutdownAnimationTimeout);
303 } 303 }
304 304
305 void LockStateController::OnPreShutdownAnimationTimeout() { 305 void LockStateController::OnPreShutdownAnimationTimeout() {
306 VLOG(1) << "OnPreShutdownAnimationTimeout"; 306 VLOG(1) << "OnPreShutdownAnimationTimeout";
307 shutting_down_ = true; 307 shutting_down_ = true;
308 308
309 Shell* shell = ash::Shell::GetInstance(); 309 Shell* shell = Shell::GetInstance();
310 shell->cursor_manager()->HideCursor(); 310 shell->cursor_manager()->HideCursor();
311 311
312 StartRealShutdownTimer(false); 312 StartRealShutdownTimer(false);
313 } 313 }
314 314
315 void LockStateController::StartRealShutdownTimer(bool with_animation_time) { 315 void LockStateController::StartRealShutdownTimer(bool with_animation_time) {
316 base::TimeDelta duration = 316 base::TimeDelta duration =
317 base::TimeDelta::FromMilliseconds(kShutdownRequestDelayMs); 317 base::TimeDelta::FromMilliseconds(kShutdownRequestDelayMs);
318 if (with_animation_time) { 318 if (with_animation_time) {
319 duration += 319 duration +=
(...skipping 20 matching lines...) Expand all
340 DCHECK(shutting_down_); 340 DCHECK(shutting_down_);
341 #if defined(OS_CHROMEOS) 341 #if defined(OS_CHROMEOS)
342 if (!base::SysInfo::IsRunningOnChromeOS()) { 342 if (!base::SysInfo::IsRunningOnChromeOS()) {
343 ShellDelegate* delegate = Shell::GetInstance()->delegate(); 343 ShellDelegate* delegate = Shell::GetInstance()->delegate();
344 if (delegate) { 344 if (delegate) {
345 delegate->Exit(); 345 delegate->Exit();
346 return; 346 return;
347 } 347 }
348 } 348 }
349 #endif 349 #endif
350 Shell::GetInstance()->metrics()->RecordUserMetricsAction( 350 WmShell::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON);
351 UMA_ACCEL_SHUT_DOWN_POWER_BUTTON);
352 delegate_->RequestShutdown(); 351 delegate_->RequestShutdown();
353 } 352 }
354 353
355 void LockStateController::StartCancellableShutdownAnimation() { 354 void LockStateController::StartCancellableShutdownAnimation() {
356 Shell* shell = ash::Shell::GetInstance(); 355 Shell* shell = Shell::GetInstance();
357 // Hide cursor, but let it reappear if the mouse moves. 356 // Hide cursor, but let it reappear if the mouse moves.
358 shell->cursor_manager()->HideCursor(); 357 shell->cursor_manager()->HideCursor();
359 358
360 animator_->StartAnimation( 359 animator_->StartAnimation(
361 SessionStateAnimator::ROOT_CONTAINER, 360 SessionStateAnimator::ROOT_CONTAINER,
362 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, 361 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS,
363 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); 362 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
364 StartPreShutdownAnimationTimer(); 363 StartPreShutdownAnimationTimer();
365 } 364 }
366 365
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 510
512 // Don't do anything (including starting the lock-fail timer) if the screen 511 // Don't do anything (including starting the lock-fail timer) if the screen
513 // was already locked while the animation was going. 512 // was already locked while the animation was going.
514 if (system_is_locked_) { 513 if (system_is_locked_) {
515 DCHECK(!request_lock) << "Got request to lock already-locked system " 514 DCHECK(!request_lock) << "Got request to lock already-locked system "
516 << "at completion of pre-lock animation"; 515 << "at completion of pre-lock animation";
517 return; 516 return;
518 } 517 }
519 518
520 if (request_lock) { 519 if (request_lock) {
521 Shell::GetInstance()->metrics()->RecordUserMetricsAction( 520 WmShell::Get()->RecordUserMetricsAction(
522 shutdown_after_lock_ ? 521 shutdown_after_lock_ ? UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON
523 UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON : 522 : UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON);
524 UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON);
525 delegate_->RequestLockScreen(); 523 delegate_->RequestLockScreen();
526 } 524 }
527 525
528 base::TimeDelta timeout = 526 base::TimeDelta timeout =
529 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs); 527 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs);
530 #if defined(OS_CHROMEOS) 528 #if defined(OS_CHROMEOS)
531 // Increase lock timeout for slower hardware, see http://crbug.com/350628 529 // Increase lock timeout for slower hardware, see http://crbug.com/350628
532 const std::string board = base::SysInfo::GetLsbReleaseBoard(); 530 const std::string board = base::SysInfo::GetLsbReleaseBoard();
533 if (board == "x86-mario" || 531 if (board == "x86-mario" ||
534 base::StartsWith(board, "x86-alex", base::CompareCase::SENSITIVE) || 532 base::StartsWith(board, "x86-alex", base::CompareCase::SENSITIVE) ||
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 if (unlocked_properties_.get() && 607 if (unlocked_properties_.get() &&
610 unlocked_properties_->background_is_hidden) { 608 unlocked_properties_->background_is_hidden) {
611 animation_sequence->StartAnimation( 609 animation_sequence->StartAnimation(
612 SessionStateAnimator::DESKTOP_BACKGROUND, 610 SessionStateAnimator::DESKTOP_BACKGROUND,
613 SessionStateAnimator::ANIMATION_FADE_OUT, 611 SessionStateAnimator::ANIMATION_FADE_OUT,
614 speed); 612 speed);
615 } 613 }
616 } 614 }
617 615
618 } // namespace ash 616 } // namespace ash
OLDNEW
« no previous file with comments | « ash/touch/touch_uma.cc ('k') | ash/wm/maximize_mode/maximize_mode_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698