Rename SessionStateController -> LockStateController.
Now that we have SessionStateDelegate which covers more aspects of the session than just lock/unlock/shut down animations makes sense to rename lock animation related classes.
SessionStateController -> LockStateController
SessionStateControllerImpl2 > LockStateControllerImpl2
SessionStateObserver > LockStateObserver
SessionStateObserver will be used as observer for SessionStateDelegate for things like active user changed etc.
NOT renaming SessionStateControllerImpl since it is a legacy implementation and will removed soon.
BUG=180903
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/15974008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203193 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 7d05c1b..2cae8ab 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -386,6 +386,11 @@
'wm/gestures/two_finger_drag_handler.h',
'wm/image_cursors.cc',
'wm/image_cursors.h',
+ 'wm/lock_state_controller.cc',
+ 'wm/lock_state_controller.h',
+ 'wm/lock_state_controller_impl2.cc',
+ 'wm/lock_state_controller_impl2.h',
+ 'wm/lock_state_observer.h',
'wm/maximize_bubble_controller.cc',
'wm/maximize_bubble_controller.h',
'wm/overlay_event_filter.cc',
@@ -412,13 +417,8 @@
'wm/screen_dimmer.h',
'wm/session_state_animator.cc',
'wm/session_state_animator.h',
- 'wm/session_state_controller.cc',
- 'wm/session_state_controller.h',
'wm/session_state_controller_impl.cc',
'wm/session_state_controller_impl.h',
- 'wm/session_state_controller_impl2.cc',
- 'wm/session_state_controller_impl2.h',
- 'wm/session_state_observer.h',
'wm/stacking_controller.cc',
'wm/stacking_controller.h',
'wm/status_area_layout_manager.cc',
@@ -688,12 +688,12 @@
'wm/custom_frame_view_ash_unittest.cc',
'wm/drag_window_resizer_unittest.cc',
'wm/frame_painter_unittest.cc',
+ 'wm/lock_state_controller_impl2_unittest.cc',
'wm/panels/panel_layout_manager_unittest.cc',
'wm/panels/panel_window_resizer_unittest.cc',
'wm/partial_screenshot_view_unittest.cc',
'wm/power_button_controller_unittest.cc',
'wm/screen_dimmer_unittest.cc',
- 'wm/session_state_controller_impl2_unittest.cc',
'wm/stacking_controller_unittest.cc',
'wm/system_gesture_event_filter_unittest.cc',
'wm/system_modal_container_layout_manager_unittest.cc',
diff --git a/ash/shell.cc b/ash/shell.cc
index 0f12d3f..365df5b 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -50,15 +50,15 @@
#include "ash/wm/custom_frame_view_ash.h"
#include "ash/wm/event_client_impl.h"
#include "ash/wm/event_rewriter_event_filter.h"
+#include "ash/wm/lock_state_controller.h"
+#include "ash/wm/lock_state_controller_impl2.h"
#include "ash/wm/overlay_event_filter.h"
#include "ash/wm/power_button_controller.h"
#include "ash/wm/property_util.h"
#include "ash/wm/resize_shadow_controller.h"
#include "ash/wm/root_window_layout_manager.h"
#include "ash/wm/screen_dimmer.h"
-#include "ash/wm/session_state_controller.h"
#include "ash/wm/session_state_controller_impl.h"
-#include "ash/wm/session_state_controller_impl2.h"
#include "ash/wm/system_gesture_event_filter.h"
#include "ash/wm/system_modal_container_event_filter.h"
#include "ash/wm/system_modal_container_layout_manager.h"
@@ -298,7 +298,7 @@
video_detector_.reset();
power_button_controller_.reset();
- session_state_controller_.reset();
+ lock_state_controller_.reset();
mirror_window_controller_.reset();
@@ -530,12 +530,12 @@
delegate_->IsFirstRunAfterBoot());
if (command_line->HasSwitch(ash::switches::kAshDisableNewLockAnimations))
- session_state_controller_.reset(new SessionStateControllerImpl);
+ lock_state_controller_.reset(new SessionStateControllerImpl);
else
- session_state_controller_.reset(new SessionStateControllerImpl2);
+ lock_state_controller_.reset(new LockStateControllerImpl2);
power_button_controller_.reset(new PowerButtonController(
- session_state_controller_.get()));
- AddShellObserver(session_state_controller_.get());
+ lock_state_controller_.get()));
+ AddShellObserver(lock_state_controller_.get());
mouse_cursor_filter_.reset(new internal::MouseCursorEventFilter());
AddPreTargetHandler(mouse_cursor_filter_.get());
diff --git a/ash/shell.h b/ash/shell.h
index b663f78..a420293 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -84,7 +84,7 @@
class PowerButtonController;
class RootWindowHostFactory;
class ScreenAsh;
-class SessionStateController;
+class LockStateController;
class SessionStateDelegate;
class ShellDelegate;
class ShellObserver;
@@ -309,8 +309,8 @@
PowerButtonController* power_button_controller() {
return power_button_controller_.get();
}
- SessionStateController* session_state_controller() {
- return session_state_controller_.get();
+ LockStateController* lock_state_controller() {
+ return lock_state_controller_.get();
}
UserActivityDetector* user_activity_detector() {
return user_activity_detector_.get();
@@ -537,7 +537,7 @@
scoped_ptr<views::corewm::TooltipController> tooltip_controller_;
scoped_ptr<DesktopBackgroundController> desktop_background_controller_;
scoped_ptr<PowerButtonController> power_button_controller_;
- scoped_ptr<SessionStateController> session_state_controller_;
+ scoped_ptr<LockStateController> lock_state_controller_;
scoped_ptr<UserActivityDetector> user_activity_detector_;
scoped_ptr<VideoDetector> video_detector_;
scoped_ptr<WindowCycleController> window_cycle_controller_;
diff --git a/ash/wm/lock_state_controller.cc b/ash/wm/lock_state_controller.cc
new file mode 100644
index 0000000..f0be1057
--- /dev/null
+++ b/ash/wm/lock_state_controller.cc
@@ -0,0 +1,52 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/wm/lock_state_controller.h"
+
+#include "ash/ash_switches.h"
+#include "ash/shell.h"
+#include "ash/shell_delegate.h"
+#include "ash/shell_window_ids.h"
+#include "ash/wm/session_state_animator.h"
+#include "base/command_line.h"
+#include "ui/aura/root_window.h"
+#include "ui/views/corewm/compound_event_filter.h"
+
+#if defined(OS_CHROMEOS)
+#include "base/chromeos/chromeos_version.h"
+#endif
+
+namespace ash {
+
+const int LockStateController::kLockTimeoutMs = 400;
+const int LockStateController::kShutdownTimeoutMs = 400;
+const int LockStateController::kLockFailTimeoutMs = 4000;
+const int LockStateController::kLockToShutdownTimeoutMs = 150;
+const int LockStateController::kShutdownRequestDelayMs = 50;
+
+LockStateController::LockStateController()
+ : animator_(new internal::SessionStateAnimator()) {
+}
+
+LockStateController::~LockStateController() {
+}
+
+void LockStateController::SetDelegate(LockStateControllerDelegate* delegate) {
+ delegate_.reset(delegate);
+}
+
+void LockStateController::AddObserver(LockStateObserver* observer) {
+ observers_.AddObserver(observer);
+}
+
+void LockStateController::RemoveObserver(LockStateObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+bool LockStateController::HasObserver(LockStateObserver* observer) {
+ return observers_.HasObserver(observer);
+}
+
+
+} // namespace ash
diff --git a/ash/wm/session_state_controller.h b/ash/wm/lock_state_controller.h
similarity index 75%
rename from ash/wm/session_state_controller.h
rename to ash/wm/lock_state_controller.h
index c457c70c..a651b5f 100644
--- a/ash/wm/session_state_controller.h
+++ b/ash/wm/lock_state_controller.h
@@ -1,14 +1,14 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_WM_SESSION_STATE_CONTROLLER_H_
-#define ASH_WM_SESSION_STATE_CONTROLLER_H_
+#ifndef ASH_WM_LOCK_STATE_CONTROLLER_H_
+#define ASH_WM_LOCK_STATE_CONTROLLER_H_
#include "ash/ash_export.h"
#include "ash/shell_observer.h"
+#include "ash/wm/lock_state_observer.h"
#include "ash/wm/session_state_animator.h"
-#include "ash/wm/session_state_observer.h"
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
@@ -28,27 +28,27 @@
namespace ash {
namespace test {
+class LockStateControllerImpl2Test;
class PowerButtonControllerTest;
-class SessionStateControllerImpl2Test;
}
-// Performs system-related functions on behalf of SessionStateController.
-class ASH_EXPORT SessionStateControllerDelegate {
+// Performs system-related functions on behalf of LockStateController.
+class ASH_EXPORT LockStateControllerDelegate {
public:
- SessionStateControllerDelegate() {}
- virtual ~SessionStateControllerDelegate() {}
+ LockStateControllerDelegate() {}
+ virtual ~LockStateControllerDelegate() {}
virtual void RequestLockScreen() = 0;
virtual void RequestShutdown() = 0;
private:
- DISALLOW_COPY_AND_ASSIGN(SessionStateControllerDelegate);
+ DISALLOW_COPY_AND_ASSIGN(LockStateControllerDelegate);
};
// Displays onscreen animations and locks or suspends the system in response to
// the power button being pressed or released.
-class ASH_EXPORT SessionStateController : public aura::RootWindowObserver,
- public ShellObserver {
+class ASH_EXPORT LockStateController : public aura::RootWindowObserver,
+ public ShellObserver {
public:
// Amount of time that the power button needs to be held before we lock the
// screen.
@@ -71,10 +71,10 @@
// the animation time to finish.
static const int kShutdownRequestDelayMs;
- SessionStateController();
- virtual ~SessionStateController();
+ LockStateController();
+ virtual ~LockStateController();
- void SetDelegate(SessionStateControllerDelegate* delegate);
+ void SetDelegate(LockStateControllerDelegate* delegate);
// Starts locking (with slow animation) that can be cancelled.
// After locking and |kLockToShutdownTimeoutMs| StartShutdownAnimation()
@@ -123,24 +123,24 @@
// Callback is guaranteed to be called once and then discarded.
virtual void SetLockScreenDisplayedCallback(base::Closure& callback) = 0;
- virtual void AddObserver(SessionStateObserver* observer);
- virtual void RemoveObserver(SessionStateObserver* observer);
- virtual bool HasObserver(SessionStateObserver* observer);
+ virtual void AddObserver(LockStateObserver* observer);
+ virtual void RemoveObserver(LockStateObserver* observer);
+ virtual bool HasObserver(LockStateObserver* observer);
protected:
friend class test::PowerButtonControllerTest;
- friend class test::SessionStateControllerImpl2Test;
+ friend class test::LockStateControllerImpl2Test;
scoped_ptr<internal::SessionStateAnimator> animator_;
- scoped_ptr<SessionStateControllerDelegate> delegate_;
+ scoped_ptr<LockStateControllerDelegate> delegate_;
- ObserverList<SessionStateObserver> observers_;
+ ObserverList<LockStateObserver> observers_;
private:
- DISALLOW_COPY_AND_ASSIGN(SessionStateController);
+ DISALLOW_COPY_AND_ASSIGN(LockStateController);
};
} // namespace ash
-#endif // ASH_WM_SESSION_STATE_CONTROLLER_H_
+#endif // ASH_WM_LOCK_STATE_CONTROLLER_H_
diff --git a/ash/wm/session_state_controller_impl2.cc b/ash/wm/lock_state_controller_impl2.cc
similarity index 80%
rename from ash/wm/session_state_controller_impl2.cc
rename to ash/wm/lock_state_controller_impl2.cc
index f21a8d7..fe7152fb 100644
--- a/ash/wm/session_state_controller_impl2.cc
+++ b/ash/wm/lock_state_controller_impl2.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/wm/session_state_controller_impl2.h"
+#include "ash/wm/lock_state_controller_impl2.h"
#include "ash/ash_switches.h"
#include "ash/cancel_mode.h"
@@ -135,15 +135,15 @@
} // namespace
-SessionStateControllerImpl2::TestApi::TestApi(
- SessionStateControllerImpl2* controller)
+LockStateControllerImpl2::TestApi::TestApi(
+ LockStateControllerImpl2* controller)
: controller_(controller) {
}
-SessionStateControllerImpl2::TestApi::~TestApi() {
+LockStateControllerImpl2::TestApi::~TestApi() {
}
-SessionStateControllerImpl2::SessionStateControllerImpl2()
+LockStateControllerImpl2::LockStateControllerImpl2()
: login_status_(user::LOGGED_IN_NONE),
system_is_locked_(false),
shutting_down_(false),
@@ -153,18 +153,18 @@
Shell::GetPrimaryRootWindow()->AddRootWindowObserver(this);
}
-SessionStateControllerImpl2::~SessionStateControllerImpl2() {
+LockStateControllerImpl2::~LockStateControllerImpl2() {
Shell::GetPrimaryRootWindow()->RemoveRootWindowObserver(this);
}
-void SessionStateControllerImpl2::OnLoginStateChanged(
+void LockStateControllerImpl2::OnLoginStateChanged(
user::LoginStatus status) {
if (status != user::LOGGED_IN_LOCKED)
login_status_ = status;
system_is_locked_ = (status == user::LOGGED_IN_LOCKED);
}
-void SessionStateControllerImpl2::OnAppTerminating() {
+void LockStateControllerImpl2::OnAppTerminating() {
// If we hear that Chrome is exiting but didn't request it ourselves, all we
// can really hope for is that we'll have time to clear the screen.
// This is also the case when the user signs off.
@@ -180,7 +180,7 @@
}
}
-void SessionStateControllerImpl2::OnLockStateChanged(bool locked) {
+void LockStateControllerImpl2::OnLockStateChanged(bool locked) {
if (shutting_down_ || (system_is_locked_ == locked))
return;
@@ -194,12 +194,12 @@
}
}
-void SessionStateControllerImpl2::SetLockScreenDisplayedCallback(
+void LockStateControllerImpl2::SetLockScreenDisplayedCallback(
base::Closure& callback) {
lock_screen_displayed_callback_ = callback;
}
-void SessionStateControllerImpl2::OnStartingLock() {
+void LockStateControllerImpl2::OnStartingLock() {
if (shutting_down_ || system_is_locked_)
return;
if (animating_lock_)
@@ -207,13 +207,14 @@
StartImmediatePreLockAnimation(false /* request_lock_on_completion */);
}
-void SessionStateControllerImpl2::StartLockAnimationAndLockImmediately() {
+void LockStateControllerImpl2::StartLockAnimationAndLockImmediately() {
if (animating_lock_)
return;
StartImmediatePreLockAnimation(true /* request_lock_on_completion */);
}
-void SessionStateControllerImpl2::StartLockAnimation(bool shutdown_after_lock) {
+void LockStateControllerImpl2::StartLockAnimation(
+ bool shutdown_after_lock) {
if (animating_lock_)
return;
shutdown_after_lock_ = shutdown_after_lock;
@@ -222,19 +223,19 @@
StartCancellablePreLockAnimation();
}
-bool SessionStateControllerImpl2::LockRequested() {
+bool LockStateControllerImpl2::LockRequested() {
return lock_fail_timer_.IsRunning();
}
-bool SessionStateControllerImpl2::ShutdownRequested() {
+bool LockStateControllerImpl2::ShutdownRequested() {
return shutting_down_;
}
-bool SessionStateControllerImpl2::CanCancelLockAnimation() {
+bool LockStateControllerImpl2::CanCancelLockAnimation() {
return can_cancel_lock_animation_;
}
-void SessionStateControllerImpl2::CancelLockAnimation() {
+void LockStateControllerImpl2::CancelLockAnimation() {
if (!CanCancelLockAnimation())
return;
shutdown_after_lock_ = false;
@@ -242,17 +243,17 @@
CancelPreLockAnimation();
}
-bool SessionStateControllerImpl2::CanCancelShutdownAnimation() {
+bool LockStateControllerImpl2::CanCancelShutdownAnimation() {
return pre_shutdown_timer_.IsRunning() ||
shutdown_after_lock_ ||
lock_to_shutdown_timer_.IsRunning();
}
-void SessionStateControllerImpl2::StartShutdownAnimation() {
+void LockStateControllerImpl2::StartShutdownAnimation() {
StartCancellableShutdownAnimation();
}
-void SessionStateControllerImpl2::CancelShutdownAnimation() {
+void LockStateControllerImpl2::CancelShutdownAnimation() {
if (!CanCancelShutdownAnimation())
return;
if (lock_to_shutdown_timer_.IsRunning()) {
@@ -270,12 +271,12 @@
pre_shutdown_timer_.Stop();
}
-void SessionStateControllerImpl2::RequestShutdown() {
+void LockStateControllerImpl2::RequestShutdown() {
if (!shutting_down_)
RequestShutdownImpl();
}
-void SessionStateControllerImpl2::RequestShutdownImpl() {
+void LockStateControllerImpl2::RequestShutdownImpl() {
DCHECK(!shutting_down_);
shutting_down_ = true;
@@ -286,32 +287,32 @@
StartShutdownAnimationImpl();
}
-void SessionStateControllerImpl2::OnRootWindowHostCloseRequested(
+void LockStateControllerImpl2::OnRootWindowHostCloseRequested(
const aura::RootWindow*) {
Shell::GetInstance()->delegate()->Exit();
}
-void SessionStateControllerImpl2::OnLockFailTimeout() {
+void LockStateControllerImpl2::OnLockFailTimeout() {
DCHECK(!system_is_locked_);
// Undo lock animation.
StartUnlockAnimationAfterUIDestroyed();
}
-void SessionStateControllerImpl2::StartLockToShutdownTimer() {
+void LockStateControllerImpl2::StartLockToShutdownTimer() {
shutdown_after_lock_ = false;
lock_to_shutdown_timer_.Stop();
lock_to_shutdown_timer_.Start(
FROM_HERE,
base::TimeDelta::FromMilliseconds(kLockToShutdownTimeoutMs),
- this, &SessionStateControllerImpl2::OnLockToShutdownTimeout);
+ this, &LockStateControllerImpl2::OnLockToShutdownTimeout);
}
-void SessionStateControllerImpl2::OnLockToShutdownTimeout() {
+void LockStateControllerImpl2::OnLockToShutdownTimeout() {
DCHECK(system_is_locked_);
StartCancellableShutdownAnimation();
}
-void SessionStateControllerImpl2::StartCancellableShutdownAnimation() {
+void LockStateControllerImpl2::StartCancellableShutdownAnimation() {
Shell* shell = ash::Shell::GetInstance();
// Hide cursor, but let it reappear if the mouse moves.
shell->env_filter()->set_cursor_hidden_by_filter(true);
@@ -323,24 +324,24 @@
StartPreShutdownAnimationTimer();
}
-void SessionStateControllerImpl2::StartShutdownAnimationImpl() {
+void LockStateControllerImpl2::StartShutdownAnimationImpl() {
animator_->StartGlobalAnimation(
internal::SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS,
internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
StartRealShutdownTimer(true);
}
-void SessionStateControllerImpl2::StartPreShutdownAnimationTimer() {
+void LockStateControllerImpl2::StartPreShutdownAnimationTimer() {
pre_shutdown_timer_.Stop();
pre_shutdown_timer_.Start(
FROM_HERE,
animator_->
GetDuration(internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN),
this,
- &SessionStateControllerImpl2::OnPreShutdownAnimationTimeout);
+ &LockStateControllerImpl2::OnPreShutdownAnimationTimeout);
}
-void SessionStateControllerImpl2::OnPreShutdownAnimationTimeout() {
+void LockStateControllerImpl2::OnPreShutdownAnimationTimeout() {
shutting_down_ = true;
Shell* shell = ash::Shell::GetInstance();
@@ -350,7 +351,7 @@
StartRealShutdownTimer(false);
}
-void SessionStateControllerImpl2::StartRealShutdownTimer(
+void LockStateControllerImpl2::StartRealShutdownTimer(
bool with_animation_time) {
base::TimeDelta duration =
base::TimeDelta::FromMilliseconds(kShutdownRequestDelayMs);
@@ -362,10 +363,10 @@
FROM_HERE,
duration,
this,
- &SessionStateControllerImpl2::OnRealShutdownTimeout);
+ &LockStateControllerImpl2::OnRealShutdownTimeout);
}
-void SessionStateControllerImpl2::OnRealShutdownTimeout() {
+void LockStateControllerImpl2::OnRealShutdownTimeout() {
DCHECK(shutting_down_);
#if defined(OS_CHROMEOS)
if (!base::chromeos::IsRunningOnChromeOS()) {
@@ -381,17 +382,18 @@
delegate_->RequestShutdown();
}
-void SessionStateControllerImpl2::OnLockScreenHide(
+void LockStateControllerImpl2::OnLockScreenHide(
base::Callback<void(void)>& callback) {
StartUnlockAnimationBeforeUIDestroyed(callback);
}
-void SessionStateControllerImpl2::LockAnimationCancelled() {
+void LockStateControllerImpl2::LockAnimationCancelled() {
can_cancel_lock_animation_ = false;
RestoreUnlockedProperties();
}
-void SessionStateControllerImpl2::PreLockAnimationFinished(bool request_lock) {
+void LockStateControllerImpl2::PreLockAnimationFinished(
+ bool request_lock) {
can_cancel_lock_animation_ = false;
if (request_lock) {
@@ -406,15 +408,14 @@
FROM_HERE,
base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs),
this,
- &SessionStateControllerImpl2::OnLockFailTimeout);
+ &LockStateControllerImpl2::OnLockFailTimeout);
}
-void SessionStateControllerImpl2::PostLockAnimationFinished() {
+void LockStateControllerImpl2::PostLockAnimationFinished() {
animating_lock_ = false;
- FOR_EACH_OBSERVER(SessionStateObserver, observers_,
- OnSessionStateEvent(
- SessionStateObserver::EVENT_LOCK_ANIMATION_FINISHED));
+ FOR_EACH_OBSERVER(LockStateObserver, observers_,
+ OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED));
if (!lock_screen_displayed_callback_.is_null()) {
lock_screen_displayed_callback_.Run();
lock_screen_displayed_callback_.Reset();
@@ -425,18 +426,19 @@
}
}
-void SessionStateControllerImpl2::UnlockAnimationAfterUIDestroyedFinished() {
+void LockStateControllerImpl2::
+UnlockAnimationAfterUIDestroyedFinished() {
RestoreUnlockedProperties();
}
-void SessionStateControllerImpl2::StartImmediatePreLockAnimation(
+void LockStateControllerImpl2::StartImmediatePreLockAnimation(
bool request_lock_on_completion) {
animating_lock_ = true;
StoreUnlockedProperties();
base::Closure next_animation_starter =
- base::Bind(&SessionStateControllerImpl2::PreLockAnimationFinished,
+ base::Bind(&LockStateControllerImpl2::PreLockAnimationFinished,
base::Unretained(this), request_lock_on_completion);
AnimationFinishedObserver* observer =
new AnimationFinishedObserver(next_animation_starter);
@@ -465,16 +467,16 @@
observer->Unpause();
DispatchCancelMode();
- FOR_EACH_OBSERVER(SessionStateObserver, observers_,
- OnSessionStateEvent(SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED));
+ FOR_EACH_OBSERVER(LockStateObserver, observers_,
+ OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_STARTED));
}
-void SessionStateControllerImpl2::StartCancellablePreLockAnimation() {
+void LockStateControllerImpl2::StartCancellablePreLockAnimation() {
animating_lock_ = true;
StoreUnlockedProperties();
base::Closure next_animation_starter =
- base::Bind(&SessionStateControllerImpl2::PreLockAnimationFinished,
+ base::Bind(&LockStateControllerImpl2::PreLockAnimationFinished,
base::Unretained(this), true /* request_lock */);
AnimationFinishedObserver* observer =
new AnimationFinishedObserver(next_animation_starter);
@@ -501,15 +503,14 @@
observer);
DispatchCancelMode();
- FOR_EACH_OBSERVER(SessionStateObserver, observers_,
- OnSessionStateEvent(
- SessionStateObserver::EVENT_PRELOCK_ANIMATION_STARTED));
+ FOR_EACH_OBSERVER(LockStateObserver, observers_,
+ OnLockStateEvent(LockStateObserver::EVENT_PRELOCK_ANIMATION_STARTED));
observer->Unpause();
}
-void SessionStateControllerImpl2::CancelPreLockAnimation() {
+void LockStateControllerImpl2::CancelPreLockAnimation() {
base::Closure next_animation_starter =
- base::Bind(&SessionStateControllerImpl2::LockAnimationCancelled,
+ base::Bind(&LockStateControllerImpl2::LockAnimationCancelled,
base::Unretained(this));
AnimationFinishedObserver* observer =
new AnimationFinishedObserver(next_animation_starter);
@@ -533,9 +534,9 @@
observer->Unpause();
}
-void SessionStateControllerImpl2::StartPostLockAnimation() {
+void LockStateControllerImpl2::StartPostLockAnimation() {
base::Closure next_animation_starter =
- base::Bind(&SessionStateControllerImpl2::PostLockAnimationFinished,
+ base::Bind(&LockStateControllerImpl2::PostLockAnimationFinished,
base::Unretained(this));
AnimationFinishedObserver* observer =
@@ -550,7 +551,7 @@
observer->Unpause();
}
-void SessionStateControllerImpl2::StartUnlockAnimationBeforeUIDestroyed(
+void LockStateControllerImpl2::StartUnlockAnimationBeforeUIDestroyed(
base::Closure& callback) {
animator_->StartAnimationWithCallback(
internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
@@ -559,11 +560,12 @@
callback);
}
-void SessionStateControllerImpl2::StartUnlockAnimationAfterUIDestroyed() {
+void LockStateControllerImpl2::StartUnlockAnimationAfterUIDestroyed() {
base::Closure next_animation_starter =
base::Bind(
- &SessionStateControllerImpl2::UnlockAnimationAfterUIDestroyedFinished,
- base::Unretained(this));
+ &LockStateControllerImpl2::
+ UnlockAnimationAfterUIDestroyedFinished,
+ base::Unretained(this));
AnimationFinishedObserver* observer =
new AnimationFinishedObserver(next_animation_starter);
@@ -586,7 +588,7 @@
observer->Unpause();
}
-void SessionStateControllerImpl2::StoreUnlockedProperties() {
+void LockStateControllerImpl2::StoreUnlockedProperties() {
if (!unlocked_properties_) {
unlocked_properties_.reset(new UnlockedStateProperties());
unlocked_properties_->background_is_hidden = IsBackgroundHidden();
@@ -601,7 +603,7 @@
}
}
-void SessionStateControllerImpl2::RestoreUnlockedProperties() {
+void LockStateControllerImpl2::RestoreUnlockedProperties() {
if (!unlocked_properties_)
return;
if (unlocked_properties_->background_is_hidden) {
@@ -615,7 +617,7 @@
unlocked_properties_.reset();
}
-void SessionStateControllerImpl2::AnimateBackgroundAppearanceIfNecessary(
+void LockStateControllerImpl2::AnimateBackgroundAppearanceIfNecessary(
internal::SessionStateAnimator::AnimationSpeed speed,
ui::LayerAnimationObserver* observer) {
if (unlocked_properties_.get() &&
@@ -628,7 +630,7 @@
}
}
-void SessionStateControllerImpl2::AnimateBackgroundHidingIfNecessary(
+void LockStateControllerImpl2::AnimateBackgroundHidingIfNecessary(
internal::SessionStateAnimator::AnimationSpeed speed,
ui::LayerAnimationObserver* observer) {
if (unlocked_properties_.get() &&
diff --git a/ash/wm/session_state_controller_impl2.h b/ash/wm/lock_state_controller_impl2.h
similarity index 89%
rename from ash/wm/session_state_controller_impl2.h
rename to ash/wm/lock_state_controller_impl2.h
index e40468f..2ea16168 100644
--- a/ash/wm/session_state_controller_impl2.h
+++ b/ash/wm/lock_state_controller_impl2.h
@@ -1,14 +1,14 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_WM_SESSION_STATE_CONTROLLER_IMPL2_H_
-#define ASH_WM_SESSION_STATE_CONTROLLER_IMPL2_H_
+#ifndef ASH_WM_LOCK_STATE_CONTROLLER_IMPL2_H_
+#define ASH_WM_LOCK_STATE_CONTROLLER_IMPL2_H_
#include "ash/ash_export.h"
#include "ash/shell_observer.h"
+#include "ash/wm/lock_state_controller.h"
#include "ash/wm/session_state_animator.h"
-#include "ash/wm/session_state_controller.h"
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/time.h"
@@ -27,7 +27,7 @@
namespace ash {
namespace test {
-class SessionStateControllerImpl2Test;
+class LockStateControllerImpl2Test;
}
// Displays onscreen animations and locks or suspends the system in response to
@@ -54,13 +54,13 @@
// OnLockStateChanged is called. It leads to
// StartUnlockAnimationAfterUIDestroyed.
-class ASH_EXPORT SessionStateControllerImpl2 : public SessionStateController {
+class ASH_EXPORT LockStateControllerImpl2 : public LockStateController {
public:
// Helper class used by tests to access internal state.
class ASH_EXPORT TestApi {
public:
- explicit TestApi(SessionStateControllerImpl2* controller);
+ explicit TestApi(LockStateControllerImpl2* controller);
virtual ~TestApi();
@@ -100,13 +100,13 @@
controller_->real_shutdown_timer_.Stop();
}
private:
- SessionStateControllerImpl2* controller_; // not owned
+ LockStateControllerImpl2* controller_; // not owned
DISALLOW_COPY_AND_ASSIGN(TestApi);
};
- SessionStateControllerImpl2();
- virtual ~SessionStateControllerImpl2();
+ LockStateControllerImpl2();
+ virtual ~LockStateControllerImpl2();
// RootWindowObserver override:
virtual void OnRootWindowHostCloseRequested(
@@ -117,7 +117,7 @@
virtual void OnAppTerminating() OVERRIDE;
virtual void OnLockStateChanged(bool locked) OVERRIDE;
- // SessionStateController overrides:
+ // LockStateController overrides:
virtual void StartLockAnimation(bool shutdown_after_lock) OVERRIDE;
virtual void StartShutdownAnimation() OVERRIDE;
@@ -139,7 +139,7 @@
virtual void SetLockScreenDisplayedCallback(base::Closure& callback) OVERRIDE;
protected:
- friend class test::SessionStateControllerImpl2Test;
+ friend class test::LockStateControllerImpl2Test;
private:
struct UnlockedStateProperties {
@@ -237,27 +237,27 @@
// Started when we request that the screen be locked. When it fires, we
// assume that our request got dropped.
- base::OneShotTimer<SessionStateControllerImpl2> lock_fail_timer_;
+ base::OneShotTimer<LockStateControllerImpl2> lock_fail_timer_;
// Started when the screen is locked while the power button is held. Adds a
// delay between the appearance of the lock screen and the beginning of the
// pre-shutdown animation.
- base::OneShotTimer<SessionStateControllerImpl2> lock_to_shutdown_timer_;
+ base::OneShotTimer<LockStateControllerImpl2> lock_to_shutdown_timer_;
// Started when we begin displaying the pre-shutdown animation. When it
// fires, we start the shutdown animation and get ready to request shutdown.
- base::OneShotTimer<SessionStateControllerImpl2> pre_shutdown_timer_;
+ base::OneShotTimer<LockStateControllerImpl2> pre_shutdown_timer_;
// Started when we display the shutdown animation. When it fires, we actually
// request shutdown. Gives the animation time to complete before Chrome, X,
// etc. are shut down.
- base::OneShotTimer<SessionStateControllerImpl2> real_shutdown_timer_;
+ base::OneShotTimer<LockStateControllerImpl2> real_shutdown_timer_;
base::Closure lock_screen_displayed_callback_;
- DISALLOW_COPY_AND_ASSIGN(SessionStateControllerImpl2);
+ DISALLOW_COPY_AND_ASSIGN(LockStateControllerImpl2);
};
} // namespace ash
-#endif // ASH_WM_SESSION_STATE_CONTROLLER_IMPL2_H_
+#endif // ASH_WM_LOCK_STATE_CONTROLLER_IMPL2_H_
diff --git a/ash/wm/session_state_controller_impl2_unittest.cc b/ash/wm/lock_state_controller_impl2_unittest.cc
similarity index 90%
rename from ash/wm/session_state_controller_impl2_unittest.cc
rename to ash/wm/lock_state_controller_impl2_unittest.cc
index 9ff3987..8177422 100644
--- a/ash/wm/session_state_controller_impl2_unittest.cc
+++ b/ash/wm/lock_state_controller_impl2_unittest.cc
@@ -1,18 +1,17 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/wm/session_state_controller_impl2.h"
-
#include "ash/ash_switches.h"
#include "ash/session_state_delegate.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/test_shell_delegate.h"
+#include "ash/wm/lock_state_controller.h"
+#include "ash/wm/lock_state_controller_impl2.h"
#include "ash/wm/power_button_controller.h"
#include "ash/wm/session_state_animator.h"
-#include "ash/wm/session_state_controller.h"
#include "base/command_line.h"
#include "base/memory/scoped_ptr.h"
#include "base/time.h"
@@ -76,17 +75,16 @@
// Fake implementation of PowerButtonControllerDelegate that just logs requests
// to lock the screen and shut down the device.
-class TestSessionStateControllerDelegate :
- public SessionStateControllerDelegate {
+class TestLockStateControllerDelegate : public LockStateControllerDelegate {
public:
- TestSessionStateControllerDelegate()
+ TestLockStateControllerDelegate()
: num_lock_requests_(0),
num_shutdown_requests_(0) {}
int num_lock_requests() const { return num_lock_requests_; }
int num_shutdown_requests() const { return num_shutdown_requests_; }
- // SessionStateControllerDelegate implementation.
+ // LockStateControllerDelegate implementation.
virtual void RequestLockScreen() OVERRIDE {
num_lock_requests_++;
}
@@ -98,13 +96,13 @@
int num_lock_requests_;
int num_shutdown_requests_;
- DISALLOW_COPY_AND_ASSIGN(TestSessionStateControllerDelegate);
+ DISALLOW_COPY_AND_ASSIGN(TestLockStateControllerDelegate);
};
-class SessionStateControllerImpl2Test : public AshTestBase {
+class LockStateControllerImpl2Test : public AshTestBase {
public:
- SessionStateControllerImpl2Test() : controller_(NULL), delegate_(NULL) {}
- virtual ~SessionStateControllerImpl2Test() {}
+ LockStateControllerImpl2Test() : controller_(NULL), delegate_(NULL) {}
+ virtual ~LockStateControllerImpl2Test() {}
virtual void SetUp() OVERRIDE {
CHECK(!CommandLine::ForCurrentProcess()->HasSwitch(
@@ -125,19 +123,19 @@
// TODO(antrim): once there is a way to mock time and run animations, make
// sure that animations are finished even in simple tests.
- delegate_ = new TestSessionStateControllerDelegate;
+ delegate_ = new TestLockStateControllerDelegate;
controller_ = Shell::GetInstance()->power_button_controller();
- state_controller_ = static_cast<SessionStateControllerImpl2*>(
- Shell::GetInstance()->session_state_controller());
- state_controller_->SetDelegate(delegate_); // transfers ownership
+ lock_state_controller_ = static_cast<LockStateControllerImpl2*>(
+ Shell::GetInstance()->lock_state_controller());
+ lock_state_controller_->SetDelegate(delegate_); // transfers ownership
test_api_.reset(
- new SessionStateControllerImpl2::TestApi(state_controller_));
+ new LockStateControllerImpl2::TestApi(lock_state_controller_));
animator_api_.reset(
- new SessionStateAnimator::TestApi(state_controller_->
+ new SessionStateAnimator::TestApi(lock_state_controller_->
animator_.get()));
shell_delegate_ = reinterpret_cast<TestShellDelegate*>(
ash::Shell::GetInstance()->delegate());
- state_delegate_ = Shell::GetInstance()->session_state_delegate();
+ session_state_delegate_ = Shell::GetInstance()->session_state_delegate();
}
virtual void TearDown() {
@@ -311,7 +309,7 @@
void ExpectUnlockedState() {
//TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
- EXPECT_FALSE(state_delegate_->IsScreenLocked());
+ EXPECT_FALSE(session_state_delegate_->IsScreenLocked());
aura::Window::Windows containers;
@@ -332,7 +330,7 @@
void ExpectLockedState() {
//TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
- EXPECT_TRUE(state_delegate_->IsScreenLocked());
+ EXPECT_TRUE(session_state_delegate_->IsScreenLocked());
aura::Window::Windows containers;
@@ -370,46 +368,46 @@
}
void SystemLocks() {
- state_controller_->OnLockStateChanged(true);
- state_delegate_->LockScreen();
+ lock_state_controller_->OnLockStateChanged(true);
+ session_state_delegate_->LockScreen();
//TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta());
}
void SuccessfulAuthentication(bool* call_flag) {
base::Closure closure = base::Bind(&CheckCalledCallback, call_flag);
- state_controller_->OnLockScreenHide(closure);
+ lock_state_controller_->OnLockScreenHide(closure);
//TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta());
}
void SystemUnlocks() {
- state_controller_->OnLockStateChanged(false);
- state_delegate_->UnlockScreen();
+ lock_state_controller_->OnLockStateChanged(false);
+ session_state_delegate_->UnlockScreen();
//TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta());
}
void Initialize(bool legacy_button, user::LoginStatus status) {
controller_->set_has_legacy_power_button_for_test(legacy_button);
- state_controller_->OnLoginStateChanged(status);
+ lock_state_controller_->OnLoginStateChanged(status);
SetUserLoggedIn(status != user::LOGGED_IN_NONE);
if (status == user::LOGGED_IN_GUEST)
SetCanLockScreen(false);
- state_controller_->OnLockStateChanged(false);
+ lock_state_controller_->OnLockStateChanged(false);
}
PowerButtonController* controller_; // not owned
- SessionStateControllerImpl2* state_controller_; // not owned
- TestSessionStateControllerDelegate* delegate_; // not owned
+ LockStateControllerImpl2* lock_state_controller_; // not owned
+ TestLockStateControllerDelegate* delegate_; // not owned
TestShellDelegate* shell_delegate_; // not owned
- SessionStateDelegate* state_delegate_; // not owned
+ SessionStateDelegate* session_state_delegate_; // not owned
scoped_ptr<ui::ScopedAnimationDurationScaleMode> animation_duration_mode_;
- scoped_ptr<SessionStateControllerImpl2::TestApi> test_api_;
+ scoped_ptr<LockStateControllerImpl2::TestApi> test_api_;
scoped_ptr<SessionStateAnimator::TestApi> animator_api_;
// TODO(antrim) : restore
// scoped_ptr<ui::test::AnimationContainerTestHelper> animator_helper_;
private:
- DISALLOW_COPY_AND_ASSIGN(SessionStateControllerImpl2Test);
+ DISALLOW_COPY_AND_ASSIGN(LockStateControllerImpl2Test);
};
// Test the lock-to-shutdown flow for non-Chrome-OS hardware that doesn't
@@ -417,7 +415,7 @@
// time the button is pressed and shut down when it's pressed from the locked
// state.
// TODO(antrim): Reenable this: http://crbug.com/167048
-TEST_F(SessionStateControllerImpl2Test, DISABLED_LegacyLockAndShutDown) {
+TEST_F(LockStateControllerImpl2Test, DISABLED_LegacyLockAndShutDown) {
Initialize(true, user::LOGGED_IN_USER);
ExpectUnlockedState();
@@ -436,7 +434,7 @@
EXPECT_EQ(1, delegate_->num_lock_requests());
// Notify that we locked successfully.
- state_controller_->OnStartingLock();
+ lock_state_controller_->OnStartingLock();
// We had that animation already.
//TODO (antrim) : restore
// EXPECT_FALSE(animator_helper_->IsAnimating());
@@ -470,7 +468,7 @@
// Test that we start shutting down immediately if the power button is pressed
// while we're not logged in on an unofficial system.
-TEST_F(SessionStateControllerImpl2Test, LegacyNotLoggedIn) {
+TEST_F(LockStateControllerImpl2Test, LegacyNotLoggedIn) {
Initialize(true, user::LOGGED_IN_NONE);
PressPowerButton();
@@ -481,7 +479,7 @@
// Test that we start shutting down immediately if the power button is pressed
// while we're logged in as a guest on an unofficial system.
-TEST_F(SessionStateControllerImpl2Test, LegacyGuest) {
+TEST_F(LockStateControllerImpl2Test, LegacyGuest) {
Initialize(true, user::LOGGED_IN_GUEST);
PressPowerButton();
@@ -492,7 +490,7 @@
// When we hold the power button while the user isn't logged in, we should shut
// down the machine directly.
-TEST_F(SessionStateControllerImpl2Test, ShutdownWhenNotLoggedIn) {
+TEST_F(LockStateControllerImpl2Test, ShutdownWhenNotLoggedIn) {
Initialize(false, user::LOGGED_IN_NONE);
// Press the power button and check that we start the shutdown timer.
@@ -532,7 +530,7 @@
// Test that we lock the screen and deal with unlocking correctly.
// TODO(antrim): Reenable this: http://crbug.com/167048
-TEST_F(SessionStateControllerImpl2Test, DISABLED_LockAndUnlock) {
+TEST_F(LockStateControllerImpl2Test, DISABLED_LockAndUnlock) {
Initialize(false, user::LOGGED_IN_USER);
ExpectUnlockedState();
@@ -551,7 +549,7 @@
EXPECT_EQ(1, delegate_->num_lock_requests());
// Notify that we locked successfully.
- state_controller_->OnStartingLock();
+ lock_state_controller_->OnStartingLock();
// We had that animation already.
//TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
@@ -592,7 +590,7 @@
// Test that we deal with cancelling lock correctly.
// TODO(antrim): Reenable this: http://crbug.com/167048
-TEST_F(SessionStateControllerImpl2Test, DISABLED_LockAndCancel) {
+TEST_F(LockStateControllerImpl2Test, DISABLED_LockAndCancel) {
Initialize(false, user::LOGGED_IN_USER);
ExpectUnlockedState();
@@ -629,7 +627,8 @@
// Test that we deal with cancelling lock correctly.
// TODO(antrim): Reenable this: http://crbug.com/167048
-TEST_F(SessionStateControllerImpl2Test, DISABLED_LockAndCancelAndLockAgain) {
+TEST_F(LockStateControllerImpl2Test,
+ DISABLED_LockAndCancelAndLockAgain) {
Initialize(false, user::LOGGED_IN_USER);
ExpectUnlockedState();
@@ -666,7 +665,7 @@
// Hold the power button down from the unlocked state to eventual shutdown.
// TODO(antrim): Reenable this: http://crbug.com/167048
-TEST_F(SessionStateControllerImpl2Test, DISABLED_LockToShutdown) {
+TEST_F(LockStateControllerImpl2Test, DISABLED_LockToShutdown) {
Initialize(false, user::LOGGED_IN_USER);
// Hold the power button and lock the screen.
@@ -699,7 +698,7 @@
// Hold the power button down from the unlocked state to eventual shutdown,
// then release the button while system does locking.
-TEST_F(SessionStateControllerImpl2Test, CancelLockToShutdown) {
+TEST_F(LockStateControllerImpl2Test, CancelLockToShutdown) {
Initialize(false, user::LOGGED_IN_USER);
PressPowerButton();
@@ -716,14 +715,14 @@
Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS);
- EXPECT_FALSE(state_controller_->ShutdownRequested());
+ EXPECT_FALSE(lock_state_controller_->ShutdownRequested());
EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running());
EXPECT_FALSE(test_api_->shutdown_timer_is_running());
}
// Test that we handle the case where lock requests are ignored.
// TODO(antrim): Reenable this: http://crbug.com/167048
-TEST_F(SessionStateControllerImpl2Test, DISABLED_Lock) {
+TEST_F(LockStateControllerImpl2Test, DISABLED_Lock) {
// We require animations to have a duration for this test.
ui::ScopedAnimationDurationScaleMode normal_duration_mode(
ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
@@ -752,7 +751,7 @@
}
// Test the basic operation of the lock button (not logged in).
-TEST_F(SessionStateControllerImpl2Test, LockButtonBasicNotLoggedIn) {
+TEST_F(LockStateControllerImpl2Test, LockButtonBasicNotLoggedIn) {
// The lock button shouldn't do anything if we aren't logged in.
Initialize(false, user::LOGGED_IN_NONE);
@@ -763,7 +762,7 @@
}
// Test the basic operation of the lock button (guest).
-TEST_F(SessionStateControllerImpl2Test, LockButtonBasicGuest) {
+TEST_F(LockStateControllerImpl2Test, LockButtonBasicGuest) {
// The lock button shouldn't do anything when we're logged in as a guest.
Initialize(false, user::LOGGED_IN_GUEST);
@@ -775,7 +774,7 @@
// Test the basic operation of the lock button.
// TODO(antrim): Reenable this: http://crbug.com/167048
-TEST_F(SessionStateControllerImpl2Test, DISABLED_LockButtonBasic) {
+TEST_F(LockStateControllerImpl2Test, DISABLED_LockButtonBasic) {
// If we're logged in as a regular user, we should start the lock timer and
// the pre-lock animation.
Initialize(false, user::LOGGED_IN_USER);
@@ -824,7 +823,7 @@
// Test that the power button takes priority over the lock button.
// TODO(antrim): Reenable this: http://crbug.com/167048
-TEST_F(SessionStateControllerImpl2Test,
+TEST_F(LockStateControllerImpl2Test,
DISABLED_PowerButtonPreemptsLockButton) {
Initialize(false, user::LOGGED_IN_USER);
@@ -863,9 +862,9 @@
// When the screen is locked without going through the usual power-button
// slow-close path (e.g. via the wrench menu), test that we still show the
// fast-close animation.
-TEST_F(SessionStateControllerImpl2Test, LockWithoutButton) {
+TEST_F(LockStateControllerImpl2Test, LockWithoutButton) {
Initialize(false, user::LOGGED_IN_USER);
- state_controller_->OnStartingLock();
+ lock_state_controller_->OnStartingLock();
ExpectPreLockAnimationStarted();
EXPECT_FALSE(test_api_->is_lock_cancellable());
@@ -877,9 +876,9 @@
// When we hear that the process is exiting but we haven't had a chance to
// display an animation, we should just blank the screen.
-TEST_F(SessionStateControllerImpl2Test, ShutdownWithoutButton) {
+TEST_F(LockStateControllerImpl2Test, ShutdownWithoutButton) {
Initialize(false, user::LOGGED_IN_USER);
- state_controller_->OnAppTerminating();
+ lock_state_controller_->OnAppTerminating();
EXPECT_TRUE(
animator_api_->ContainersAreAnimated(
@@ -891,10 +890,10 @@
// Test that we display the fast-close animation and shut down when we get an
// outside request to shut down (e.g. from the login or lock screen).
-TEST_F(SessionStateControllerImpl2Test, RequestShutdownFromLoginScreen) {
+TEST_F(LockStateControllerImpl2Test, RequestShutdownFromLoginScreen) {
Initialize(false, user::LOGGED_IN_NONE);
- state_controller_->RequestShutdown();
+ lock_state_controller_->RequestShutdown();
ExpectShutdownAnimationStarted();
Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
@@ -908,14 +907,14 @@
EXPECT_EQ(1, NumShutdownRequests());
}
-TEST_F(SessionStateControllerImpl2Test, RequestShutdownFromLockScreen) {
+TEST_F(LockStateControllerImpl2Test, RequestShutdownFromLockScreen) {
Initialize(false, user::LOGGED_IN_USER);
SystemLocks();
Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
ExpectPastLockAnimationFinished();
- state_controller_->RequestShutdown();
+ lock_state_controller_->RequestShutdown();
ExpectShutdownAnimationStarted();
Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
@@ -930,7 +929,7 @@
}
// TODO(antrim): Reenable this: http://crbug.com/167048
-TEST_F(SessionStateControllerImpl2Test,
+TEST_F(LockStateControllerImpl2Test,
DISABLED_RequestAndCancelShutdownFromLockScreen) {
Initialize(false, user::LOGGED_IN_USER);
@@ -967,7 +966,7 @@
}
// Test that we ignore power button presses when the screen is turned off.
-TEST_F(SessionStateControllerImpl2Test, IgnorePowerButtonIfScreenIsOff) {
+TEST_F(LockStateControllerImpl2Test, IgnorePowerButtonIfScreenIsOff) {
Initialize(false, user::LOGGED_IN_USER);
// When the screen brightness is at 0%, we shouldn't do anything in response
@@ -988,7 +987,7 @@
// Test that hidden background appears and revers correctly on lock/cancel.
// TODO(antrim): Reenable this: http://crbug.com/167048
-TEST_F(SessionStateControllerImpl2Test,
+TEST_F(LockStateControllerImpl2Test,
DISABLED_TestHiddenBackgroundLockCancel) {
Initialize(false, user::LOGGED_IN_USER);
HideBackground();
@@ -1018,7 +1017,7 @@
// Test that hidden background appears and revers correctly on lock/unlock.
// TODO(antrim): Reenable this: http://crbug.com/167048
-TEST_F(SessionStateControllerImpl2Test,
+TEST_F(LockStateControllerImpl2Test,
DISABLED_TestHiddenBackgroundLockUnlock) {
Initialize(false, user::LOGGED_IN_USER);
HideBackground();
diff --git a/ash/wm/lock_state_observer.h b/ash/wm/lock_state_observer.h
new file mode 100644
index 0000000..d247e82
--- /dev/null
+++ b/ash/wm/lock_state_observer.h
@@ -0,0 +1,28 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_WM_LOCK_STATE_OBSERVER_H_
+#define ASH_WM_LOCK_STATE_OBSERVER_H_
+
+#include "ash/ash_export.h"
+
+namespace ash {
+
+// Interface for classes that want to be notified by LockStateController when
+// session-related events occur.
+class ASH_EXPORT LockStateObserver {
+ public:
+ enum EventType {
+ EVENT_PRELOCK_ANIMATION_STARTED,
+ EVENT_LOCK_ANIMATION_STARTED,
+ EVENT_LOCK_ANIMATION_FINISHED,
+ };
+
+ virtual void OnLockStateEvent(EventType event) = 0;
+ virtual ~LockStateObserver() {}
+};
+
+} // namespace ash
+
+#endif // ASH_WM_LOCK_STATE_OBSERVER_H_
diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc
index 68506080..c2e3789 100644
--- a/ash/wm/power_button_controller.cc
+++ b/ash/wm/power_button_controller.cc
@@ -8,15 +8,16 @@
#include "ash/session_state_delegate.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
+#include "ash/wm/lock_state_controller.h"
#include "ash/wm/session_state_animator.h"
-#include "ash/wm/session_state_controller.h"
#include "base/command_line.h"
#include "ui/aura/root_window.h"
#include "ui/views/corewm/compound_event_filter.h"
namespace ash {
-PowerButtonController::PowerButtonController(SessionStateController* controller)
+PowerButtonController::PowerButtonController(
+ LockStateController* controller)
: power_button_down_(false),
lock_button_down_(false),
screen_is_off_(false),
diff --git a/ash/wm/power_button_controller.h b/ash/wm/power_button_controller.h
index 3c0127b..558bf6d 100644
--- a/ash/wm/power_button_controller.h
+++ b/ash/wm/power_button_controller.h
@@ -24,14 +24,14 @@
class PowerButtonControllerTest;
}
-class SessionStateController;
+class LockStateController;
// Displays onscreen animations and locks or suspends the system in response to
// the power button being pressed or released.
class ASH_EXPORT PowerButtonController {
public:
- explicit PowerButtonController(SessionStateController* controller);
+ explicit PowerButtonController(LockStateController* controller);
virtual ~PowerButtonController();
void set_has_legacy_power_button_for_test(bool legacy) {
@@ -59,7 +59,7 @@
// that misreports power button releases?
bool has_legacy_power_button_;
- SessionStateController* controller_; // Not owned.
+ LockStateController* controller_; // Not owned.
DISALLOW_COPY_AND_ASSIGN(PowerButtonController);
};
diff --git a/ash/wm/power_button_controller_unittest.cc b/ash/wm/power_button_controller_unittest.cc
index 7dbdf73..5ee1e27 100644
--- a/ash/wm/power_button_controller_unittest.cc
+++ b/ash/wm/power_button_controller_unittest.cc
@@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ash/wm/lock_state_controller.h"
#include "ash/wm/power_button_controller.h"
#include "ash/wm/session_state_animator.h"
-#include "ash/wm/session_state_controller.h"
#include "ash/wm/session_state_controller_impl.h"
-
#include "ash/ash_switches.h"
#include "ash/session_state_delegate.h"
#include "ash/shell.h"
@@ -33,7 +32,7 @@
// Fake implementation of PowerButtonControllerDelegate that just logs requests
// to lock the screen and shut down the device.
class TestPowerButtonControllerDelegate :
- public SessionStateControllerDelegate {
+ public LockStateControllerDelegate {
public:
TestPowerButtonControllerDelegate()
: num_lock_requests_(0),
@@ -69,13 +68,13 @@
AshTestBase::SetUp();
delegate_ = new TestPowerButtonControllerDelegate;
controller_ = Shell::GetInstance()->power_button_controller();
- state_controller_ = static_cast<SessionStateControllerImpl*>(
- Shell::GetInstance()->session_state_controller());
- state_controller_->SetDelegate(delegate_); // transfers ownership
- test_api_.reset(new SessionStateControllerImpl::TestApi(state_controller_));
- animator_api_.reset(
- new internal::SessionStateAnimator::TestApi(state_controller_->
- animator_.get()));
+ lock_state_controller_ = static_cast<SessionStateControllerImpl*>(
+ Shell::GetInstance()->lock_state_controller());
+ lock_state_controller_->SetDelegate(delegate_); // transfers ownership
+ test_api_.reset(new SessionStateControllerImpl::TestApi(
+ lock_state_controller_));
+ animator_api_.reset(new internal::SessionStateAnimator::TestApi(
+ lock_state_controller_->animator_.get()));
shell_delegate_ = reinterpret_cast<TestShellDelegate*>(
ash::Shell::GetInstance()->delegate());
state_delegate_ = Shell::GetInstance()->session_state_delegate();
@@ -94,7 +93,7 @@
}
PowerButtonController* controller_; // not owned
- SessionStateControllerImpl* state_controller_; // not owned
+ SessionStateControllerImpl* lock_state_controller_; // not owned
TestPowerButtonControllerDelegate* delegate_; // not owned
TestShellDelegate* shell_delegate_; // not owned
SessionStateDelegate* state_delegate_; // not owned
@@ -112,8 +111,8 @@
// state.
TEST_F(PowerButtonControllerTest, LegacyLockAndShutDown) {
controller_->set_has_legacy_power_button_for_test(true);
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
- state_controller_->OnLockStateChanged(false);
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
+ lock_state_controller_->OnLockStateChanged(false);
// We should request that the screen be locked immediately after seeing the
// power button get pressed.
@@ -126,7 +125,7 @@
EXPECT_EQ(1, delegate_->num_lock_requests());
// Notify that we locked successfully.
- state_controller_->OnStartingLock();
+ lock_state_controller_->OnStartingLock();
EXPECT_TRUE(
animator_api_->ContainersAreAnimated(
internal::SessionStateAnimator::LAUNCHER,
@@ -141,7 +140,7 @@
internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY));
// Notify that the lock window is visible. We should make it fade in.
- state_controller_->OnLockStateChanged(true);
+ lock_state_controller_->OnLockStateChanged(true);
state_delegate_->LockScreen();
EXPECT_TRUE(
animator_api_->ContainersAreAnimated(
@@ -182,8 +181,8 @@
// while we're not logged in on an unofficial system.
TEST_F(PowerButtonControllerTest, LegacyNotLoggedIn) {
controller_->set_has_legacy_power_button_for_test(true);
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_NONE);
- state_controller_->OnLockStateChanged(false);
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_NONE);
+ lock_state_controller_->OnLockStateChanged(false);
SetUserLoggedIn(false);
controller_->OnPowerButtonEvent(true, base::TimeTicks::Now());
EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
@@ -193,8 +192,8 @@
// while we're logged in as a guest on an unofficial system.
TEST_F(PowerButtonControllerTest, LegacyGuest) {
controller_->set_has_legacy_power_button_for_test(true);
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_GUEST);
- state_controller_->OnLockStateChanged(false);
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_GUEST);
+ lock_state_controller_->OnLockStateChanged(false);
SetCanLockScreen(false);
controller_->OnPowerButtonEvent(true, base::TimeTicks::Now());
EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
@@ -204,8 +203,8 @@
// down the machine directly.
TEST_F(PowerButtonControllerTest, ShutdownWhenNotLoggedIn) {
controller_->set_has_legacy_power_button_for_test(false);
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_NONE);
- state_controller_->OnLockStateChanged(false);
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_NONE);
+ lock_state_controller_->OnLockStateChanged(false);
SetUserLoggedIn(false);
// Press the power button and check that we start the shutdown timer.
@@ -250,8 +249,8 @@
// Test that we lock the screen and deal with unlocking correctly.
TEST_F(PowerButtonControllerTest, LockAndUnlock) {
controller_->set_has_legacy_power_button_for_test(false);
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
- state_controller_->OnLockStateChanged(false);
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
+ lock_state_controller_->OnLockStateChanged(false);
// We should initially be showing the screen locker containers, since they
// also contain login-related windows that we want to show during the
@@ -292,7 +291,7 @@
internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE));
// Notify that we locked successfully.
- state_controller_->OnStartingLock();
+ lock_state_controller_->OnStartingLock();
EXPECT_TRUE(
animator_api_->ContainersAreAnimated(
internal::SessionStateAnimator::LAUNCHER,
@@ -307,7 +306,7 @@
internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY));
// Notify that the lock window is visible. We should make it fade in.
- state_controller_->OnLockStateChanged(true);
+ lock_state_controller_->OnLockStateChanged(true);
state_delegate_->LockScreen();
EXPECT_TRUE(
animator_api_->ContainersAreAnimated(
@@ -322,7 +321,7 @@
// Notify that the screen has been unlocked. We should show the
// non-screen-locker windows.
- state_controller_->OnLockStateChanged(false);
+ lock_state_controller_->OnLockStateChanged(false);
state_delegate_->UnlockScreen();
EXPECT_TRUE(
animator_api_->ContainersAreAnimated(
@@ -335,15 +334,15 @@
// Hold the power button down from the unlocked state to eventual shutdown.
TEST_F(PowerButtonControllerTest, LockToShutdown) {
controller_->set_has_legacy_power_button_for_test(false);
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
- state_controller_->OnLockStateChanged(false);
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
+ lock_state_controller_->OnLockStateChanged(false);
// Hold the power button and lock the screen.
controller_->OnPowerButtonEvent(true, base::TimeTicks::Now());
EXPECT_TRUE(test_api_->lock_timer_is_running());
test_api_->trigger_lock_timeout();
- state_controller_->OnStartingLock();
- state_controller_->OnLockStateChanged(true);
+ lock_state_controller_->OnStartingLock();
+ lock_state_controller_->OnLockStateChanged(true);
state_delegate_->LockScreen();
// When the lock-to-shutdown timeout fires, we should start the shutdown
@@ -370,21 +369,21 @@
TEST_F(PowerButtonControllerTest, CancelLockToShutdown) {
controller_->set_has_legacy_power_button_for_test(false);
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
- state_controller_->OnLockStateChanged(false);
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
+ lock_state_controller_->OnLockStateChanged(false);
// Hold the power button and lock the screen.
controller_->OnPowerButtonEvent(true, base::TimeTicks::Now());
EXPECT_TRUE(test_api_->lock_timer_is_running());
test_api_->trigger_lock_timeout();
- state_controller_->OnStartingLock();
+ lock_state_controller_->OnStartingLock();
// Power button is released while system attempts to lock.
controller_->OnPowerButtonEvent(false, base::TimeTicks::Now());
- state_controller_->OnLockStateChanged(true);
+ lock_state_controller_->OnLockStateChanged(true);
state_delegate_->LockScreen();
- EXPECT_FALSE(state_controller_->ShutdownRequested());
+ EXPECT_FALSE(lock_state_controller_->ShutdownRequested());
EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running());
EXPECT_FALSE(test_api_->shutdown_timer_is_running());
}
@@ -396,8 +395,8 @@
ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
controller_->set_has_legacy_power_button_for_test(false);
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
- state_controller_->OnLockStateChanged(false);
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
+ lock_state_controller_->OnLockStateChanged(false);
// Hold the power button and lock the screen.
controller_->OnPowerButtonEvent(true, base::TimeTicks::Now());
@@ -428,8 +427,8 @@
TEST_F(PowerButtonControllerTest, LockButtonBasic) {
controller_->set_has_legacy_power_button_for_test(false);
// The lock button shouldn't do anything if we aren't logged in.
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_NONE);
- state_controller_->OnLockStateChanged(false);
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_NONE);
+ lock_state_controller_->OnLockStateChanged(false);
SetUserLoggedIn(false);
controller_->OnLockButtonEvent(true, base::TimeTicks::Now());
EXPECT_FALSE(test_api_->lock_timer_is_running());
@@ -437,7 +436,7 @@
EXPECT_EQ(0, delegate_->num_lock_requests());
// Ditto for when we're logged in as a guest.
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_GUEST);
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_GUEST);
SetUserLoggedIn(true);
SetCanLockScreen(false);
controller_->OnLockButtonEvent(true, base::TimeTicks::Now());
@@ -447,7 +446,7 @@
// If we're logged in as a regular user, we should start the lock timer and
// the pre-lock animation.
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
SetCanLockScreen(true);
controller_->OnLockButtonEvent(true, base::TimeTicks::Now());
EXPECT_TRUE(test_api_->lock_timer_is_running());
@@ -480,8 +479,8 @@
controller_->OnLockButtonEvent(false, base::TimeTicks::Now());
// Pressing the button also shouldn't do anything after the screen is locked.
- state_controller_->OnStartingLock();
- state_controller_->OnLockStateChanged(true);
+ lock_state_controller_->OnStartingLock();
+ lock_state_controller_->OnLockStateChanged(true);
state_delegate_->LockScreen();
controller_->OnLockButtonEvent(true, base::TimeTicks::Now());
EXPECT_FALSE(test_api_->lock_timer_is_running());
@@ -491,8 +490,8 @@
// Test that the power button takes priority over the lock button.
TEST_F(PowerButtonControllerTest, PowerButtonPreemptsLockButton) {
controller_->set_has_legacy_power_button_for_test(false);
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
- state_controller_->OnLockStateChanged(false);
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
+ lock_state_controller_->OnLockStateChanged(false);
// While the lock button is down, hold the power button.
controller_->OnLockButtonEvent(true, base::TimeTicks::Now());
@@ -523,8 +522,8 @@
// slow-close path (e.g. via the wrench menu), test that we still show the
// fast-close animation.
TEST_F(PowerButtonControllerTest, LockWithoutButton) {
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
- state_controller_->OnStartingLock();
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
+ lock_state_controller_->OnStartingLock();
EXPECT_TRUE(
animator_api_->ContainersAreAnimated(
internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
@@ -534,8 +533,8 @@
// When we hear that the process is exiting but we haven't had a chance to
// display an animation, we should just blank the screen.
TEST_F(PowerButtonControllerTest, ShutdownWithoutButton) {
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
- state_controller_->OnAppTerminating();
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
+ lock_state_controller_->OnAppTerminating();
EXPECT_TRUE(
animator_api_->ContainersAreAnimated(
internal::SessionStateAnimator::kAllContainersMask,
@@ -547,10 +546,10 @@
// Test that we display the fast-close animation and shut down when we get an
// outside request to shut down (e.g. from the login or lock screen).
TEST_F(PowerButtonControllerTest, RequestShutdownFromLoginScreen) {
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_NONE);
- state_controller_->OnLockStateChanged(false);
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_NONE);
+ lock_state_controller_->OnLockStateChanged(false);
SetUserLoggedIn(false);
- state_controller_->RequestShutdown();
+ lock_state_controller_->RequestShutdown();
EXPECT_TRUE(
animator_api_->ContainersAreAnimated(
internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
@@ -569,10 +568,10 @@
}
TEST_F(PowerButtonControllerTest, RequestShutdownFromLockScreen) {
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
- state_controller_->OnLockStateChanged(true);
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
+ lock_state_controller_->OnLockStateChanged(true);
state_delegate_->LockScreen();
- state_controller_->RequestShutdown();
+ lock_state_controller_->RequestShutdown();
EXPECT_TRUE(
animator_api_->ContainersAreAnimated(
internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
@@ -591,8 +590,8 @@
}
TEST_F(PowerButtonControllerTest, RequestAndCancelShutdownFromLockScreen) {
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
- state_controller_->OnLockStateChanged(true);
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
+ lock_state_controller_->OnLockStateChanged(true);
state_delegate_->LockScreen();
// Press the power button and check that we start the shutdown timer.
@@ -619,7 +618,7 @@
// Test that we ignore power button presses when the screen is turned off.
TEST_F(PowerButtonControllerTest, IgnorePowerButtonIfScreenIsOff) {
- state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
+ lock_state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
// When the screen brightness is at 0%, we shouldn't do anything in response
// to power button presses.
diff --git a/ash/wm/session_state_controller.cc b/ash/wm/session_state_controller.cc
deleted file mode 100644
index 0bcf31d..0000000
--- a/ash/wm/session_state_controller.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/wm/session_state_controller.h"
-
-#include "ash/ash_switches.h"
-#include "ash/shell.h"
-#include "ash/shell_delegate.h"
-#include "ash/shell_window_ids.h"
-#include "ash/wm/session_state_animator.h"
-#include "base/command_line.h"
-#include "ui/aura/root_window.h"
-#include "ui/views/corewm/compound_event_filter.h"
-
-#if defined(OS_CHROMEOS)
-#include "base/chromeos/chromeos_version.h"
-#endif
-
-namespace ash {
-
-const int SessionStateController::kLockTimeoutMs = 400;
-const int SessionStateController::kShutdownTimeoutMs = 400;
-const int SessionStateController::kLockFailTimeoutMs = 4000;
-const int SessionStateController::kLockToShutdownTimeoutMs = 150;
-const int SessionStateController::kShutdownRequestDelayMs = 50;
-
-SessionStateController::SessionStateController()
- : animator_(new internal::SessionStateAnimator()) {
-}
-
-SessionStateController::~SessionStateController() {
-}
-
-void SessionStateController::SetDelegate(
- SessionStateControllerDelegate* delegate) {
- delegate_.reset(delegate);
-}
-
-void SessionStateController::AddObserver(SessionStateObserver* observer) {
- observers_.AddObserver(observer);
-}
-
-void SessionStateController::RemoveObserver(SessionStateObserver* observer) {
- observers_.RemoveObserver(observer);
-}
-
-bool SessionStateController::HasObserver(SessionStateObserver* observer) {
- return observers_.HasObserver(observer);
-}
-
-
-} // namespace ash
diff --git a/ash/wm/session_state_controller_impl.cc b/ash/wm/session_state_controller_impl.cc
index 0469b6b..dbd97a7 100644
--- a/ash/wm/session_state_controller_impl.cc
+++ b/ash/wm/session_state_controller_impl.cc
@@ -73,9 +73,8 @@
internal::SessionStateAnimator::ANIMATION_FADE_IN,
internal::SessionStateAnimator::ANIMATION_SPEED_SHOW_LOCK_SCREEN);
DispatchCancelMode();
- FOR_EACH_OBSERVER(SessionStateObserver, observers_,
- OnSessionStateEvent(
- SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED));
+ FOR_EACH_OBSERVER(LockStateObserver, observers_,
+ OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_STARTED));
lock_timer_.Stop();
lock_fail_timer_.Stop();
@@ -108,8 +107,8 @@
internal::SessionStateAnimator::ANIMATION_SPEED_FAST);
DispatchCancelMode();
- FOR_EACH_OBSERVER(SessionStateObserver, observers_,
- OnSessionStateEvent(SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED));
+ FOR_EACH_OBSERVER(LockStateObserver, observers_,
+ OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_STARTED));
// Hide the screen locker containers so we can make them fade in later.
animator_->StartAnimation(
@@ -124,8 +123,8 @@
internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE,
internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE);
DispatchCancelMode();
- FOR_EACH_OBSERVER(SessionStateObserver, observers_,
- OnSessionStateEvent(SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED));
+ FOR_EACH_OBSERVER(LockStateObserver, observers_,
+ OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_STARTED));
OnLockTimeout();
}
@@ -137,9 +136,8 @@
internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE,
internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE);
DispatchCancelMode();
- FOR_EACH_OBSERVER(SessionStateObserver, observers_,
- OnSessionStateEvent(
- SessionStateObserver::EVENT_PRELOCK_ANIMATION_STARTED));
+ FOR_EACH_OBSERVER(LockStateObserver, observers_,
+ OnLockStateEvent(LockStateObserver::EVENT_PRELOCK_ANIMATION_STARTED));
StartLockTimer();
}
diff --git a/ash/wm/session_state_controller_impl.h b/ash/wm/session_state_controller_impl.h
index cab27b3..79a5c2cc 100644
--- a/ash/wm/session_state_controller_impl.h
+++ b/ash/wm/session_state_controller_impl.h
@@ -7,8 +7,8 @@
#include "ash/ash_export.h"
#include "ash/shell_observer.h"
+#include "ash/wm/lock_state_controller.h"
#include "ash/wm/session_state_animator.h"
-#include "ash/wm/session_state_controller.h"
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/time.h"
@@ -32,7 +32,8 @@
// Displays onscreen animations and locks or suspends the system in response to
// the power button being pressed or released.
-class ASH_EXPORT SessionStateControllerImpl : public SessionStateController {
+class ASH_EXPORT SessionStateControllerImpl :
+ public LockStateController {
public:
// Helper class used by tests to access internal state.
@@ -96,7 +97,7 @@
virtual void OnAppTerminating() OVERRIDE;
virtual void OnLockStateChanged(bool locked) OVERRIDE;
- // SessionStateController overrides:
+ // SessionLockStateController overrides:
virtual void StartLockAnimation(bool shutdown_after_lock) OVERRIDE;
virtual void StartShutdownAnimation() OVERRIDE;
diff --git a/ash/wm/session_state_observer.h b/ash/wm/session_state_observer.h
deleted file mode 100644
index 8df4018..0000000
--- a/ash/wm/session_state_observer.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_WM_SESSION_STATE_OBSERVER_H_
-#define ASH_WM_SESSION_STATE_OBSERVER_H_
-
-#include "ash/ash_export.h"
-
-namespace ash {
-
-// Interface for classes that want to be notified by SessionStateController when
-// session-related events occur.
-class ASH_EXPORT SessionStateObserver {
- public:
- enum EventType {
- EVENT_PRELOCK_ANIMATION_STARTED,
- EVENT_LOCK_ANIMATION_STARTED,
- EVENT_LOCK_ANIMATION_FINISHED,
- };
-
- virtual void OnSessionStateEvent(EventType event) = 0;
- virtual ~SessionStateObserver() {};
-};
-
-} // namespace ash
-
-#endif // ASH_WM_SESSION_STATE_CONTROLLER_H_
diff --git a/ash/wm/toplevel_window_event_handler_unittest.cc b/ash/wm/toplevel_window_event_handler_unittest.cc
index 527c9b3c..0076d3d 100644
--- a/ash/wm/toplevel_window_event_handler_unittest.cc
+++ b/ash/wm/toplevel_window_event_handler_unittest.cc
@@ -8,8 +8,8 @@
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
+#include "ash/wm/lock_state_controller_impl2.h"
#include "ash/wm/property_util.h"
-#include "ash/wm/session_state_controller_impl.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/snap_sizer.h"
#include "ash/wm/workspace_controller.h"
@@ -472,9 +472,9 @@
// Tests that a gesture cannot minimize a window in login/lock screen.
TEST_F(ToplevelWindowEventHandlerTest, GestureDragMinimizeLoginScreen) {
- SessionStateControllerImpl* state_controller =
- static_cast<SessionStateControllerImpl*>
- (Shell::GetInstance()->session_state_controller());
+ LockStateControllerImpl2* state_controller =
+ static_cast<LockStateControllerImpl2*>
+ (Shell::GetInstance()->lock_state_controller());
state_controller->OnLoginStateChanged(user::LOGGED_IN_NONE);
state_controller->OnLockStateChanged(false);
SetUserLoggedIn(false);
diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc
index e319b52..30cc533 100644
--- a/chrome/browser/chromeos/login/screen_locker.cc
+++ b/chrome/browser/chromeos/login/screen_locker.cc
@@ -10,7 +10,7 @@
#include "ash/ash_switches.h"
#include "ash/desktop_background/desktop_background_controller.h"
#include "ash/shell.h"
-#include "ash/wm/session_state_controller.h"
+#include "ash/wm/lock_state_controller.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
@@ -373,7 +373,7 @@
DCHECK(screen_locker_);
base::Callback<void(void)> callback =
base::Bind(&ScreenLocker::ScheduleDeletion);
- ash::Shell::GetInstance()->session_state_controller()->
+ ash::Shell::GetInstance()->lock_state_controller()->
OnLockScreenHide(callback);
}
diff --git a/chrome/browser/chromeos/login/webui_screen_locker.cc b/chrome/browser/chromeos/login/webui_screen_locker.cc
index 3f3188b..6d4645d 100644
--- a/chrome/browser/chromeos/login/webui_screen_locker.cc
+++ b/chrome/browser/chromeos/login/webui_screen_locker.cc
@@ -5,8 +5,8 @@
#include "chrome/browser/chromeos/login/webui_screen_locker.h"
#include "ash/shell.h"
-#include "ash/wm/session_state_controller.h"
-#include "ash/wm/session_state_observer.h"
+#include "ash/wm/lock_state_controller.h"
+#include "ash/wm/lock_state_observer.h"
#include "base/command_line.h"
#include "base/metrics/histogram.h"
#include "base/utf_string_conversions.h"
@@ -50,7 +50,7 @@
webui_ready_(false),
weak_factory_(this) {
set_should_emit_login_prompt_visible(false);
- ash::Shell::GetInstance()->session_state_controller()->AddObserver(this);
+ ash::Shell::GetInstance()->lock_state_controller()->AddObserver(this);
DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this);
}
@@ -140,7 +140,8 @@
WebUIScreenLocker::~WebUIScreenLocker() {
DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this);
- ash::Shell::GetInstance()->session_state_controller()->RemoveObserver(this);
+ ash::Shell::GetInstance()->
+ lock_state_controller()->RemoveObserver(this);
// In case of shutdown, lock_window_ may be deleted before WebUIScreenLocker.
if (lock_window_) {
lock_window_->RemoveObserver(this);
@@ -275,11 +276,11 @@
}
////////////////////////////////////////////////////////////////////////////////
-// SessionStateObserver override.
+// SessionLockStateObserver override.
-void WebUIScreenLocker::OnSessionStateEvent(
- ash::SessionStateObserver::EventType event) {
- if (event == ash::SessionStateObserver::EVENT_LOCK_ANIMATION_FINISHED) {
+void WebUIScreenLocker::OnLockStateEvent(
+ ash::LockStateObserver::EventType event) {
+ if (event == ash::LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED) {
// Release capture if any.
aura::client::GetCaptureClient(GetNativeWindow()->GetRootWindow())->
SetCapture(NULL);
diff --git a/chrome/browser/chromeos/login/webui_screen_locker.h b/chrome/browser/chromeos/login/webui_screen_locker.h
index 1034687..4579bbb 100644
--- a/chrome/browser/chromeos/login/webui_screen_locker.h
+++ b/chrome/browser/chromeos/login/webui_screen_locker.h
@@ -7,7 +7,7 @@
#include <string>
-#include "ash/wm/session_state_observer.h"
+#include "ash/wm/lock_state_observer.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
@@ -43,7 +43,7 @@
public LoginDisplay::Delegate,
public ScreenLockerDelegate,
public LockWindow::Observer,
- public ash::SessionStateObserver,
+ public ash::LockStateObserver,
public views::WidgetObserver,
public PowerManagerClient::Observer,
public content::WebContentsObserver {
@@ -92,9 +92,9 @@
// LockWindow::Observer implementation.
virtual void OnLockWindowReady() OVERRIDE;
- // SessionStateObserver override.
- virtual void OnSessionStateEvent(ash::SessionStateObserver::EventType event)
- OVERRIDE;
+ // LockStateObserver override.
+ virtual void OnLockStateEvent(
+ ash::LockStateObserver::EventType event) OVERRIDE;
// WidgetObserver override.
virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
diff --git a/chrome/browser/chromeos/power/power_button_observer.cc b/chrome/browser/chromeos/power/power_button_observer.cc
index 87bfff3..38874d9 100644
--- a/chrome/browser/chromeos/power/power_button_observer.cc
+++ b/chrome/browser/chromeos/power/power_button_observer.cc
@@ -29,7 +29,7 @@
} // namespace
PowerButtonObserver::PowerButtonObserver() {
- ash::Shell::GetInstance()->session_state_controller()->
+ ash::Shell::GetInstance()->lock_state_controller()->
SetDelegate(new SessionStateControllerDelegateChromeos);
registrar_.Add(
@@ -89,7 +89,7 @@
}
void PowerButtonObserver::LockScreen() {
- ash::Shell::GetInstance()->session_state_controller()->OnStartingLock();
+ ash::Shell::GetInstance()->lock_state_controller()->OnStartingLock();
}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/power/session_state_controller_delegate_chromeos.h b/chrome/browser/chromeos/power/session_state_controller_delegate_chromeos.h
index dd7ec32..c7d0845 100644
--- a/chrome/browser/chromeos/power/session_state_controller_delegate_chromeos.h
+++ b/chrome/browser/chromeos/power/session_state_controller_delegate_chromeos.h
@@ -5,14 +5,14 @@
#ifndef CHROME_BROWSER_CHROMEOS_POWER_SESSION_STATE_CONTROLLER_DELEGATE_CHROMEOS_H_
#define CHROME_BROWSER_CHROMEOS_POWER_SESSION_STATE_CONTROLLER_DELEGATE_CHROMEOS_H_
-#include "ash/wm/session_state_controller.h"
+#include "ash/wm/lock_state_controller.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
namespace chromeos {
class SessionStateControllerDelegateChromeos
- : public ash::SessionStateControllerDelegate {
+ : public ash::LockStateControllerDelegate {
public:
SessionStateControllerDelegateChromeos() {}
virtual ~SessionStateControllerDelegateChromeos() {}
diff --git a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
index 33854c8c..a9ce0b6a 100644
--- a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
+++ b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
@@ -31,7 +31,7 @@
#include "ash/system/user/update_observer.h"
#include "ash/system/user/user_observer.h"
#include "ash/volume_control_delegate.h"
-#include "ash/wm/session_state_controller.h"
+#include "ash/wm/lock_state_controller.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/chromeos/chromeos_version.h"
@@ -592,7 +592,7 @@
}
virtual void ShutDown() OVERRIDE {
- ash::Shell::GetInstance()->session_state_controller()->RequestShutdown();
+ ash::Shell::GetInstance()->lock_state_controller()->RequestShutdown();
}
virtual void SignOut() OVERRIDE {
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
index f54ffa3..43c76af 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
@@ -57,7 +57,7 @@
#if defined(USE_AURA)
#include "ash/shell.h"
-#include "ash/wm/session_state_controller.h"
+#include "ash/wm/lock_state_controller.h"
#endif
using content::BrowserThread;
@@ -1156,7 +1156,7 @@
}
void SigninScreenHandler::HandleShutdownSystem() {
- ash::Shell::GetInstance()->session_state_controller()->RequestShutdown();
+ ash::Shell::GetInstance()->lock_state_controller()->RequestShutdown();
}
void SigninScreenHandler::HandleLoadWallpaper(const std::string& email) {