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

Side by Side Diff: ash/wm/lock_state_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 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/accessibility_delegate.h" 11 #include "ash/accessibility_delegate.h"
12 #include "ash/cancel_mode.h" 12 #include "ash/cancel_mode.h"
13 #include "ash/public/cpp/shell_window_ids.h" 13 #include "ash/public/cpp/shell_window_ids.h"
14 #include "ash/public/interfaces/shutdown.mojom.h" 14 #include "ash/public/interfaces/shutdown.mojom.h"
15 #include "ash/shell.h" 15 #include "ash/shell.h"
16 #include "ash/shell_delegate.h" 16 #include "ash/shell_delegate.h"
17 #include "ash/shell_port.h"
17 #include "ash/shutdown_controller.h" 18 #include "ash/shutdown_controller.h"
18 #include "ash/wm/session_state_animator.h" 19 #include "ash/wm/session_state_animator.h"
19 #include "ash/wm/session_state_animator_impl.h" 20 #include "ash/wm/session_state_animator_impl.h"
20 #include "ash/wm_shell.h"
21 #include "base/bind.h" 21 #include "base/bind.h"
22 #include "base/bind_helpers.h" 22 #include "base/bind_helpers.h"
23 #include "base/command_line.h" 23 #include "base/command_line.h"
24 #include "base/location.h" 24 #include "base/location.h"
25 #include "base/logging.h" 25 #include "base/logging.h"
26 #include "base/metrics/histogram_macros.h" 26 #include "base/metrics/histogram_macros.h"
27 #include "base/strings/string_util.h" 27 #include "base/strings/string_util.h"
28 #include "base/sys_info.h" 28 #include "base/sys_info.h"
29 #include "base/timer/timer.h" 29 #include "base/timer/timer.h"
30 #include "chromeos/dbus/dbus_thread_manager.h" 30 #include "chromeos/dbus/dbus_thread_manager.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 duration = std::max(duration, sound_duration); 292 duration = std::max(duration, sound_duration);
293 293
294 real_shutdown_timer_.Start( 294 real_shutdown_timer_.Start(
295 FROM_HERE, duration, base::Bind(&LockStateController::OnRealPowerTimeout, 295 FROM_HERE, duration, base::Bind(&LockStateController::OnRealPowerTimeout,
296 base::Unretained(this))); 296 base::Unretained(this)));
297 } 297 }
298 298
299 void LockStateController::OnRealPowerTimeout() { 299 void LockStateController::OnRealPowerTimeout() {
300 VLOG(1) << "OnRealPowerTimeout"; 300 VLOG(1) << "OnRealPowerTimeout";
301 DCHECK(shutting_down_); 301 DCHECK(shutting_down_);
302 WmShell::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); 302 ShellPort::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON);
303 // Shut down or reboot based on device policy. 303 // Shut down or reboot based on device policy.
304 shutdown_controller_->ShutDownOrReboot(); 304 shutdown_controller_->ShutDownOrReboot();
305 } 305 }
306 306
307 void LockStateController::StartCancellableShutdownAnimation() { 307 void LockStateController::StartCancellableShutdownAnimation() {
308 Shell* shell = Shell::Get(); 308 Shell* shell = Shell::Get();
309 // Hide cursor, but let it reappear if the mouse moves. 309 // Hide cursor, but let it reappear if the mouse moves.
310 if (shell->cursor_manager()) 310 if (shell->cursor_manager())
311 shell->cursor_manager()->HideCursor(); 311 shell->cursor_manager()->HideCursor();
312 312
(...skipping 26 matching lines...) Expand all
339 // Hide the screen locker containers so we can raise them later. 339 // Hide the screen locker containers so we can raise them later.
340 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS, 340 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
341 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, 341 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY,
342 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); 342 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE);
343 AnimateWallpaperAppearanceIfNecessary( 343 AnimateWallpaperAppearanceIfNecessary(
344 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, animation_sequence); 344 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, animation_sequence);
345 345
346 animation_sequence->EndSequence(); 346 animation_sequence->EndSequence();
347 347
348 DispatchCancelMode(); 348 DispatchCancelMode();
349 WmShell::Get()->OnLockStateEvent( 349 ShellPort::Get()->OnLockStateEvent(
350 LockStateObserver::EVENT_LOCK_ANIMATION_STARTED); 350 LockStateObserver::EVENT_LOCK_ANIMATION_STARTED);
351 } 351 }
352 352
353 void LockStateController::StartCancellablePreLockAnimation() { 353 void LockStateController::StartCancellablePreLockAnimation() {
354 animating_lock_ = true; 354 animating_lock_ = true;
355 StoreUnlockedProperties(); 355 StoreUnlockedProperties();
356 VLOG(1) << "StartCancellablePreLockAnimation"; 356 VLOG(1) << "StartCancellablePreLockAnimation";
357 base::Closure next_animation_starter = 357 base::Closure next_animation_starter =
358 base::Bind(&LockStateController::PreLockAnimationFinished, 358 base::Bind(&LockStateController::PreLockAnimationFinished,
359 weak_ptr_factory_.GetWeakPtr(), true /* request_lock */); 359 weak_ptr_factory_.GetWeakPtr(), true /* request_lock */);
360 SessionStateAnimator::AnimationSequence* animation_sequence = 360 SessionStateAnimator::AnimationSequence* animation_sequence =
361 animator_->BeginAnimationSequence(next_animation_starter); 361 animator_->BeginAnimationSequence(next_animation_starter);
362 362
363 animation_sequence->StartAnimation( 363 animation_sequence->StartAnimation(
364 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, 364 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
365 SessionStateAnimator::ANIMATION_LIFT, 365 SessionStateAnimator::ANIMATION_LIFT,
366 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); 366 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE);
367 animation_sequence->StartAnimation( 367 animation_sequence->StartAnimation(
368 SessionStateAnimator::LAUNCHER, SessionStateAnimator::ANIMATION_FADE_OUT, 368 SessionStateAnimator::LAUNCHER, SessionStateAnimator::ANIMATION_FADE_OUT,
369 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); 369 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE);
370 // Hide the screen locker containers so we can raise them later. 370 // Hide the screen locker containers so we can raise them later.
371 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS, 371 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
372 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, 372 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY,
373 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); 373 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE);
374 AnimateWallpaperAppearanceIfNecessary( 374 AnimateWallpaperAppearanceIfNecessary(
375 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, animation_sequence); 375 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, animation_sequence);
376 376
377 DispatchCancelMode(); 377 DispatchCancelMode();
378 WmShell::Get()->OnLockStateEvent( 378 ShellPort::Get()->OnLockStateEvent(
379 LockStateObserver::EVENT_PRELOCK_ANIMATION_STARTED); 379 LockStateObserver::EVENT_PRELOCK_ANIMATION_STARTED);
380 animation_sequence->EndSequence(); 380 animation_sequence->EndSequence();
381 } 381 }
382 382
383 void LockStateController::CancelPreLockAnimation() { 383 void LockStateController::CancelPreLockAnimation() {
384 VLOG(1) << "CancelPreLockAnimation"; 384 VLOG(1) << "CancelPreLockAnimation";
385 base::Closure next_animation_starter = 385 base::Closure next_animation_starter =
386 base::Bind(&LockStateController::LockAnimationCancelled, 386 base::Bind(&LockStateController::LockAnimationCancelled,
387 weak_ptr_factory_.GetWeakPtr()); 387 weak_ptr_factory_.GetWeakPtr());
388 SessionStateAnimator::AnimationSequence* animation_sequence = 388 SessionStateAnimator::AnimationSequence* animation_sequence =
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 457
458 // Don't do anything (including starting the lock-fail timer) if the screen 458 // Don't do anything (including starting the lock-fail timer) if the screen
459 // was already locked while the animation was going. 459 // was already locked while the animation was going.
460 if (system_is_locked_) { 460 if (system_is_locked_) {
461 DCHECK(!request_lock) << "Got request to lock already-locked system " 461 DCHECK(!request_lock) << "Got request to lock already-locked system "
462 << "at completion of pre-lock animation"; 462 << "at completion of pre-lock animation";
463 return; 463 return;
464 } 464 }
465 465
466 if (request_lock) { 466 if (request_lock) {
467 WmShell::Get()->RecordUserMetricsAction( 467 ShellPort::Get()->RecordUserMetricsAction(
468 shutdown_after_lock_ ? UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON 468 shutdown_after_lock_ ? UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON
469 : UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON); 469 : UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON);
470 chromeos::DBusThreadManager::Get() 470 chromeos::DBusThreadManager::Get()
471 ->GetSessionManagerClient() 471 ->GetSessionManagerClient()
472 ->RequestLockScreen(); 472 ->RequestLockScreen();
473 } 473 }
474 474
475 base::TimeDelta timeout = 475 base::TimeDelta timeout =
476 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs); 476 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs);
477 // Increase lock timeout for slower hardware, see http://crbug.com/350628 477 // Increase lock timeout for slower hardware, see http://crbug.com/350628
478 // The devices with boards "x86-mario", "daisy", "x86-alex" and "x86-zgb" have 478 // The devices with boards "x86-mario", "daisy", "x86-alex" and "x86-zgb" have
479 // slower hardware. For "x86-alex" and "x86-zgb" there are some modifications 479 // slower hardware. For "x86-alex" and "x86-zgb" there are some modifications
480 // like "x86-alex-he". Also there's "daisy", "daisy_spring" and "daisy_skate", 480 // like "x86-alex-he". Also there's "daisy", "daisy_spring" and "daisy_skate",
481 // but they are all different devices and only "daisy" has slower hardware. 481 // but they are all different devices and only "daisy" has slower hardware.
482 const std::string board = base::SysInfo::GetStrippedReleaseBoard(); 482 const std::string board = base::SysInfo::GetStrippedReleaseBoard();
483 if (board == "x86-mario" || board == "daisy" || 483 if (board == "x86-mario" || board == "daisy" ||
484 base::StartsWith(board, "x86-alex", base::CompareCase::SENSITIVE) || 484 base::StartsWith(board, "x86-alex", base::CompareCase::SENSITIVE) ||
485 base::StartsWith(board, "x86-zgb", base::CompareCase::SENSITIVE)) { 485 base::StartsWith(board, "x86-zgb", base::CompareCase::SENSITIVE)) {
486 timeout *= 2; 486 timeout *= 2;
487 } 487 }
488 lock_fail_timer_.Start(FROM_HERE, timeout, this, 488 lock_fail_timer_.Start(FROM_HERE, timeout, this,
489 &LockStateController::OnLockFailTimeout); 489 &LockStateController::OnLockFailTimeout);
490 490
491 lock_duration_timer_.reset(new base::ElapsedTimer()); 491 lock_duration_timer_.reset(new base::ElapsedTimer());
492 } 492 }
493 493
494 void LockStateController::PostLockAnimationFinished() { 494 void LockStateController::PostLockAnimationFinished() {
495 animating_lock_ = false; 495 animating_lock_ = false;
496 VLOG(1) << "PostLockAnimationFinished"; 496 VLOG(1) << "PostLockAnimationFinished";
497 WmShell::Get()->OnLockStateEvent( 497 ShellPort::Get()->OnLockStateEvent(
498 LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED); 498 LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED);
499 if (!lock_screen_displayed_callback_.is_null()) { 499 if (!lock_screen_displayed_callback_.is_null()) {
500 lock_screen_displayed_callback_.Run(); 500 lock_screen_displayed_callback_.Run();
501 lock_screen_displayed_callback_.Reset(); 501 lock_screen_displayed_callback_.Reset();
502 } 502 }
503 CHECK(!views::MenuController::GetActiveInstance()); 503 CHECK(!views::MenuController::GetActiveInstance());
504 if (shutdown_after_lock_) { 504 if (shutdown_after_lock_) {
505 shutdown_after_lock_ = false; 505 shutdown_after_lock_ = false;
506 StartLockToShutdownTimer(); 506 StartLockToShutdownTimer();
507 } 507 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 SessionStateAnimator::AnimationSpeed speed, 552 SessionStateAnimator::AnimationSpeed speed,
553 SessionStateAnimator::AnimationSequence* animation_sequence) { 553 SessionStateAnimator::AnimationSequence* animation_sequence) {
554 if (unlocked_properties_.get() && unlocked_properties_->wallpaper_is_hidden) { 554 if (unlocked_properties_.get() && unlocked_properties_->wallpaper_is_hidden) {
555 animation_sequence->StartAnimation(SessionStateAnimator::WALLPAPER, 555 animation_sequence->StartAnimation(SessionStateAnimator::WALLPAPER,
556 SessionStateAnimator::ANIMATION_FADE_OUT, 556 SessionStateAnimator::ANIMATION_FADE_OUT,
557 speed); 557 speed);
558 } 558 }
559 } 559 }
560 560
561 } // namespace ash 561 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698